From 7688fa0f836242942fd02122f1b2547e20082a39 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Mon, 11 Jul 2022 13:09:25 -0400 Subject: [PATCH 001/111] update definitions.json --- .../binarycodec/definitions/definitions.json | 180 +++++++++++++++++- 1 file changed, 179 insertions(+), 1 deletion(-) diff --git a/xrpl/core/binarycodec/definitions/definitions.json b/xrpl/core/binarycodec/definitions/definitions.json index 317e1feb7..5a603b307 100644 --- a/xrpl/core/binarycodec/definitions/definitions.json +++ b/xrpl/core/binarycodec/definitions/definitions.json @@ -21,6 +21,10 @@ "UInt192": 21, "UInt384": 22, "UInt512": 23, + "Bridge": 24, + "XChainAttestations": 25, + "XChainAttestationBatch": 26, + "XChainClaimProof": 27, "Transaction": 10001, "LedgerEntry": 10002, "Validation": 10003, @@ -34,8 +38,10 @@ "Ticket": 84, "SignerList": 83, "Offer": 111, + "Bridge": 105, "LedgerHashes": 104, "Amendments": 102, + "XChainClaimId": 113, "FeeSettings": 115, "Escrow": 117, "PayChannel": 120, @@ -231,6 +237,16 @@ "type": "UInt8" } ], + [ + "WasLockingChainSend", + { + "nth": 19, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt8" + } + ], [ "LedgerEntryType", { @@ -931,6 +947,36 @@ "type": "UInt64" } ], + [ + "XChainClaimID", + { + "nth": 20, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "XChainAccountCreateCount", + { + "nth": 21, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], + [ + "XChainAccountClaimCount", + { + "nth": 22, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "UInt64" + } + ], [ "EmailHash", { @@ -1421,6 +1467,36 @@ "type": "Amount" } ], + [ + "XChainFee", + { + "nth": 20, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Amount" + } + ], + [ + "SignatureReward", + { + "nth": 21, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Amount" + } + ], + [ + "MinAccountCreateAmount", + { + "nth": 22, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Amount" + } + ], [ "PublicKey", { @@ -1761,6 +1837,36 @@ "type": "AccountID" } ], + [ + "ThisChainAccount", + { + "nth": 17, + "isVLEncoded": true, + "isSerialized": true, + "isSigningField": true, + "type": "AccountID" + } + ], + [ + "OtherChainAccount", + { + "nth": 18, + "isVLEncoded": true, + "isSerialized": true, + "isSigningField": true, + "type": "AccountID" + } + ], + [ + "AttestationRewardAccount", + { + "nth": 19, + "isVLEncoded": true, + "isSerialized": true, + "isSigningField": true, + "type": "AccountID" + } + ], [ "Indexes", { @@ -1811,6 +1917,36 @@ "type": "PathSet" } ], + [ + "Bridge", + { + "nth": 1, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Bridge" + } + ], + [ + "XChainClaimProof", + { + "nth": 1, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "XChainClaimProof" + } + ], + [ + "XChainAttestations", + { + "nth": 1, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "XChainAttestations" + } + ], [ "TransactionMetaData", { @@ -2021,6 +2157,16 @@ "type": "STObject" } ], + [ + "XChainProofSig", + { + "nth": 25, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "STObject" + } + ], [ "Signers", { @@ -2160,6 +2306,16 @@ "isSigningField": true, "type": "STArray" } + ], + [ + "XChainProofSigs", + { + "nth": 21, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "STArray" + } ] ], "TRANSACTION_RESULTS": { @@ -2215,6 +2371,12 @@ "temUNKNOWN": -264, "temSEQ_AND_TICKET": -263, "temBAD_NFTOKEN_TRANSFER_FEE": -262, + "temEQUAL_DOOR_ACCOUNTS": -261, + "temBAD_XCHAIN_PROOF": -260, + "temSIDECHAIN_BAD_ISSUES": -259, + "temSIDECHAIN_NONDOOR_OWNER": -258, + "temXCHAIN_BRIDGE_BAD_MIN_ACCOUNT_CREATE_AMOUNT": -257, + "temXCHAIN_BRIDGE_BAD_REWARD_AMOUNT": -256, "tefFAILURE": -199, "tefALREADY": -198, @@ -2298,7 +2460,16 @@ "tecCANT_ACCEPT_OWN_NFTOKEN_OFFER": 158, "tecINSUFFICIENT_FUNDS": 159, "tecOBJECT_NOT_FOUND": 160, - "tecINSUFFICIENT_PAYMENT": 161 + "tecINSUFFICIENT_PAYMENT": 161, + "tecBAD_XCHAIN_TRANSFER_ISSUE": 162, + "tecBAD_XCHAIN_CLAIM_ID": 163, + "tecXCHAIN_CLAIM_NO_QUORUM": 164, + "tecXCHAIN_PROOF_UNKNOWN_KEY": 165, + "tecXCHAIN_CREATE_ACCOUNT_NONXRP_ISSUE": 166, + "tecXCHAIN_CLAIM_ACCOUNT_DST_EXISTS": 167, + "tecXCHAIN_CLAIM_WRONG_CHAIN": 168, + "tecXCHAIN_REWARD_MISMATCH": 169, + "tecXCHAIN_NO_SIGNERS_LIST": 170 }, "TRANSACTION_TYPES": { "Invalid": -1, @@ -2330,6 +2501,13 @@ "NFTokenCreateOffer": 27, "NFTokenCancelOffer": 28, "NFTokenAcceptOffer": 29, + "XChainCreateBridge": 30, + "XChainCreateClaimId": 31, + "XChainCommit": 32, + "XChainClaim": 33, + "SidechainXChainAccountCreate": 34, + "SidechainXChainAccountClaim": 35, + "XChainAddAttestation": 36, "EnableAmendment": 100, "SetFee": 101, "UNLModify": 102 From 1e117cd3d4dfcf9087162c1fefded86b16dc325b Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Mon, 11 Jul 2022 14:51:18 -0400 Subject: [PATCH 002/111] add XChainCreateBridge test --- .../fixtures/data/codec-fixtures.json | 44 +++++++++++++------ 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json b/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json index be2e637a3..670f035df 100644 --- a/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json +++ b/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json @@ -4435,20 +4435,38 @@ } } ], - "transactions": [{ - "binary": "1200002200000000240000003E6140000002540BE40068400000000000000A7321034AADB09CFF4A4804073701EC53C3510CDC95917C2BB0150FB742D0C66E6CEE9E74473045022022EB32AECEF7C644C891C19F87966DF9C62B1F34BABA6BE774325E4BB8E2DD62022100A51437898C28C2B297112DF8131F2BB39EA5FE613487DDD611525F17962646398114550FC62003E785DC231A1058A05E56E3F09CF4E68314D4CC8AB5B21D86A82C3E9E8D0ECF2404B77FECBA", - "json": { - "Account": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", - "Destination": "rLQBHVhFnaC5gLEkgr6HgBJJ3bgeZHg9cj", - "TransactionType": "Payment", - "TxnSignature": "3045022022EB32AECEF7C644C891C19F87966DF9C62B1F34BABA6BE774325E4BB8E2DD62022100A51437898C28C2B297112DF8131F2BB39EA5FE613487DDD611525F1796264639", - "SigningPubKey": "034AADB09CFF4A4804073701EC53C3510CDC95917C2BB0150FB742D0C66E6CEE9E", - "Amount": "10000000000", - "Fee": "10", - "Flags": 0, - "Sequence": 62 + "transactions": [ + { + "binary": "1200002200000000240000003E6140000002540BE40068400000000000000A7321034AADB09CFF4A4804073701EC53C3510CDC95917C2BB0150FB742D0C66E6CEE9E74473045022022EB32AECEF7C644C891C19F87966DF9C62B1F34BABA6BE774325E4BB8E2DD62022100A51437898C28C2B297112DF8131F2BB39EA5FE613487DDD611525F17962646398114550FC62003E785DC231A1058A05E56E3F09CF4E68314D4CC8AB5B21D86A82C3E9E8D0ECF2404B77FECBA", + "json": { + "Account": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", + "Destination": "rLQBHVhFnaC5gLEkgr6HgBJJ3bgeZHg9cj", + "TransactionType": "Payment", + "TxnSignature": "3045022022EB32AECEF7C644C891C19F87966DF9C62B1F34BABA6BE774325E4BB8E2DD62022100A51437898C28C2B297112DF8131F2BB39EA5FE613487DDD611525F1796264639", + "SigningPubKey": "034AADB09CFF4A4804073701EC53C3510CDC95917C2BB0150FB742D0C66E6CEE9E", + "Amount": "10000000000", + "Fee": "10", + "Flags": 0, + "Sequence": 62 + } + }, + { + "binary": "12001E2280000000240000000168400000000000000A601540000000000003E86016400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020744630440220432A94FC7F759730DD66CC7FB0044E563E6C0DF28C3CDF673CB1D2DF03862FA5022020F70FCF14FF24080E34FA5CA0F555C83A520FC4730F5EDA82523FB0E145E2DA8114AF80285F637EE4AF3C20378F9DFB12511ACB8D270118AF80285F637EE4AF3C20378F9DFB12511ACB8D270000000000000000000000000000000000000000550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", + "json": { + "Account": "rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", + "Bridge": "", + "Fee": "10", + "Flags": 2147483648, + "MinAccountCreateAmount": "10000", + "Sequence": 1, + "SignatureReward": "1000", + "SigningPubKey": "0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020", + "TransactionType": "XChainCreateBridge", + "TxnSignature": "30440220432A94FC7F759730DD66CC7FB0044E563E6C0DF28C3CDF673CB1D2DF03862FA5022020F70FCF14FF24080E34FA5CA0F555C83A520FC4730F5EDA82523FB0E145E2DA", + "hash": "488927573EE5700E813738AE815299CD9098DE4F7AAB38EF58E4F861C36EFD24" + } } - }], + ], "ledgerData": [{ "binary": "01E91435016340767BF1C4A3EACEB081770D8ADE216C85445DD6FB002C6B5A2930F2DECE006DA18150CB18F6DD33F6F0990754C962A7CCE62F332FF9C13939B03B864117F0BDA86B6E9B4F873B5C3E520634D343EF5D9D9A4246643D64DAD278BA95DC0EAC6EB5350CF970D521276CDE21276CE60A00", "json": { From 19589d1e639488b74589bba16cdb5d2b2efc4b0a Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Mon, 11 Jul 2022 15:01:04 -0400 Subject: [PATCH 003/111] get XChainCreateBridge test working --- .../fixtures/data/codec-fixtures.json | 10 ++- tests/unit/core/binarycodec/test_main.py | 2 +- xrpl/core/binarycodec/types/__init__.py | 4 + xrpl/core/binarycodec/types/bridge.py | 90 +++++++++++++++++++ .../core/binarycodec/types/issued_currency.py | 90 +++++++++++++++++++ xrpl/models/__init__.py | 2 + xrpl/models/bridge.py | 23 +++++ 7 files changed, 217 insertions(+), 4 deletions(-) create mode 100644 xrpl/core/binarycodec/types/bridge.py create mode 100644 xrpl/core/binarycodec/types/issued_currency.py create mode 100644 xrpl/models/bridge.py diff --git a/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json b/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json index 670f035df..d7a86a2a9 100644 --- a/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json +++ b/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json @@ -4454,7 +4454,12 @@ "binary": "12001E2280000000240000000168400000000000000A601540000000000003E86016400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020744630440220432A94FC7F759730DD66CC7FB0044E563E6C0DF28C3CDF673CB1D2DF03862FA5022020F70FCF14FF24080E34FA5CA0F555C83A520FC4730F5EDA82523FB0E145E2DA8114AF80285F637EE4AF3C20378F9DFB12511ACB8D270118AF80285F637EE4AF3C20378F9DFB12511ACB8D270000000000000000000000000000000000000000550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", "json": { "Account": "rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", - "Bridge": "", + "Bridge": { + "src_chain_door": "rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", + "src_chain_issue": "XRP", + "dst_chain_door": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", + "dst_chain_issue": "XRP" + }, "Fee": "10", "Flags": 2147483648, "MinAccountCreateAmount": "10000", @@ -4462,8 +4467,7 @@ "SignatureReward": "1000", "SigningPubKey": "0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020", "TransactionType": "XChainCreateBridge", - "TxnSignature": "30440220432A94FC7F759730DD66CC7FB0044E563E6C0DF28C3CDF673CB1D2DF03862FA5022020F70FCF14FF24080E34FA5CA0F555C83A520FC4730F5EDA82523FB0E145E2DA", - "hash": "488927573EE5700E813738AE815299CD9098DE4F7AAB38EF58E4F861C36EFD24" + "TxnSignature": "30440220432A94FC7F759730DD66CC7FB0044E563E6C0DF28C3CDF673CB1D2DF03862FA5022020F70FCF14FF24080E34FA5CA0F555C83A520FC4730F5EDA82523FB0E145E2DA" } } ], diff --git a/tests/unit/core/binarycodec/test_main.py b/tests/unit/core/binarycodec/test_main.py index 0e345d6b3..ac32822e2 100644 --- a/tests/unit/core/binarycodec/test_main.py +++ b/tests/unit/core/binarycodec/test_main.py @@ -331,7 +331,7 @@ def test_xaddress_xaddr_and_matching_source_tag(self): class TestMainFixtures(TestCase): - maxDiff = 1000 + maxDiff = None def _check_binary_and_json(self, test): test_binary = test["binary"] diff --git a/xrpl/core/binarycodec/types/__init__.py b/xrpl/core/binarycodec/types/__init__.py index 9511fc29b..1d2b2fbb5 100644 --- a/xrpl/core/binarycodec/types/__init__.py +++ b/xrpl/core/binarycodec/types/__init__.py @@ -2,11 +2,13 @@ from xrpl.core.binarycodec.types.account_id import AccountID from xrpl.core.binarycodec.types.amount import Amount from xrpl.core.binarycodec.types.blob import Blob +from xrpl.core.binarycodec.types.bridge import Bridge from xrpl.core.binarycodec.types.currency import Currency from xrpl.core.binarycodec.types.hash import Hash from xrpl.core.binarycodec.types.hash128 import Hash128 from xrpl.core.binarycodec.types.hash160 import Hash160 from xrpl.core.binarycodec.types.hash256 import Hash256 +from xrpl.core.binarycodec.types.issued_currency import IssuedCurrency from xrpl.core.binarycodec.types.path_set import PathSet from xrpl.core.binarycodec.types.st_array import STArray from xrpl.core.binarycodec.types.st_object import STObject @@ -21,11 +23,13 @@ "AccountID", "Amount", "Blob", + "Bridge", "Currency", "Hash", "Hash128", "Hash160", "Hash256", + "IssuedCurrency", "PathSet", "STObject", "STArray", diff --git a/xrpl/core/binarycodec/types/bridge.py b/xrpl/core/binarycodec/types/bridge.py new file mode 100644 index 000000000..f309811bc --- /dev/null +++ b/xrpl/core/binarycodec/types/bridge.py @@ -0,0 +1,90 @@ +"""Codec for serializing and deserializing bridge fields.""" +from __future__ import annotations + +from typing import Any, Dict, List, Optional, Tuple, Type, Union, cast + +from xrpl.core.binarycodec.binary_wrappers.binary_parser import BinaryParser +from xrpl.core.binarycodec.exceptions import XRPLBinaryCodecException +from xrpl.core.binarycodec.types.account_id import AccountID +from xrpl.core.binarycodec.types.issued_currency import IssuedCurrency +from xrpl.core.binarycodec.types.serialized_type import SerializedType +from xrpl.models.bridge import Bridge as BridgeModel + +_TYPE_ORDER: List[Tuple[str, Type[SerializedType]]] = [ + ("src_chain_door", AccountID), + ("src_chain_issue", IssuedCurrency), + ("dst_chain_door", AccountID), + ("dst_chain_issue", IssuedCurrency), +] + + +class Bridge(SerializedType): + """Codec for serializing and deserializing bridge fields.""" + + def __init__(self: Bridge, buffer: bytes) -> None: + """Construct a Bridge from given bytes.""" + super().__init__(buffer) + + @classmethod + def from_value(cls: Type[Bridge], value: Union[str, Dict[str, str]]) -> Bridge: + """ + Construct a Bridge object from a dictionary representation of a bridge. + + Args: + value: The dictionary to construct a Bridge object from. + + Returns: + A Bridge object constructed from value. + + Raises: + XRPLBinaryCodecException: If the Bridge representation is invalid. + """ + if BridgeModel.is_dict_of_model(value): + value = cast(Dict[str, Any], value) + buffer = b"" + for (name, object_type) in _TYPE_ORDER: + obj = object_type.from_value(value[name]) + buffer += bytes(obj) + return cls(buffer) + + raise XRPLBinaryCodecException( + "Invalid type to construct an Bridge: expected dict," + f" received {value.__class__.__name__}." + ) + + @classmethod + def from_parser( + cls: Type[Bridge], parser: BinaryParser, length_hint: Optional[int] = None + ) -> Bridge: + """ + Construct a Bridge object from an existing BinaryParser. + + Args: + parser: The parser to construct the Bridge object from. + length_hint: The number of bytes to consume from the parser. + + Returns: + The Bridge object constructed from a parser. + """ + buffer = b"" + + for (_, object_type) in _TYPE_ORDER: + obj = object_type.from_parser(parser, length_hint) + buffer += bytes(obj) + + return cls(buffer) + + def to_json(self: Bridge) -> Union[str, Dict[Any, Any]]: + """ + Returns the JSON representation of a bridge. + + Returns: + The JSON representation of a Bridge. + """ + parser = BinaryParser(str(self)) + return_json = {} + for (name, object_type) in _TYPE_ORDER: + obj = object_type.from_parser(parser, None) + return_json[name] = obj.to_json() + + return return_json diff --git a/xrpl/core/binarycodec/types/issued_currency.py b/xrpl/core/binarycodec/types/issued_currency.py new file mode 100644 index 000000000..ab284ec57 --- /dev/null +++ b/xrpl/core/binarycodec/types/issued_currency.py @@ -0,0 +1,90 @@ +"""Codec for serializing and deserializing issued currency fields.""" + +from __future__ import annotations + +from typing import Any, Dict, Optional, Type, Union + +from xrpl.core.binarycodec.binary_wrappers.binary_parser import BinaryParser +from xrpl.core.binarycodec.exceptions import XRPLBinaryCodecException +from xrpl.core.binarycodec.types.account_id import AccountID +from xrpl.core.binarycodec.types.currency import Currency +from xrpl.core.binarycodec.types.serialized_type import SerializedType +from xrpl.models.currencies import IssuedCurrency as IssuedCurrencyModel + + +class IssuedCurrency(SerializedType): + """Codec for serializing and deserializing issued currency fields.""" + + def __init__(self: IssuedCurrency, buffer: bytes) -> None: + """Construct an IssuedCurrency from given bytes.""" + super().__init__(buffer) + + @classmethod + def from_value( + cls: Type[IssuedCurrency], value: Union[str, Dict[str, str]] + ) -> IssuedCurrency: + """ + Construct an IssuedCurrency object from a string or dictionary representation + of an issued currency. + + Args: + value: The dictionary to construct an IssuedCurrency object from. + + Returns: + An IssuedCurrency object constructed from value. + + Raises: + XRPLBinaryCodecException: If the IssuedCurrency representation is invalid. + """ + if isinstance(value, str): + if value != "XRP": + raise XRPLBinaryCodecException(f"{value} is an illegal currency") + return cls(bytes(Currency.from_value(value))) + + if IssuedCurrencyModel.is_dict_of_model(value): + currency_bytes = bytes(Currency.from_value(value["currency"])) + issuer_bytes = bytes(AccountID.from_value(value["issuer"])) + return cls(currency_bytes + issuer_bytes) + + raise XRPLBinaryCodecException( + "Invalid type to construct an IssuedCurrency: expected str or dict," + f" received {value.__class__.__name__}." + ) + + @classmethod + def from_parser( + cls: Type[IssuedCurrency], + parser: BinaryParser, + length_hint: Optional[int] = None, + ) -> IssuedCurrency: + """ + Construct an IssuedCurrency object from an existing BinaryParser. + + Args: + parser: The parser to construct the IssuedCurrency object from. + length_hint: The number of bytes to consume from the parser. + + Returns: + The IssuedCurrency object constructed from a parser. + """ + currency = Currency.from_parser(parser) + if currency.to_json() == "XRP": + return cls(bytes(currency)) + + issuer = parser.read(20) + return cls(bytes(currency) + issuer) + + def to_json(self: IssuedCurrency) -> Union[str, Dict[Any, Any]]: + """ + Returns the JSON representation of an issued currency. + + Returns: + The JSON representation of an IssuedCurrency. + """ + parser = BinaryParser(str(self)) + currency: Union[str, Dict[Any, Any]] = Currency.from_parser(parser).to_json() + if currency == "XRP": + return currency + + issuer = AccountID.from_parser(parser) + return {"currency": currency, "issuer": issuer.to_json()} diff --git a/xrpl/models/__init__.py b/xrpl/models/__init__.py index 059e5f355..a80d6e4ee 100644 --- a/xrpl/models/__init__.py +++ b/xrpl/models/__init__.py @@ -1,6 +1,7 @@ """Top-level exports for the models package.""" from xrpl.models import amounts, currencies, requests, transactions from xrpl.models.amounts import * # noqa: F401, F403 +from xrpl.models.bridge import Bridge from xrpl.models.currencies import * # noqa: F401, F403 from xrpl.models.exceptions import XRPLModelException from xrpl.models.path import Path, PathStep @@ -20,6 +21,7 @@ "transactions", *transactions.__all__, *transactions.pseudo_transactions.__all__, + "Bridge", "Path", "PathStep", "Response", diff --git a/xrpl/models/bridge.py b/xrpl/models/bridge.py new file mode 100644 index 000000000..8a5be9630 --- /dev/null +++ b/xrpl/models/bridge.py @@ -0,0 +1,23 @@ +"""A Bridge represents a cross-chain bridge.""" + +from __future__ import annotations + +from dataclasses import dataclass +from typing import Union + +from typing_extensions import Literal + +from xrpl.models.base_model import BaseModel +from xrpl.models.currencies import IssuedCurrency +from xrpl.models.utils import require_kwargs_on_init + + +@require_kwargs_on_init +@dataclass(frozen=True) +class Bridge(BaseModel): + """A Bridge represents a cross-chain bridge.""" + + src_chain_door: str + src_chain_issue: Union[Literal["XRP"], IssuedCurrency] + dst_chain_door: str + dst_chain_issue: Union[Literal["XRP"], IssuedCurrency] From cac0d76e76c537d4e375cdd331b917793b31abe7 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Mon, 11 Jul 2022 15:50:06 -0400 Subject: [PATCH 004/111] add XChainCreateClaimID tx --- .../fixtures/data/codec-fixtures.json | 20 +++++++++++++++++++ .../binarycodec/definitions/definitions.json | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json b/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json index d7a86a2a9..ea4380005 100644 --- a/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json +++ b/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json @@ -4469,6 +4469,26 @@ "TransactionType": "XChainCreateBridge", "TxnSignature": "30440220432A94FC7F759730DD66CC7FB0044E563E6C0DF28C3CDF673CB1D2DF03862FA5022020F70FCF14FF24080E34FA5CA0F555C83A520FC4730F5EDA82523FB0E145E2DA" } + }, + { + "binary": "12001F2280000000240000000168400000000000000A6015400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02074463044022065BB8ABE6E34ADB25C1350F7AF34B1DF01CE87A5ACE1610454EE6B2ED70A0D3302201A4CC9664A191E70F98E921E569E7D3D2EF7FC28353085BC8CBA5296425C287E8114550FC62003E785DC231A1058A05E56E3F09CF4E6801214AF80285F637EE4AF3C20378F9DFB12511ACB8D270118AF80285F637EE4AF3C20378F9DFB12511ACB8D270000000000000000000000000000000000000000550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", + "json": { + "Account": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", + "Bridge": { + "src_chain_door": "rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", + "src_chain_issue": "XRP", + "dst_chain_door": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", + "dst_chain_issue": "XRP" + }, + "Fee": "10", + "Flags": 2147483648, + "OtherChainAccount": "rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", + "Sequence": 1, + "SignatureReward": "10000", + "SigningPubKey": "0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020", + "TransactionType": "XChainCreateClaimID", + "TxnSignature": "3044022065BB8ABE6E34ADB25C1350F7AF34B1DF01CE87A5ACE1610454EE6B2ED70A0D3302201A4CC9664A191E70F98E921E569E7D3D2EF7FC28353085BC8CBA5296425C287E" + } } ], "ledgerData": [{ diff --git a/xrpl/core/binarycodec/definitions/definitions.json b/xrpl/core/binarycodec/definitions/definitions.json index 5a603b307..4e69632f7 100644 --- a/xrpl/core/binarycodec/definitions/definitions.json +++ b/xrpl/core/binarycodec/definitions/definitions.json @@ -2502,7 +2502,7 @@ "NFTokenCancelOffer": 28, "NFTokenAcceptOffer": 29, "XChainCreateBridge": 30, - "XChainCreateClaimId": 31, + "XChainCreateClaimID": 31, "XChainCommit": 32, "XChainClaim": 33, "SidechainXChainAccountCreate": 34, From 7a9741717a21442c3f3e6a19890ad0e065d5446e Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Mon, 11 Jul 2022 16:02:54 -0400 Subject: [PATCH 005/111] get XChainCommit working --- .../fixtures/data/codec-fixtures.json | 20 +++++++++++++++++++ .../binarycodec/definitions/definitions.json | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json b/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json index ea4380005..1cc3f135c 100644 --- a/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json +++ b/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json @@ -4489,6 +4489,26 @@ "TransactionType": "XChainCreateClaimID", "TxnSignature": "3044022065BB8ABE6E34ADB25C1350F7AF34B1DF01CE87A5ACE1610454EE6B2ED70A0D3302201A4CC9664A191E70F98E921E569E7D3D2EF7FC28353085BC8CBA5296425C287E" } + }, + { + "binary": "120020228000000024000000013014000000000000000161400000000000271068400000000000000A73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD0207446304402204C1E4F103CB24B10925F34DF2A90AD3008078A0A725A1F96A59652E34EF5071B02200F567E95FF140F12A35CDBD2324F8BE769BF57DE5D2F92367A4C8AAB7C5F34548114550FC62003E785DC231A1058A05E56E3F09CF4E60118AF80285F637EE4AF3C20378F9DFB12511ACB8D270000000000000000000000000000000000000000550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", + "json": { + "Account": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", + "Amount": "10000", + "Bridge": { + "src_chain_door": "rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", + "src_chain_issue": "XRP", + "dst_chain_door": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", + "dst_chain_issue": "XRP" + }, + "Fee": "10", + "Flags": 2147483648, + "Sequence": 1, + "SigningPubKey": "0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020", + "TransactionType": "XChainCommit", + "TxnSignature": "304402204C1E4F103CB24B10925F34DF2A90AD3008078A0A725A1F96A59652E34EF5071B02200F567E95FF140F12A35CDBD2324F8BE769BF57DE5D2F92367A4C8AAB7C5F3454", + "XChainClaimID": "0000000000000001" + } } ], "ledgerData": [{ diff --git a/xrpl/core/binarycodec/definitions/definitions.json b/xrpl/core/binarycodec/definitions/definitions.json index 4e69632f7..be000f9d2 100644 --- a/xrpl/core/binarycodec/definitions/definitions.json +++ b/xrpl/core/binarycodec/definitions/definitions.json @@ -41,7 +41,7 @@ "Bridge": 105, "LedgerHashes": 104, "Amendments": 102, - "XChainClaimId": 113, + "XChainClaimID": 113, "FeeSettings": 115, "Escrow": 117, "PayChannel": 120, From 9a832d0a31e2e1b4d502b4e187abfe5368765fac Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Mon, 11 Jul 2022 16:06:11 -0400 Subject: [PATCH 006/111] add XChainClaim tx --- .../fixtures/data/codec-fixtures.json | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json b/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json index 1cc3f135c..d12e8eaef 100644 --- a/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json +++ b/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json @@ -4509,6 +4509,27 @@ "TxnSignature": "304402204C1E4F103CB24B10925F34DF2A90AD3008078A0A725A1F96A59652E34EF5071B02200F567E95FF140F12A35CDBD2324F8BE769BF57DE5D2F92367A4C8AAB7C5F3454", "XChainClaimID": "0000000000000001" } + }, + { + "binary": "120021228000000024000000013014000000000000000161400000000000271068400000000000000A73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02074473045022100D4AFE8A4ACED40969B3E06EEC1D3C94FB9B6702537CC56FB180BA2F74E9CCB5C02203B30C46AB83B665BD3B4FF6AB3CBF33C138640CB7CA76888BB7280B114FC94458114550FC62003E785DC231A1058A05E56E3F09CF4E68314550FC62003E785DC231A1058A05E56E3F09CF4E60118AF80285F637EE4AF3C20378F9DFB12511ACB8D270000000000000000000000000000000000000000550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", + "json": { + "Account": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", + "Amount": "10000", + "Bridge": { + "src_chain_door": "rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", + "src_chain_issue": "XRP", + "dst_chain_door": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", + "dst_chain_issue": "XRP" + }, + "Destination": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", + "Fee": "10", + "Flags": 2147483648, + "Sequence": 1, + "SigningPubKey": "0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020", + "TransactionType": "XChainClaim", + "TxnSignature": "3045022100D4AFE8A4ACED40969B3E06EEC1D3C94FB9B6702537CC56FB180BA2F74E9CCB5C02203B30C46AB83B665BD3B4FF6AB3CBF33C138640CB7CA76888BB7280B114FC9445", + "XChainClaimID": "0000000000000001" + } } ], "ledgerData": [{ From 5abc9f8d2cacf49bb54b2e41fc9bcdf16ce48425 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Mon, 11 Jul 2022 18:00:00 -0400 Subject: [PATCH 007/111] add models --- xrpl/models/base_model.py | 8 +++-- xrpl/models/transactions/__init__.py | 8 +++++ xrpl/models/transactions/transaction.py | 10 ++++++- .../transactions/types/transaction_type.py | 7 +++++ xrpl/models/transactions/xchain_claim.py | 30 +++++++++++++++++++ xrpl/models/transactions/xchain_commit.py | 28 +++++++++++++++++ .../transactions/xchain_create_bridge.py | 28 +++++++++++++++++ .../transactions/xchain_create_claim_id.py | 27 +++++++++++++++++ 8 files changed, 143 insertions(+), 3 deletions(-) create mode 100644 xrpl/models/transactions/xchain_claim.py create mode 100644 xrpl/models/transactions/xchain_commit.py create mode 100644 xrpl/models/transactions/xchain_create_bridge.py create mode 100644 xrpl/models/transactions/xchain_create_claim_id.py diff --git a/xrpl/models/base_model.py b/xrpl/models/base_model.py index 829113f6f..f5e578783 100644 --- a/xrpl/models/base_model.py +++ b/xrpl/models/base_model.py @@ -9,7 +9,7 @@ from enum import Enum from typing import Any, Dict, List, Pattern, Type, TypeVar, Union, cast, get_type_hints -from typing_extensions import Final, get_args, get_origin +from typing_extensions import Final, Literal, get_args, get_origin from xrpl.models.exceptions import XRPLModelException from xrpl.models.required import REQUIRED @@ -33,7 +33,7 @@ f"(?:{_CAMEL_CASE_LEADING_LOWER}|{_CAMEL_CASE_ABBREVIATION}|{_CAMEL_CASE_TYPICAL})" ) # used for converting special substrings inside CamelCase fields -SPECIAL_CAMELCASE_STRINGS = ["NFToken"] +SPECIAL_CAMELCASE_STRINGS = ["NFToken", "XChain"] BM = TypeVar("BM", bound="BaseModel") # any type inherited from BaseModel @@ -167,6 +167,10 @@ def _from_dict_single_param( # expected an object, received the correct object return param_value + if get_origin(param_type) == Literal: + if param_value in get_args(param_type): + return param_value + if ( isinstance(param_type, type) and issubclass(param_type, Enum) diff --git a/xrpl/models/transactions/__init__.py b/xrpl/models/transactions/__init__.py index cd040e508..567ba72b1 100644 --- a/xrpl/models/transactions/__init__.py +++ b/xrpl/models/transactions/__init__.py @@ -53,6 +53,10 @@ TrustSetFlag, TrustSetFlagInterface, ) +from xrpl.models.transactions.xchain_claim import XChainClaim +from xrpl.models.transactions.xchain_commit import XChainCommit +from xrpl.models.transactions.xchain_create_bridge import XChainCreateBridge +from xrpl.models.transactions.xchain_create_claim_id import XChainCreateClaimID __all__ = [ "AccountDelete", @@ -98,4 +102,8 @@ "TrustSet", "TrustSetFlag", "TrustSetFlagInterface", + "XChainClaim", + "XChainCommit", + "XChainCreateBridge", + "XChainCreateClaimID", ] diff --git a/xrpl/models/transactions/transaction.py b/xrpl/models/transactions/transaction.py index 29fb557b6..1336a7e85 100644 --- a/xrpl/models/transactions/transaction.py +++ b/xrpl/models/transactions/transaction.py @@ -10,6 +10,7 @@ from xrpl.core.binarycodec import encode from xrpl.models.amounts import IssuedCurrencyAmount from xrpl.models.base_model import BaseModel +from xrpl.models.bridge import Bridge from xrpl.models.exceptions import XRPLModelException from xrpl.models.flags import check_false_flag_definition, interface_to_flag_list from xrpl.models.nested_model import NestedModel @@ -27,8 +28,15 @@ "id": "ID", "uri": "URI", "nftoken": "NFToken", + "xchain": "XChain", } +_LOWER_CASE_MODELS: List[Type[BaseModel]] = [ + IssuedCurrencyAmount, + PathStep, + Bridge, +] + def transaction_json_to_binary_codec_form( dictionary: Dict[str, XRPL_VALUE_TYPE] @@ -69,7 +77,7 @@ def _key_to_tx_json(key: str) -> str: def _value_to_tx_json(value: XRPL_VALUE_TYPE) -> XRPL_VALUE_TYPE: # IssuedCurrencyAmount and PathStep are special cases and should not be snake cased # and only contain primitive members - if IssuedCurrencyAmount.is_dict_of_model(value) or PathStep.is_dict_of_model(value): + if any([model.is_dict_of_model(value) for model in _LOWER_CASE_MODELS]): return value if isinstance(value, dict): return transaction_json_to_binary_codec_form(value) diff --git a/xrpl/models/transactions/types/transaction_type.py b/xrpl/models/transactions/types/transaction_type.py index 3b8a0c809..cc8dbee31 100644 --- a/xrpl/models/transactions/types/transaction_type.py +++ b/xrpl/models/transactions/types/transaction_type.py @@ -30,3 +30,10 @@ class TransactionType(str, Enum): SIGNER_LIST_SET = "SignerListSet" TICKET_CREATE = "TicketCreate" TRUST_SET = "TrustSet" + XCHAIN_ADD_ATTESTATION = "XChainAddAttestation" + XCHAIN_CLAIM = "XChainClaim" + XCHAIN_COMMIT = "XChainCommit" + XCHAIN_CREATE_ACCOUNT_COMMIT = "XChainCreateAccountCommit" + XCHAIN_CREATE_BRIDGE = "XChainCreateBridge" + XCHAIN_CREATE_CLAIM_ID = "XChainCreateClaimID" + XCHAIN_MODIFY_BRIDGE = "XChainModifyBridge" diff --git a/xrpl/models/transactions/xchain_claim.py b/xrpl/models/transactions/xchain_claim.py new file mode 100644 index 000000000..54d820712 --- /dev/null +++ b/xrpl/models/transactions/xchain_claim.py @@ -0,0 +1,30 @@ +"""Model for a XChainClaim transaction type.""" + +from dataclasses import dataclass, field +from typing import Union + +from xrpl.models.amounts import Amount +from xrpl.models.bridge import Bridge +from xrpl.models.required import REQUIRED +from xrpl.models.transactions.transaction import Transaction +from xrpl.models.transactions.types import TransactionType +from xrpl.models.utils import require_kwargs_on_init + + +@require_kwargs_on_init +@dataclass(frozen=True) +class XChainClaim(Transaction): + """Represents a XChainClaim transaction.""" + + bridge: Bridge = REQUIRED # type: ignore + + xchain_claim_id: Union[int, str] = REQUIRED # type: ignore + + destination: str = REQUIRED # type: ignore + + amount: Amount = REQUIRED # type: ignore + + transaction_type: TransactionType = field( + default=TransactionType.XCHAIN_CREATE_CLAIM_ID, + init=False, + ) diff --git a/xrpl/models/transactions/xchain_commit.py b/xrpl/models/transactions/xchain_commit.py new file mode 100644 index 000000000..2f629f412 --- /dev/null +++ b/xrpl/models/transactions/xchain_commit.py @@ -0,0 +1,28 @@ +"""Model for a XChainCommit transaction type.""" + +from dataclasses import dataclass, field +from typing import Union + +from xrpl.models.amounts import Amount +from xrpl.models.bridge import Bridge +from xrpl.models.required import REQUIRED +from xrpl.models.transactions.transaction import Transaction +from xrpl.models.transactions.types import TransactionType +from xrpl.models.utils import require_kwargs_on_init + + +@require_kwargs_on_init +@dataclass(frozen=True) +class XChainCommit(Transaction): + """Represents a XChainCommit transaction.""" + + bridge: Bridge = REQUIRED # type: ignore + + xchain_claim_id: Union[int, str] = REQUIRED # type: ignore + + amount: Amount = REQUIRED # type: ignore + + transaction_type: TransactionType = field( + default=TransactionType.XCHAIN_CREATE_CLAIM_ID, + init=False, + ) diff --git a/xrpl/models/transactions/xchain_create_bridge.py b/xrpl/models/transactions/xchain_create_bridge.py new file mode 100644 index 000000000..1ffa80c65 --- /dev/null +++ b/xrpl/models/transactions/xchain_create_bridge.py @@ -0,0 +1,28 @@ +"""Model for a XChainCreateBridge transaction type.""" + +from dataclasses import dataclass, field +from typing import Optional + +from xrpl.models.amounts import Amount +from xrpl.models.bridge import Bridge +from xrpl.models.required import REQUIRED +from xrpl.models.transactions.transaction import Transaction +from xrpl.models.transactions.types import TransactionType +from xrpl.models.utils import require_kwargs_on_init + + +@require_kwargs_on_init +@dataclass(frozen=True) +class XChainCreateBridge(Transaction): + """Represents a XChainCreateBridge transaction.""" + + bridge: Bridge = REQUIRED # type: ignore + + signature_reward: Amount = REQUIRED # type: ignore + + min_account_create_amount: Optional[Amount] = None + + transaction_type: TransactionType = field( + default=TransactionType.XCHAIN_CREATE_BRIDGE, + init=False, + ) diff --git a/xrpl/models/transactions/xchain_create_claim_id.py b/xrpl/models/transactions/xchain_create_claim_id.py new file mode 100644 index 000000000..122ee440b --- /dev/null +++ b/xrpl/models/transactions/xchain_create_claim_id.py @@ -0,0 +1,27 @@ +"""Model for a XChainCreateClaimID transaction type.""" + +from dataclasses import dataclass, field + +from xrpl.models.amounts import Amount +from xrpl.models.bridge import Bridge +from xrpl.models.required import REQUIRED +from xrpl.models.transactions.transaction import Transaction +from xrpl.models.transactions.types import TransactionType +from xrpl.models.utils import require_kwargs_on_init + + +@require_kwargs_on_init +@dataclass(frozen=True) +class XChainCreateClaimID(Transaction): + """Represents a XChainCreateClaimID transaction.""" + + bridge: Bridge = REQUIRED # type: ignore + + signature_reward: Amount = REQUIRED # type: ignore + + other_chain_account: str = REQUIRED # type: ignore + + transaction_type: TransactionType = field( + default=TransactionType.XCHAIN_CREATE_CLAIM_ID, + init=False, + ) From 34bea91dee3d6849317fbd14e31163fc7df9f1ec Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Mon, 11 Jul 2022 18:03:18 -0400 Subject: [PATCH 008/111] comment out unwritten txs --- xrpl/models/transactions/types/transaction_type.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xrpl/models/transactions/types/transaction_type.py b/xrpl/models/transactions/types/transaction_type.py index cc8dbee31..ef71d46ad 100644 --- a/xrpl/models/transactions/types/transaction_type.py +++ b/xrpl/models/transactions/types/transaction_type.py @@ -30,10 +30,10 @@ class TransactionType(str, Enum): SIGNER_LIST_SET = "SignerListSet" TICKET_CREATE = "TicketCreate" TRUST_SET = "TrustSet" - XCHAIN_ADD_ATTESTATION = "XChainAddAttestation" + # XCHAIN_ADD_ATTESTATION = "XChainAddAttestation" XCHAIN_CLAIM = "XChainClaim" XCHAIN_COMMIT = "XChainCommit" - XCHAIN_CREATE_ACCOUNT_COMMIT = "XChainCreateAccountCommit" + # XCHAIN_CREATE_ACCOUNT_COMMIT = "XChainCreateAccountCommit" XCHAIN_CREATE_BRIDGE = "XChainCreateBridge" XCHAIN_CREATE_CLAIM_ID = "XChainCreateClaimID" - XCHAIN_MODIFY_BRIDGE = "XChainModifyBridge" + # XCHAIN_MODIFY_BRIDGE = "XChainModifyBridge" From 00b2461195840e8d0ca489330f9606e35333a997 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Mon, 11 Jul 2022 18:38:18 -0400 Subject: [PATCH 009/111] add test for xchain conversion, fix bugs --- tests/unit/models/test_base_model.py | 33 +++++++++++++++++++++++ xrpl/models/transactions/xchain_claim.py | 2 +- xrpl/models/transactions/xchain_commit.py | 2 +- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/tests/unit/models/test_base_model.py b/tests/unit/models/test_base_model.py index ae5c9bff1..bb6cf904d 100644 --- a/tests/unit/models/test_base_model.py +++ b/tests/unit/models/test_base_model.py @@ -4,6 +4,7 @@ from xrpl.models import XRPLModelException from xrpl.models.amounts import IssuedCurrencyAmount +from xrpl.models.bridge import Bridge from xrpl.models.requests import ( AccountChannels, BookOffers, @@ -24,6 +25,7 @@ SignerListSet, TrustSet, TrustSetFlag, + XChainClaim, ) from xrpl.models.transactions.transaction import Transaction @@ -597,3 +599,34 @@ def test_to_xrpl_signer(self): ], } self.assertEqual(tx.to_xrpl(), expected) + + def test_to_from_xrpl_xchain(self): + tx_json = { + "Account": account, + "Amount": value, + "Bridge": { + "src_chain_door": "rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", + "src_chain_issue": "XRP", + "dst_chain_door": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", + "dst_chain_issue": "XRP", + }, + "Destination": destination, + "TransactionType": "XChainClaim", + "Flags": 0, + "SigningPubKey": "", + "XChainClaimID": "0000000000000001", + } + tx_obj = XChainClaim( + account=account, + amount=value, + bridge=Bridge( + src_chain_door="rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", + src_chain_issue="XRP", + dst_chain_door="r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", + dst_chain_issue="XRP", + ), + destination=destination, + xchain_claim_id="0000000000000001", + ) + self.assertEqual(tx_obj.to_xrpl(), tx_json) + self.assertEqual(Transaction.from_xrpl(tx_json), tx_obj) diff --git a/xrpl/models/transactions/xchain_claim.py b/xrpl/models/transactions/xchain_claim.py index 54d820712..2e2b9b630 100644 --- a/xrpl/models/transactions/xchain_claim.py +++ b/xrpl/models/transactions/xchain_claim.py @@ -25,6 +25,6 @@ class XChainClaim(Transaction): amount: Amount = REQUIRED # type: ignore transaction_type: TransactionType = field( - default=TransactionType.XCHAIN_CREATE_CLAIM_ID, + default=TransactionType.XCHAIN_CLAIM, init=False, ) diff --git a/xrpl/models/transactions/xchain_commit.py b/xrpl/models/transactions/xchain_commit.py index 2f629f412..aa828bec0 100644 --- a/xrpl/models/transactions/xchain_commit.py +++ b/xrpl/models/transactions/xchain_commit.py @@ -23,6 +23,6 @@ class XChainCommit(Transaction): amount: Amount = REQUIRED # type: ignore transaction_type: TransactionType = field( - default=TransactionType.XCHAIN_CREATE_CLAIM_ID, + default=TransactionType.XCHAIN_COMMIT, init=False, ) From 3203549e3ae923fe3cc3dae85aae40c5162f4f05 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Tue, 12 Jul 2022 13:33:34 -0400 Subject: [PATCH 010/111] Update definitions.json --- .../binarycodec/definitions/definitions.json | 41 +++++++++++++++---- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/xrpl/core/binarycodec/definitions/definitions.json b/xrpl/core/binarycodec/definitions/definitions.json index be000f9d2..d4a3e16dd 100644 --- a/xrpl/core/binarycodec/definitions/definitions.json +++ b/xrpl/core/binarycodec/definitions/definitions.json @@ -1858,7 +1858,7 @@ } ], [ - "AttestationRewardAccount", + "AttestationSignerAccount", { "nth": 19, "isVLEncoded": true, @@ -1867,6 +1867,16 @@ "type": "AccountID" } ], + [ + "AttestationRewardAccount", + { + "nth": 20, + "isVLEncoded": true, + "isSerialized": true, + "isSigningField": true, + "type": "AccountID" + } + ], [ "Indexes", { @@ -1947,6 +1957,16 @@ "type": "XChainAttestations" } ], + [ + "XChainAttestationBatch", + { + "nth": 1, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "XChainAttestationBatch" + } + ], [ "TransactionMetaData", { @@ -2377,6 +2397,7 @@ "temSIDECHAIN_NONDOOR_OWNER": -258, "temXCHAIN_BRIDGE_BAD_MIN_ACCOUNT_CREATE_AMOUNT": -257, "temXCHAIN_BRIDGE_BAD_REWARD_AMOUNT": -256, + "temXCHAIN_TOO_MANY_ATTESTATIONS": -255, "tefFAILURE": -199, "tefALREADY": -198, @@ -2462,14 +2483,16 @@ "tecOBJECT_NOT_FOUND": 160, "tecINSUFFICIENT_PAYMENT": 161, "tecBAD_XCHAIN_TRANSFER_ISSUE": 162, - "tecBAD_XCHAIN_CLAIM_ID": 163, - "tecXCHAIN_CLAIM_NO_QUORUM": 164, - "tecXCHAIN_PROOF_UNKNOWN_KEY": 165, - "tecXCHAIN_CREATE_ACCOUNT_NONXRP_ISSUE": 166, - "tecXCHAIN_CLAIM_ACCOUNT_DST_EXISTS": 167, - "tecXCHAIN_CLAIM_WRONG_CHAIN": 168, - "tecXCHAIN_REWARD_MISMATCH": 169, - "tecXCHAIN_NO_SIGNERS_LIST": 170 + "tecXCHAIN_NO_CLAIM_ID": 163, + "tecXCHAIN_BAD_CLAIM_ID": 164, + "tecXCHAIN_CLAIM_NO_QUORUM": 165, + "tecXCHAIN_PROOF_UNKNOWN_KEY": 166, + "tecXCHAIN_CREATE_ACCOUNT_NONXRP_ISSUE": 167, + "tecXCHAIN_CLAIM_ACCOUNT_DST_EXISTS": 168, + "tecXCHAIN_CLAIM_WRONG_CHAIN": 169, + "tecXCHAIN_REWARD_MISMATCH": 170, + "tecXCHAIN_NO_SIGNERS_LIST": 171, + "tecXCHAIN_SENDING_ACCOUNT_MISMATCH": 172 }, "TRANSACTION_TYPES": { "Invalid": -1, From 057e8074eed837abb33cd8dbcca77962163d3790 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Mon, 18 Jul 2022 10:43:22 +0100 Subject: [PATCH 011/111] fix typo --- xrpl/core/binarycodec/types/bridge.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xrpl/core/binarycodec/types/bridge.py b/xrpl/core/binarycodec/types/bridge.py index f309811bc..e95b60231 100644 --- a/xrpl/core/binarycodec/types/bridge.py +++ b/xrpl/core/binarycodec/types/bridge.py @@ -48,7 +48,7 @@ def from_value(cls: Type[Bridge], value: Union[str, Dict[str, str]]) -> Bridge: return cls(buffer) raise XRPLBinaryCodecException( - "Invalid type to construct an Bridge: expected dict," + "Invalid type to construct a Bridge: expected dict," f" received {value.__class__.__name__}." ) From 6629b4b1cf8ebc4d945fd13a2c3f4f3b34126734 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Mon, 18 Jul 2022 11:28:00 +0100 Subject: [PATCH 012/111] update to handle XChainAddAttestation (and fix everything else) --- .../fixtures/data/codec-fixtures.json | 83 +++++++---- tests/unit/models/test_base_model.py | 16 +-- .../binarycodec/definitions/definitions.json | 131 ++++++++++++++++-- xrpl/core/binarycodec/types/__init__.py | 8 +- .../types/{bridge.py => xchain_bridge.py} | 50 +++---- .../types/xchain_claim_attestation_batch.py | 95 +++++++++++++ xrpl/models/bridge.py | 8 +- xrpl/models/transactions/transaction.py | 2 - 8 files changed, 319 insertions(+), 74 deletions(-) rename xrpl/core/binarycodec/types/{bridge.py => xchain_bridge.py} (56%) create mode 100644 xrpl/core/binarycodec/types/xchain_claim_attestation_batch.py diff --git a/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json b/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json index d12e8eaef..a15c41169 100644 --- a/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json +++ b/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json @@ -4451,14 +4451,14 @@ } }, { - "binary": "12001E2280000000240000000168400000000000000A601540000000000003E86016400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020744630440220432A94FC7F759730DD66CC7FB0044E563E6C0DF28C3CDF673CB1D2DF03862FA5022020F70FCF14FF24080E34FA5CA0F555C83A520FC4730F5EDA82523FB0E145E2DA8114AF80285F637EE4AF3C20378F9DFB12511ACB8D270118AF80285F637EE4AF3C20378F9DFB12511ACB8D270000000000000000000000000000000000000000550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", + "binary": "12001E2280000000240000000168400000000000000A601540000000000003E86016400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD0207447304502210082C2B7E8469E7CCFA68F990E630A056D1267F299459434C79C2D80A77BDEFADD022005D68C84A8BAA5FED4E6E1C3CD36E9CEF64A842E6E51E450F1EA8367EE9727158114AF80285F637EE4AF3C20378F9DFB12511ACB8D27011B14AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", "json": { "Account": "rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", - "Bridge": { - "src_chain_door": "rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", - "src_chain_issue": "XRP", - "dst_chain_door": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", - "dst_chain_issue": "XRP" + "XChainBridge": { + "LockingChainDoor": "rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", + "LockingChainIssue": "XRP", + "IssuingChainDoor": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", + "IssuingChainIssue": "XRP" }, "Fee": "10", "Flags": 2147483648, @@ -4471,14 +4471,14 @@ } }, { - "binary": "12001F2280000000240000000168400000000000000A6015400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02074463044022065BB8ABE6E34ADB25C1350F7AF34B1DF01CE87A5ACE1610454EE6B2ED70A0D3302201A4CC9664A191E70F98E921E569E7D3D2EF7FC28353085BC8CBA5296425C287E8114550FC62003E785DC231A1058A05E56E3F09CF4E6801214AF80285F637EE4AF3C20378F9DFB12511ACB8D270118AF80285F637EE4AF3C20378F9DFB12511ACB8D270000000000000000000000000000000000000000550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", + "binary": "12001F2280000000240000000168400000000000000A6015400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD0207446304402203858DCC266B53EDFDF16359AF483323BF4DF7176CD0EDCCC253EF5556C9D131B0220755FE28874AA927C9B41D4C7D35D88BCA4B38B5B8E2F87D21B738F087F32B3988114550FC62003E785DC231A1058A05E56E3F09CF4E6801214AF80285F637EE4AF3C20378F9DFB12511ACB8D27011B14AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", "json": { "Account": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", - "Bridge": { - "src_chain_door": "rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", - "src_chain_issue": "XRP", - "dst_chain_door": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", - "dst_chain_issue": "XRP" + "XChainBridge": { + "LockingChainDoor": "rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", + "LockingChainIssue": "XRP", + "IssuingChainDoor": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", + "IssuingChainIssue": "XRP" }, "Fee": "10", "Flags": 2147483648, @@ -4491,15 +4491,15 @@ } }, { - "binary": "120020228000000024000000013014000000000000000161400000000000271068400000000000000A73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD0207446304402204C1E4F103CB24B10925F34DF2A90AD3008078A0A725A1F96A59652E34EF5071B02200F567E95FF140F12A35CDBD2324F8BE769BF57DE5D2F92367A4C8AAB7C5F34548114550FC62003E785DC231A1058A05E56E3F09CF4E60118AF80285F637EE4AF3C20378F9DFB12511ACB8D270000000000000000000000000000000000000000550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", + "binary": "120020228000000024000000013014000000000000000161400000000000271068400000000000000A73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD0207446304402201B39894271B8512FE9C6E146587F695BC0E2AF19EC47570054FAA8B95A2CBC0C02201A9A63FEACD2416BC6E49EA45143927C474CC2CC85AA135A46A183423E76615A8114550FC62003E785DC231A1058A05E56E3F09CF4E6011B14AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", "json": { "Account": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", "Amount": "10000", - "Bridge": { - "src_chain_door": "rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", - "src_chain_issue": "XRP", - "dst_chain_door": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", - "dst_chain_issue": "XRP" + "XChainBridge": { + "LockingChainDoor": "rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", + "LockingChainIssue": "XRP", + "IssuingChainDoor": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", + "IssuingChainIssue": "XRP" }, "Fee": "10", "Flags": 2147483648, @@ -4511,15 +4511,15 @@ } }, { - "binary": "120021228000000024000000013014000000000000000161400000000000271068400000000000000A73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02074473045022100D4AFE8A4ACED40969B3E06EEC1D3C94FB9B6702537CC56FB180BA2F74E9CCB5C02203B30C46AB83B665BD3B4FF6AB3CBF33C138640CB7CA76888BB7280B114FC94458114550FC62003E785DC231A1058A05E56E3F09CF4E68314550FC62003E785DC231A1058A05E56E3F09CF4E60118AF80285F637EE4AF3C20378F9DFB12511ACB8D270000000000000000000000000000000000000000550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", + "binary": "120021228000000024000000013014000000000000000161400000000000271068400000000000000A73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02074473045022100CA14E5FB5F30FC698119ED7E7D8F291E48A21693190A01AD89E140035476EE9D02206A642A396246C726739195D5D2CCC0635E1A67EDB84DEFBD54D42F7809F45F8B8114550FC62003E785DC231A1058A05E56E3F09CF4E68314550FC62003E785DC231A1058A05E56E3F09CF4E6011B14AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", "json": { "Account": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", "Amount": "10000", - "Bridge": { - "src_chain_door": "rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", - "src_chain_issue": "XRP", - "dst_chain_door": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", - "dst_chain_issue": "XRP" + "XChainBridge": { + "LockingChainDoor": "rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", + "LockingChainIssue": "XRP", + "IssuingChainDoor": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", + "IssuingChainIssue": "XRP" }, "Destination": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", "Fee": "10", @@ -4530,6 +4530,41 @@ "TxnSignature": "3045022100D4AFE8A4ACED40969B3E06EEC1D3C94FB9B6702537CC56FB180BA2F74E9CCB5C02203B30C46AB83B665BD3B4FF6AB3CBF33C138640CB7CA76888BB7280B114FC9445", "XChainClaimID": "0000000000000001" } + }, + { + "binary": "1200242280000000240000000468400000000000000A73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02074473045022100DCAC6A97BC4AA1379504FD5293FDFA46A4C216DDC13F3950F9692E0F803862A602206583360A60961E2988041E7E8589037A233771DCFB84E7A4710940A878EAFD7581142F3CC37C1D5616B3BBF1AABC49F6BFF46A920087011C14C48CAD01682D7A86296EF14523074D4852C02EA9000000000000000000000000000000000000000014CC86E58C9B58D4CF71CB8C1B41F21BB290CE13D40000000000000000000000000000000000000000E01C30140000000000000000614000000005F5E100712103DAB289CA36FF377F3F4304C7A7203FDE5EDCBFC209F430F6A4355361425526D0760361626381142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314621D345F8F094A085132431C69C89EC05D212CC28014142F3CC37C1D5616B3BBF1AABC49F6BFF46A92008700101301E1", + "json": { + "Account" : "rnJmYAiqEVngtnb5ckRroXLtCbWC7CRUBx", + "Fee" : "10", + "Flags" : 2147483648, + "Sequence" : 4, + "SigningPubKey" : "038AD1D37688B3C0D366F2A6AEBB1361C5432681D7FD74A195F19D3AF2D857F828", + "TransactionType" : "XChainAddAttestation", + "TxnSignature" : "3045022100FB77A07939A4D70DDF456408757E330889FF1D5734906B2C21A76D4F94645DCA02205644D04FEFF37AC244B3FBCA05F58312333AD54ECAE8F9DCFD64F089E7323840", + "XChainAttestationBatch" : { + "XChainBridge" : { + "IssuingChainDoor" : "rKeSSvHvaMZJp9ykaxutVwkhZgWuWMLnQt", + "IssuingChainIssue" : "XRP", + "LockingChainDoor" : "rJvExveLEL4jNDEeLKCVdxaSCN9cEBnEQC", + "LockingChainIssue" : "XRP" + }, + "XChainClaimAttestationBatch" : [ + { + "XChainClaimAttestationBatchElement" : { + "Account" : "rnJmYAiqEVngtnb5ckRroXLtCbWC7CRUBx", + "Amount" : "100000000", + "AttestationRewardAccount" : "rnJmYAiqEVngtnb5ckRroXLtCbWC7CRUBx", + "Destination" : "r9A8UyNpW3X46FUc6P7JZqgn6WgAPjBwPg", + "PublicKey" : "03DAB289CA36FF377F3F4304C7A7203FDE5EDCBFC209F430F6A4355361425526D0", + "Signature" : "616263", + "WasLockingChainSend" : 1, + "XChainClaimID" : "0" + } + } + ], + "XChainCreateAccountAttestationBatch" : [] + } + } } ], "ledgerData": [{ diff --git a/tests/unit/models/test_base_model.py b/tests/unit/models/test_base_model.py index bb6cf904d..87184b415 100644 --- a/tests/unit/models/test_base_model.py +++ b/tests/unit/models/test_base_model.py @@ -605,10 +605,10 @@ def test_to_from_xrpl_xchain(self): "Account": account, "Amount": value, "Bridge": { - "src_chain_door": "rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", - "src_chain_issue": "XRP", - "dst_chain_door": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", - "dst_chain_issue": "XRP", + "LockingChainDoor": "rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", + "LockingChainIssue": "XRP", + "IssuingChainDoor": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", + "IssuingChainIssue": "XRP", }, "Destination": destination, "TransactionType": "XChainClaim", @@ -620,10 +620,10 @@ def test_to_from_xrpl_xchain(self): account=account, amount=value, bridge=Bridge( - src_chain_door="rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", - src_chain_issue="XRP", - dst_chain_door="r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", - dst_chain_issue="XRP", + locking_chain_door="rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", + locking_chain_issue="XRP", + issuing_chain_door="r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", + issuing_chain_issue="XRP", ), destination=destination, xchain_claim_id="0000000000000001", diff --git a/xrpl/core/binarycodec/definitions/definitions.json b/xrpl/core/binarycodec/definitions/definitions.json index d4a3e16dd..02ebd23d2 100644 --- a/xrpl/core/binarycodec/definitions/definitions.json +++ b/xrpl/core/binarycodec/definitions/definitions.json @@ -21,10 +21,11 @@ "UInt192": 21, "UInt384": 22, "UInt512": 23, - "Bridge": 24, - "XChainAttestations": 25, - "XChainAttestationBatch": 26, - "XChainClaimProof": 27, + "XChainAttestations": 24, + "XChainClaimProof": 25, + "Issue": 26, + "XChainBridge": 27, + "XChainAttestationBatch": 28, "Transaction": 10001, "LedgerEntry": 10002, "Validation": 10003, @@ -1877,6 +1878,26 @@ "type": "AccountID" } ], + [ + "LockingChainDoor", + { + "nth": 21, + "isVLEncoded": true, + "isSerialized": true, + "isSigningField": true, + "type": "AccountID" + } + ], + [ + "IssuingChainDoor", + { + "nth": 22, + "isVLEncoded": true, + "isSerialized": true, + "isSigningField": true, + "type": "AccountID" + } + ], [ "Indexes", { @@ -1928,33 +1949,53 @@ } ], [ - "Bridge", + "XChainClaimProof", { "nth": 1, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "Bridge" + "type": "XChainClaimProof" } ], [ - "XChainClaimProof", + "XChainAttestations", { "nth": 1, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "XChainClaimProof" + "type": "XChainAttestations" } ], [ - "XChainAttestations", + "LockingChainIssue", { "nth": 1, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, - "type": "XChainAttestations" + "type": "Issue" + } + ], + [ + "IssuingChainIssue", + { + "nth": 2, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "Issue" + } + ], + [ + "XChainBridge", + { + "nth": 1, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "XChainBridge" } ], [ @@ -2187,6 +2228,56 @@ "type": "STObject" } ], + [ + "XChainAttestationSigs", + { + "nth": 26, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "STObject" + } + ], + [ + "XChainAttestationBatchElement", + { + "nth": 27, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "STObject" + } + ], + [ + "XChainClaimAttestationBatchElement", + { + "nth": 28, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "STObject" + } + ], + [ + "XChainCreateAccountAttestationBatchElement", + { + "nth": 29, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "STObject" + } + ], + [ + "XChainAttestationBatchInner", + { + "nth": 30, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "STObject" + } + ], [ "Signers", { @@ -2336,6 +2427,26 @@ "isSigningField": true, "type": "STArray" } + ], + [ + "XChainClaimAttestationBatch", + { + "nth": 22, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "STArray" + } + ], + [ + "XChainCreateAccountAttestationBatch", + { + "nth": 23, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "STArray" + } ] ], "TRANSACTION_RESULTS": { diff --git a/xrpl/core/binarycodec/types/__init__.py b/xrpl/core/binarycodec/types/__init__.py index 1d2b2fbb5..2b7981bc7 100644 --- a/xrpl/core/binarycodec/types/__init__.py +++ b/xrpl/core/binarycodec/types/__init__.py @@ -2,7 +2,6 @@ from xrpl.core.binarycodec.types.account_id import AccountID from xrpl.core.binarycodec.types.amount import Amount from xrpl.core.binarycodec.types.blob import Blob -from xrpl.core.binarycodec.types.bridge import Bridge from xrpl.core.binarycodec.types.currency import Currency from xrpl.core.binarycodec.types.hash import Hash from xrpl.core.binarycodec.types.hash128 import Hash128 @@ -18,12 +17,15 @@ from xrpl.core.binarycodec.types.uint32 import UInt32 from xrpl.core.binarycodec.types.uint64 import UInt64 from xrpl.core.binarycodec.types.vector256 import Vector256 +from xrpl.core.binarycodec.types.xchain_bridge import XChainBridge +from xrpl.core.binarycodec.types.xchain_claim_attestation_batch import ( + XChainAttestationBatch, +) __all__ = [ "AccountID", "Amount", "Blob", - "Bridge", "Currency", "Hash", "Hash128", @@ -39,4 +41,6 @@ "UInt32", "UInt64", "Vector256", + "XChainBridge", + "XChainAttestationBatch", ] diff --git a/xrpl/core/binarycodec/types/bridge.py b/xrpl/core/binarycodec/types/xchain_bridge.py similarity index 56% rename from xrpl/core/binarycodec/types/bridge.py rename to xrpl/core/binarycodec/types/xchain_bridge.py index e95b60231..cf0c3e2c5 100644 --- a/xrpl/core/binarycodec/types/bridge.py +++ b/xrpl/core/binarycodec/types/xchain_bridge.py @@ -1,46 +1,48 @@ """Codec for serializing and deserializing bridge fields.""" from __future__ import annotations -from typing import Any, Dict, List, Optional, Tuple, Type, Union, cast +from typing import Any, Dict, List, Optional, Tuple, Type, Union from xrpl.core.binarycodec.binary_wrappers.binary_parser import BinaryParser from xrpl.core.binarycodec.exceptions import XRPLBinaryCodecException from xrpl.core.binarycodec.types.account_id import AccountID from xrpl.core.binarycodec.types.issued_currency import IssuedCurrency from xrpl.core.binarycodec.types.serialized_type import SerializedType -from xrpl.models.bridge import Bridge as BridgeModel _TYPE_ORDER: List[Tuple[str, Type[SerializedType]]] = [ - ("src_chain_door", AccountID), - ("src_chain_issue", IssuedCurrency), - ("dst_chain_door", AccountID), - ("dst_chain_issue", IssuedCurrency), + ("LockingChainDoor", AccountID), + ("LockingChainIssue", IssuedCurrency), + ("IssuingChainDoor", AccountID), + ("IssuingChainIssue", IssuedCurrency), ] +_TYPE_KEYS = {type[0] for type in _TYPE_ORDER} -class Bridge(SerializedType): + +class XChainBridge(SerializedType): """Codec for serializing and deserializing bridge fields.""" - def __init__(self: Bridge, buffer: bytes) -> None: - """Construct a Bridge from given bytes.""" + def __init__(self: XChainBridge, buffer: bytes) -> None: + """Construct a XChainBridge from given bytes.""" super().__init__(buffer) @classmethod - def from_value(cls: Type[Bridge], value: Union[str, Dict[str, str]]) -> Bridge: + def from_value( + cls: Type[XChainBridge], value: Union[str, Dict[str, str]] + ) -> XChainBridge: """ - Construct a Bridge object from a dictionary representation of a bridge. + Construct a XChainBridge object from a dictionary representation of a bridge. Args: - value: The dictionary to construct a Bridge object from. + value: The dictionary to construct a XChainBridge object from. Returns: - A Bridge object constructed from value. + A XChainBridge object constructed from value. Raises: - XRPLBinaryCodecException: If the Bridge representation is invalid. + XRPLBinaryCodecException: If the XChainBridge representation is invalid. """ - if BridgeModel.is_dict_of_model(value): - value = cast(Dict[str, Any], value) + if isinstance(value, dict) and set(value.keys()) == _TYPE_KEYS: buffer = b"" for (name, object_type) in _TYPE_ORDER: obj = object_type.from_value(value[name]) @@ -48,23 +50,23 @@ def from_value(cls: Type[Bridge], value: Union[str, Dict[str, str]]) -> Bridge: return cls(buffer) raise XRPLBinaryCodecException( - "Invalid type to construct a Bridge: expected dict," + "Invalid type to construct a XChainBridge: expected dict," f" received {value.__class__.__name__}." ) @classmethod def from_parser( - cls: Type[Bridge], parser: BinaryParser, length_hint: Optional[int] = None - ) -> Bridge: + cls: Type[XChainBridge], parser: BinaryParser, length_hint: Optional[int] = None + ) -> XChainBridge: """ - Construct a Bridge object from an existing BinaryParser. + Construct a XChainBridge object from an existing BinaryParser. Args: - parser: The parser to construct the Bridge object from. + parser: The parser to construct the XChainBridge object from. length_hint: The number of bytes to consume from the parser. Returns: - The Bridge object constructed from a parser. + The XChainBridge object constructed from a parser. """ buffer = b"" @@ -74,12 +76,12 @@ def from_parser( return cls(buffer) - def to_json(self: Bridge) -> Union[str, Dict[Any, Any]]: + def to_json(self: XChainBridge) -> Union[str, Dict[Any, Any]]: """ Returns the JSON representation of a bridge. Returns: - The JSON representation of a Bridge. + The JSON representation of a XChainBridge. """ parser = BinaryParser(str(self)) return_json = {} diff --git a/xrpl/core/binarycodec/types/xchain_claim_attestation_batch.py b/xrpl/core/binarycodec/types/xchain_claim_attestation_batch.py new file mode 100644 index 000000000..dd3882e93 --- /dev/null +++ b/xrpl/core/binarycodec/types/xchain_claim_attestation_batch.py @@ -0,0 +1,95 @@ +"""Codec for serializing and deserializing bridge fields.""" +from __future__ import annotations + +from typing import Any, Dict, List, Optional, Tuple, Type, Union + +from xrpl.core.binarycodec.binary_wrappers.binary_parser import BinaryParser +from xrpl.core.binarycodec.exceptions import XRPLBinaryCodecException +from xrpl.core.binarycodec.types.serialized_type import SerializedType +from xrpl.core.binarycodec.types.st_array import STArray +from xrpl.core.binarycodec.types.xchain_bridge import XChainBridge + +_TYPE_ORDER: List[Tuple[str, Type[SerializedType]]] = [ + ("XChainBridge", XChainBridge), + ("XChainClaimAttestationBatch", STArray), + ("XChainCreateAccountAttestationBatch", STArray), +] + +_TYPE_KEYS = {type[0] for type in _TYPE_ORDER} + + +class XChainAttestationBatch(SerializedType): + """Codec for serializing and deserializing XChainAttestationBatch fields.""" + + def __init__(self: XChainAttestationBatch, buffer: bytes) -> None: + """Construct a XChainAttestationBatch from given bytes.""" + super().__init__(buffer) + + @classmethod + def from_value( + cls: Type[XChainAttestationBatch], value: Union[str, Dict[str, str]] + ) -> XChainAttestationBatch: + """ + Construct a XChainAttestationBatch object from a dictionary representation of a + XChainAttestationBatch. + + Args: + value: The dictionary to construct a XChainAttestationBatch object from. + + Returns: + A XChainAttestationBatch object constructed from value. + + Raises: + XRPLBinaryCodecException: If the XChainAttestationBatch representation is + invalid. + """ + if isinstance(value, dict) and set(value.keys()) == _TYPE_KEYS: + buffer = b"" + for (name, object_type) in _TYPE_ORDER: + obj = object_type.from_value(value[name]) + buffer += bytes(obj) + return cls(buffer) + + raise XRPLBinaryCodecException( + "Invalid type to construct an XChainAttestationBatch: expected dict," + f" received {value.__class__.__name__}." + ) + + @classmethod + def from_parser( + cls: Type[XChainAttestationBatch], + parser: BinaryParser, + length_hint: Optional[int] = None, + ) -> XChainAttestationBatch: + """ + Construct a XChainAttestationBatch object from an existing BinaryParser. + + Args: + parser: The parser to construct the XChainAttestationBatch object from. + length_hint: The number of bytes to consume from the parser. + + Returns: + The XChainAttestationBatch object constructed from a parser. + """ + buffer = b"" + + for (_, object_type) in _TYPE_ORDER: + obj = object_type.from_parser(parser, length_hint) + buffer += bytes(obj) + + return cls(buffer) + + def to_json(self: XChainAttestationBatch) -> Union[str, Dict[Any, Any]]: + """ + Returns the JSON representation of a XChainAttestationBatch. + + Returns: + The JSON representation of a XChainAttestationBatch. + """ + parser = BinaryParser(str(self)) + return_json = {} + for (name, object_type) in _TYPE_ORDER: + obj = object_type.from_parser(parser, None) + return_json[name] = obj.to_json() + + return return_json diff --git a/xrpl/models/bridge.py b/xrpl/models/bridge.py index 8a5be9630..efbecee5c 100644 --- a/xrpl/models/bridge.py +++ b/xrpl/models/bridge.py @@ -17,7 +17,7 @@ class Bridge(BaseModel): """A Bridge represents a cross-chain bridge.""" - src_chain_door: str - src_chain_issue: Union[Literal["XRP"], IssuedCurrency] - dst_chain_door: str - dst_chain_issue: Union[Literal["XRP"], IssuedCurrency] + locking_chain_door: str + locking_chain_issue: Union[Literal["XRP"], IssuedCurrency] + issuing_chain_door: str + issuing_chain_issue: Union[Literal["XRP"], IssuedCurrency] diff --git a/xrpl/models/transactions/transaction.py b/xrpl/models/transactions/transaction.py index 1336a7e85..414da363a 100644 --- a/xrpl/models/transactions/transaction.py +++ b/xrpl/models/transactions/transaction.py @@ -10,7 +10,6 @@ from xrpl.core.binarycodec import encode from xrpl.models.amounts import IssuedCurrencyAmount from xrpl.models.base_model import BaseModel -from xrpl.models.bridge import Bridge from xrpl.models.exceptions import XRPLModelException from xrpl.models.flags import check_false_flag_definition, interface_to_flag_list from xrpl.models.nested_model import NestedModel @@ -34,7 +33,6 @@ _LOWER_CASE_MODELS: List[Type[BaseModel]] = [ IssuedCurrencyAmount, PathStep, - Bridge, ] From 58a0b02cb7dbc28bf89dc08c6159f9a7ef1385e7 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Mon, 18 Jul 2022 14:24:27 +0100 Subject: [PATCH 013/111] fix bugs --- .../fixtures/data/codec-fixtures.json | 22 +++++++++---------- .../binarycodec/definitions/field_header.py | 4 ++++ xrpl/core/binarycodec/types/xchain_bridge.py | 10 +++++++-- .../types/xchain_claim_attestation_batch.py | 2 +- 4 files changed, 24 insertions(+), 14 deletions(-) diff --git a/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json b/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json index a15c41169..22f6aebea 100644 --- a/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json +++ b/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json @@ -4451,7 +4451,7 @@ } }, { - "binary": "12001E2280000000240000000168400000000000000A601540000000000003E86016400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD0207447304502210082C2B7E8469E7CCFA68F990E630A056D1267F299459434C79C2D80A77BDEFADD022005D68C84A8BAA5FED4E6E1C3CD36E9CEF64A842E6E51E450F1EA8367EE9727158114AF80285F637EE4AF3C20378F9DFB12511ACB8D27011B14AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", + "binary": "12001E2200000000240000000168400000000000000A601540000000000003E86016400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02074463044022044798D0E4310C7E79B2929308E765F0C29B2D2A1DB4FDF0D7A62DAB39A4874F402207DC871A0E0049078ECB98EAD1E0B78DAD17F4E3E6DF4AB2E5F6DAC9451A5630A8114AF80285F637EE4AF3C20378F9DFB12511ACB8D27011B14AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", "json": { "Account": "rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", "XChainBridge": { @@ -4461,13 +4461,13 @@ "IssuingChainIssue": "XRP" }, "Fee": "10", - "Flags": 2147483648, + "Flags": 0, "MinAccountCreateAmount": "10000", "Sequence": 1, "SignatureReward": "1000", "SigningPubKey": "0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020", "TransactionType": "XChainCreateBridge", - "TxnSignature": "30440220432A94FC7F759730DD66CC7FB0044E563E6C0DF28C3CDF673CB1D2DF03862FA5022020F70FCF14FF24080E34FA5CA0F555C83A520FC4730F5EDA82523FB0E145E2DA" + "TxnSignature": "3044022044798D0E4310C7E79B2929308E765F0C29B2D2A1DB4FDF0D7A62DAB39A4874F402207DC871A0E0049078ECB98EAD1E0B78DAD17F4E3E6DF4AB2E5F6DAC9451A5630A" } }, { @@ -4487,7 +4487,7 @@ "SignatureReward": "10000", "SigningPubKey": "0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020", "TransactionType": "XChainCreateClaimID", - "TxnSignature": "3044022065BB8ABE6E34ADB25C1350F7AF34B1DF01CE87A5ACE1610454EE6B2ED70A0D3302201A4CC9664A191E70F98E921E569E7D3D2EF7FC28353085BC8CBA5296425C287E" + "TxnSignature": "304402203858DCC266B53EDFDF16359AF483323BF4DF7176CD0EDCCC253EF5556C9D131B0220755FE28874AA927C9B41D4C7D35D88BCA4B38B5B8E2F87D21B738F087F32B398" } }, { @@ -4506,7 +4506,7 @@ "Sequence": 1, "SigningPubKey": "0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020", "TransactionType": "XChainCommit", - "TxnSignature": "304402204C1E4F103CB24B10925F34DF2A90AD3008078A0A725A1F96A59652E34EF5071B02200F567E95FF140F12A35CDBD2324F8BE769BF57DE5D2F92367A4C8AAB7C5F3454", + "TxnSignature": "304402201B39894271B8512FE9C6E146587F695BC0E2AF19EC47570054FAA8B95A2CBC0C02201A9A63FEACD2416BC6E49EA45143927C474CC2CC85AA135A46A183423E76615A", "XChainClaimID": "0000000000000001" } }, @@ -4527,20 +4527,20 @@ "Sequence": 1, "SigningPubKey": "0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020", "TransactionType": "XChainClaim", - "TxnSignature": "3045022100D4AFE8A4ACED40969B3E06EEC1D3C94FB9B6702537CC56FB180BA2F74E9CCB5C02203B30C46AB83B665BD3B4FF6AB3CBF33C138640CB7CA76888BB7280B114FC9445", + "TxnSignature": "3045022100CA14E5FB5F30FC698119ED7E7D8F291E48A21693190A01AD89E140035476EE9D02206A642A396246C726739195D5D2CCC0635E1A67EDB84DEFBD54D42F7809F45F8B", "XChainClaimID": "0000000000000001" } }, { - "binary": "1200242280000000240000000468400000000000000A73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02074473045022100DCAC6A97BC4AA1379504FD5293FDFA46A4C216DDC13F3950F9692E0F803862A602206583360A60961E2988041E7E8589037A233771DCFB84E7A4710940A878EAFD7581142F3CC37C1D5616B3BBF1AABC49F6BFF46A920087011C14C48CAD01682D7A86296EF14523074D4852C02EA9000000000000000000000000000000000000000014CC86E58C9B58D4CF71CB8C1B41F21BB290CE13D40000000000000000000000000000000000000000E01C30140000000000000000614000000005F5E100712103DAB289CA36FF377F3F4304C7A7203FDE5EDCBFC209F430F6A4355361425526D0760361626381142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314621D345F8F094A085132431C69C89EC05D212CC28014142F3CC37C1D5616B3BBF1AABC49F6BFF46A92008700101301E1", + "binary": "1200242280000000240000000468400000000000000A73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02074473045022100DCAC6A97BC4AA1379504FD5293FDFA46A4C216DDC13F3950F9692E0F803862A602206583360A60961E2988041E7E8589037A233771DCFB84E7A4710940A878EAFD7581142F3CC37C1D5616B3BBF1AABC49F6BFF46A920087011C14C48CAD01682D7A86296EF14523074D4852C02EA9000000000000000000000000000000000000000014CC86E58C9B58D4CF71CB8C1B41F21BB290CE13D40000000000000000000000000000000000000000E01C30140000000000000000614000000005F5E100712103DAB289CA36FF377F3F4304C7A7203FDE5EDCBFC209F430F6A4355361425526D0760361626381142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314621D345F8F094A085132431C69C89EC05D212CC28014142F3CC37C1D5616B3BBF1AABC49F6BFF46A92008700101301E1F1F1", "json": { "Account" : "rnJmYAiqEVngtnb5ckRroXLtCbWC7CRUBx", "Fee" : "10", "Flags" : 2147483648, "Sequence" : 4, - "SigningPubKey" : "038AD1D37688B3C0D366F2A6AEBB1361C5432681D7FD74A195F19D3AF2D857F828", + "SigningPubKey" : "0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020", "TransactionType" : "XChainAddAttestation", - "TxnSignature" : "3045022100FB77A07939A4D70DDF456408757E330889FF1D5734906B2C21A76D4F94645DCA02205644D04FEFF37AC244B3FBCA05F58312333AD54ECAE8F9DCFD64F089E7323840", + "TxnSignature" : "3045022100DCAC6A97BC4AA1379504FD5293FDFA46A4C216DDC13F3950F9692E0F803862A602206583360A60961E2988041E7E8589037A233771DCFB84E7A4710940A878EAFD75", "XChainAttestationBatch" : { "XChainBridge" : { "IssuingChainDoor" : "rKeSSvHvaMZJp9ykaxutVwkhZgWuWMLnQt", @@ -4558,13 +4558,13 @@ "PublicKey" : "03DAB289CA36FF377F3F4304C7A7203FDE5EDCBFC209F430F6A4355361425526D0", "Signature" : "616263", "WasLockingChainSend" : 1, - "XChainClaimID" : "0" + "XChainClaimID" : "0000000000000000" } } ], "XChainCreateAccountAttestationBatch" : [] } - } + } } ], "ledgerData": [{ diff --git a/xrpl/core/binarycodec/definitions/field_header.py b/xrpl/core/binarycodec/definitions/field_header.py index 3a9b05fcb..a2ff0bc4f 100644 --- a/xrpl/core/binarycodec/definitions/field_header.py +++ b/xrpl/core/binarycodec/definitions/field_header.py @@ -48,3 +48,7 @@ def __bytes__(self: FieldHeader) -> bytes: header += [0, self.type_code, self.field_code] return bytes(header) + + def __repr__(self: FieldHeader) -> str: + """Print a string representation of a FieldHeader (for debugging).""" + return f"FieldHeader({self.type_code}, {self.field_code})" diff --git a/xrpl/core/binarycodec/types/xchain_bridge.py b/xrpl/core/binarycodec/types/xchain_bridge.py index cf0c3e2c5..f9b385611 100644 --- a/xrpl/core/binarycodec/types/xchain_bridge.py +++ b/xrpl/core/binarycodec/types/xchain_bridge.py @@ -46,6 +46,8 @@ def from_value( buffer = b"" for (name, object_type) in _TYPE_ORDER: obj = object_type.from_value(value[name]) + if object_type == AccountID: + buffer += bytes.fromhex("14") buffer += bytes(obj) return cls(buffer) @@ -70,7 +72,10 @@ def from_parser( """ buffer = b"" - for (_, object_type) in _TYPE_ORDER: + for (name, object_type) in _TYPE_ORDER: + if object_type == AccountID: + parser.skip(1) + buffer += bytes.fromhex("14") obj = object_type.from_parser(parser, length_hint) buffer += bytes(obj) @@ -86,7 +91,8 @@ def to_json(self: XChainBridge) -> Union[str, Dict[Any, Any]]: parser = BinaryParser(str(self)) return_json = {} for (name, object_type) in _TYPE_ORDER: + if object_type == AccountID: + parser.skip(1) obj = object_type.from_parser(parser, None) return_json[name] = obj.to_json() - return return_json diff --git a/xrpl/core/binarycodec/types/xchain_claim_attestation_batch.py b/xrpl/core/binarycodec/types/xchain_claim_attestation_batch.py index dd3882e93..c4f99a6f9 100644 --- a/xrpl/core/binarycodec/types/xchain_claim_attestation_batch.py +++ b/xrpl/core/binarycodec/types/xchain_claim_attestation_batch.py @@ -73,7 +73,7 @@ def from_parser( """ buffer = b"" - for (_, object_type) in _TYPE_ORDER: + for (name, object_type) in _TYPE_ORDER: obj = object_type.from_parser(parser, length_hint) buffer += bytes(obj) From 3d34552b93c9f1149a1a4b974e676b8ac59f197d Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Mon, 18 Jul 2022 14:33:08 +0100 Subject: [PATCH 014/111] fix unused variable --- xrpl/core/binarycodec/types/xchain_claim_attestation_batch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xrpl/core/binarycodec/types/xchain_claim_attestation_batch.py b/xrpl/core/binarycodec/types/xchain_claim_attestation_batch.py index c4f99a6f9..dd3882e93 100644 --- a/xrpl/core/binarycodec/types/xchain_claim_attestation_batch.py +++ b/xrpl/core/binarycodec/types/xchain_claim_attestation_batch.py @@ -73,7 +73,7 @@ def from_parser( """ buffer = b"" - for (name, object_type) in _TYPE_ORDER: + for (_, object_type) in _TYPE_ORDER: obj = object_type.from_parser(parser, length_hint) buffer += bytes(obj) From 1769b109aa66837355a6ccbec69a4d8d051604c4 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Mon, 18 Jul 2022 15:38:09 +0100 Subject: [PATCH 015/111] rename Bridge -> XChainBridge in models --- tests/unit/models/test_base_model.py | 6 +++--- xrpl/models/__init__.py | 4 ++-- xrpl/models/transactions/xchain_claim.py | 4 ++-- xrpl/models/transactions/xchain_commit.py | 4 ++-- xrpl/models/transactions/xchain_create_bridge.py | 4 ++-- xrpl/models/transactions/xchain_create_claim_id.py | 4 ++-- xrpl/models/{bridge.py => xchain_bridge.py} | 6 +++--- 7 files changed, 16 insertions(+), 16 deletions(-) rename xrpl/models/{bridge.py => xchain_bridge.py} (78%) diff --git a/tests/unit/models/test_base_model.py b/tests/unit/models/test_base_model.py index 87184b415..c0861d19a 100644 --- a/tests/unit/models/test_base_model.py +++ b/tests/unit/models/test_base_model.py @@ -4,7 +4,6 @@ from xrpl.models import XRPLModelException from xrpl.models.amounts import IssuedCurrencyAmount -from xrpl.models.bridge import Bridge from xrpl.models.requests import ( AccountChannels, BookOffers, @@ -28,6 +27,7 @@ XChainClaim, ) from xrpl.models.transactions.transaction import Transaction +from xrpl.models.xchain_bridge import XChainBridge currency = "BTC" value = "100" @@ -604,7 +604,7 @@ def test_to_from_xrpl_xchain(self): tx_json = { "Account": account, "Amount": value, - "Bridge": { + "XChainBridge": { "LockingChainDoor": "rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", "LockingChainIssue": "XRP", "IssuingChainDoor": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", @@ -619,7 +619,7 @@ def test_to_from_xrpl_xchain(self): tx_obj = XChainClaim( account=account, amount=value, - bridge=Bridge( + xchain_bridge=XChainBridge( locking_chain_door="rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", locking_chain_issue="XRP", issuing_chain_door="r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", diff --git a/xrpl/models/__init__.py b/xrpl/models/__init__.py index a80d6e4ee..045183e0e 100644 --- a/xrpl/models/__init__.py +++ b/xrpl/models/__init__.py @@ -1,7 +1,6 @@ """Top-level exports for the models package.""" from xrpl.models import amounts, currencies, requests, transactions from xrpl.models.amounts import * # noqa: F401, F403 -from xrpl.models.bridge import Bridge from xrpl.models.currencies import * # noqa: F401, F403 from xrpl.models.exceptions import XRPLModelException from xrpl.models.path import Path, PathStep @@ -9,6 +8,7 @@ from xrpl.models.response import Response from xrpl.models.transactions import * # noqa: F401, F403 from xrpl.models.transactions.pseudo_transactions import * # noqa: F401, F403 +from xrpl.models.xchain_bridge import XChainBridge __all__ = [ "XRPLModelException", @@ -21,8 +21,8 @@ "transactions", *transactions.__all__, *transactions.pseudo_transactions.__all__, - "Bridge", "Path", "PathStep", "Response", + "XChainBridge", ] diff --git a/xrpl/models/transactions/xchain_claim.py b/xrpl/models/transactions/xchain_claim.py index 2e2b9b630..736fc2a9d 100644 --- a/xrpl/models/transactions/xchain_claim.py +++ b/xrpl/models/transactions/xchain_claim.py @@ -4,11 +4,11 @@ from typing import Union from xrpl.models.amounts import Amount -from xrpl.models.bridge import Bridge from xrpl.models.required import REQUIRED from xrpl.models.transactions.transaction import Transaction from xrpl.models.transactions.types import TransactionType from xrpl.models.utils import require_kwargs_on_init +from xrpl.models.xchain_bridge import XChainBridge @require_kwargs_on_init @@ -16,7 +16,7 @@ class XChainClaim(Transaction): """Represents a XChainClaim transaction.""" - bridge: Bridge = REQUIRED # type: ignore + xchain_bridge: XChainBridge = REQUIRED # type: ignore xchain_claim_id: Union[int, str] = REQUIRED # type: ignore diff --git a/xrpl/models/transactions/xchain_commit.py b/xrpl/models/transactions/xchain_commit.py index aa828bec0..4921a1e89 100644 --- a/xrpl/models/transactions/xchain_commit.py +++ b/xrpl/models/transactions/xchain_commit.py @@ -4,11 +4,11 @@ from typing import Union from xrpl.models.amounts import Amount -from xrpl.models.bridge import Bridge from xrpl.models.required import REQUIRED from xrpl.models.transactions.transaction import Transaction from xrpl.models.transactions.types import TransactionType from xrpl.models.utils import require_kwargs_on_init +from xrpl.models.xchain_bridge import XChainBridge @require_kwargs_on_init @@ -16,7 +16,7 @@ class XChainCommit(Transaction): """Represents a XChainCommit transaction.""" - bridge: Bridge = REQUIRED # type: ignore + xchain_bridge: XChainBridge = REQUIRED # type: ignore xchain_claim_id: Union[int, str] = REQUIRED # type: ignore diff --git a/xrpl/models/transactions/xchain_create_bridge.py b/xrpl/models/transactions/xchain_create_bridge.py index 1ffa80c65..b82a06314 100644 --- a/xrpl/models/transactions/xchain_create_bridge.py +++ b/xrpl/models/transactions/xchain_create_bridge.py @@ -4,11 +4,11 @@ from typing import Optional from xrpl.models.amounts import Amount -from xrpl.models.bridge import Bridge from xrpl.models.required import REQUIRED from xrpl.models.transactions.transaction import Transaction from xrpl.models.transactions.types import TransactionType from xrpl.models.utils import require_kwargs_on_init +from xrpl.models.xchain_bridge import XChainBridge @require_kwargs_on_init @@ -16,7 +16,7 @@ class XChainCreateBridge(Transaction): """Represents a XChainCreateBridge transaction.""" - bridge: Bridge = REQUIRED # type: ignore + xchain_bridge: XChainBridge = REQUIRED # type: ignore signature_reward: Amount = REQUIRED # type: ignore diff --git a/xrpl/models/transactions/xchain_create_claim_id.py b/xrpl/models/transactions/xchain_create_claim_id.py index 122ee440b..53314b461 100644 --- a/xrpl/models/transactions/xchain_create_claim_id.py +++ b/xrpl/models/transactions/xchain_create_claim_id.py @@ -3,11 +3,11 @@ from dataclasses import dataclass, field from xrpl.models.amounts import Amount -from xrpl.models.bridge import Bridge from xrpl.models.required import REQUIRED from xrpl.models.transactions.transaction import Transaction from xrpl.models.transactions.types import TransactionType from xrpl.models.utils import require_kwargs_on_init +from xrpl.models.xchain_bridge import XChainBridge @require_kwargs_on_init @@ -15,7 +15,7 @@ class XChainCreateClaimID(Transaction): """Represents a XChainCreateClaimID transaction.""" - bridge: Bridge = REQUIRED # type: ignore + xchain_bridge: XChainBridge = REQUIRED # type: ignore signature_reward: Amount = REQUIRED # type: ignore diff --git a/xrpl/models/bridge.py b/xrpl/models/xchain_bridge.py similarity index 78% rename from xrpl/models/bridge.py rename to xrpl/models/xchain_bridge.py index efbecee5c..2b3484b5a 100644 --- a/xrpl/models/bridge.py +++ b/xrpl/models/xchain_bridge.py @@ -1,4 +1,4 @@ -"""A Bridge represents a cross-chain bridge.""" +"""A XChainBridge represents a cross-chain bridge.""" from __future__ import annotations @@ -14,8 +14,8 @@ @require_kwargs_on_init @dataclass(frozen=True) -class Bridge(BaseModel): - """A Bridge represents a cross-chain bridge.""" +class XChainBridge(BaseModel): + """A XChainBridge represents a cross-chain bridge.""" locking_chain_door: str locking_chain_issue: Union[Literal["XRP"], IssuedCurrency] From cff03e19170bf6162d85ec41a4bf83060c758270 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Mon, 18 Jul 2022 15:57:07 +0100 Subject: [PATCH 016/111] add XChainAddAttestation model(s) --- xrpl/models/transactions/__init__.py | 2 + .../transactions/types/transaction_type.py | 2 +- .../transactions/xchain_add_attestation.py | 127 ++++++++++++++++++ 3 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 xrpl/models/transactions/xchain_add_attestation.py diff --git a/xrpl/models/transactions/__init__.py b/xrpl/models/transactions/__init__.py index 567ba72b1..0c58dcc4f 100644 --- a/xrpl/models/transactions/__init__.py +++ b/xrpl/models/transactions/__init__.py @@ -53,6 +53,7 @@ TrustSetFlag, TrustSetFlagInterface, ) +from xrpl.models.transactions.xchain_add_attestation import XChainAddAttestation from xrpl.models.transactions.xchain_claim import XChainClaim from xrpl.models.transactions.xchain_commit import XChainCommit from xrpl.models.transactions.xchain_create_bridge import XChainCreateBridge @@ -102,6 +103,7 @@ "TrustSet", "TrustSetFlag", "TrustSetFlagInterface", + "XChainAddAttestation", "XChainClaim", "XChainCommit", "XChainCreateBridge", diff --git a/xrpl/models/transactions/types/transaction_type.py b/xrpl/models/transactions/types/transaction_type.py index ef71d46ad..5d5c2c2f2 100644 --- a/xrpl/models/transactions/types/transaction_type.py +++ b/xrpl/models/transactions/types/transaction_type.py @@ -30,7 +30,7 @@ class TransactionType(str, Enum): SIGNER_LIST_SET = "SignerListSet" TICKET_CREATE = "TicketCreate" TRUST_SET = "TrustSet" - # XCHAIN_ADD_ATTESTATION = "XChainAddAttestation" + XCHAIN_ADD_ATTESTATION = "XChainAddAttestation" XCHAIN_CLAIM = "XChainClaim" XCHAIN_COMMIT = "XChainCommit" # XCHAIN_CREATE_ACCOUNT_COMMIT = "XChainCreateAccountCommit" diff --git a/xrpl/models/transactions/xchain_add_attestation.py b/xrpl/models/transactions/xchain_add_attestation.py new file mode 100644 index 000000000..eb2b07c1e --- /dev/null +++ b/xrpl/models/transactions/xchain_add_attestation.py @@ -0,0 +1,127 @@ +"""Model for a XChainAddAttestation transaction type.""" + +from __future__ import annotations + +from dataclasses import dataclass, field +from typing import Any, Dict, List, Literal, Optional, Type, Union + +from xrpl.models.amounts import Amount +from xrpl.models.base_model import BaseModel +from xrpl.models.required import REQUIRED +from xrpl.models.transactions.transaction import Transaction +from xrpl.models.transactions.types import TransactionType +from xrpl.models.utils import require_kwargs_on_init +from xrpl.models.xchain_bridge import XChainBridge + + +@require_kwargs_on_init +@dataclass(frozen=True) +class XChainClaimAttestationBatchElement(BaseModel): + """Represents a single claim attestation.""" + + account: str = REQUIRED # type: ignore + + amount: Amount = REQUIRED # type: ignore + + attestation_reward_account: str = REQUIRED # type: ignore + + destination: str = REQUIRED # type: ignore + + public_key: str = REQUIRED # type: ignore + + signature: str = REQUIRED # type: ignore + + was_locking_chain_send: Union[Literal[0, 1]] = REQUIRED # type: ignore + + xchain_claim_id: str = REQUIRED # type: ignore + + @classmethod + def is_dict_of_model( + cls: Type[XChainClaimAttestationBatchElement], dictionary: Dict[str, Any] + ) -> bool: + """ + Returns True if the input dictionary was derived by the `to_dict` + method of an instance of this class. In other words, True if this is + a dictionary representation of an instance of this class. + + NOTE: does not account for model inheritance, IE will only return True + if dictionary represents an instance of this class, but not if + dictionary represents an instance of a subclass of this class. + + Args: + dictionary: The dictionary to check. + + Returns: + True if dictionary is a dict representation of an instance of this + class. + """ + return ( + isinstance(dictionary, dict) + and "xchain_claim_attestation_batch_element" in dictionary + and super().is_dict_of_model( + dictionary["xchain_claim_attestation_batch_element"] + ) + ) + + @classmethod + def from_dict( + cls: Type[XChainClaimAttestationBatchElement], value: Dict[str, Any] + ) -> XChainClaimAttestationBatchElement: + """ + Construct a new XChainClaimAttestationBatchElement from a dictionary of + parameters. + + Args: + value: The value to construct the XChainClaimAttestationBatchElement from. + + Returns: + A new XChainClaimAttestationBatchElement object, constructed using the + given parameters. + """ + if len(value) == 1 and "xchain_claim_attestation_batch_element" in value: + return super(XChainClaimAttestationBatchElement, cls).from_dict( + value["xchain_claim_attestation_batch_element"] + ) + return super(XChainClaimAttestationBatchElement, cls).from_dict(value) + + def to_dict(self: XChainClaimAttestationBatchElement) -> Dict[str, Any]: + """ + Returns the dictionary representation of a XChainClaimAttestationBatchElement. + + Returns: + The dictionary representation of a XChainClaimAttestationBatchElement. + """ + return {"xchain_claim_attestation_batch_element": super().to_dict()} + + +@require_kwargs_on_init +@dataclass(frozen=True) +class XChainAttestationBatch(BaseModel): + """Represents a set of attestations from a single witness server.""" + + xchain_bridge: XChainBridge = REQUIRED # type: ignore + + xchain_claim_attestation_batch: List[ + XChainClaimAttestationBatchElement + ] = REQUIRED # type: ignore + + xchain_create_account_attestation_batch: List[ + XChainClaimAttestationBatchElement + ] = REQUIRED # type: ignore + + +@require_kwargs_on_init +@dataclass(frozen=True) +class XChainAddAttestation(Transaction): + """Represents a XChainAddAttestation transaction.""" + + xchain_bridge: XChainBridge = REQUIRED # type: ignore + + signature_reward: Amount = REQUIRED # type: ignore + + min_account_create_amount: Optional[Amount] = None + + transaction_type: TransactionType = field( + default=TransactionType.XCHAIN_ADD_ATTESTATION, + init=False, + ) From a7a45fcc0755421a9044455d072ad0c07252f8fd Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Mon, 18 Jul 2022 16:03:56 +0100 Subject: [PATCH 017/111] fix import --- xrpl/models/transactions/xchain_add_attestation.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xrpl/models/transactions/xchain_add_attestation.py b/xrpl/models/transactions/xchain_add_attestation.py index eb2b07c1e..c3947b214 100644 --- a/xrpl/models/transactions/xchain_add_attestation.py +++ b/xrpl/models/transactions/xchain_add_attestation.py @@ -3,7 +3,9 @@ from __future__ import annotations from dataclasses import dataclass, field -from typing import Any, Dict, List, Literal, Optional, Type, Union +from typing import Any, Dict, List, Optional, Type, Union + +from typing_extensions import Literal from xrpl.models.amounts import Amount from xrpl.models.base_model import BaseModel From 4c5c9afbbf137ecff7f1950d8939f57c37343525 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Tue, 19 Jul 2022 13:55:29 +0100 Subject: [PATCH 018/111] rename file --- xrpl/core/binarycodec/types/__init__.py | 4 +--- ...claim_attestation_batch.py => xchain_attestation_batch.py} | 0 2 files changed, 1 insertion(+), 3 deletions(-) rename xrpl/core/binarycodec/types/{xchain_claim_attestation_batch.py => xchain_attestation_batch.py} (100%) diff --git a/xrpl/core/binarycodec/types/__init__.py b/xrpl/core/binarycodec/types/__init__.py index 2b7981bc7..5052b9b15 100644 --- a/xrpl/core/binarycodec/types/__init__.py +++ b/xrpl/core/binarycodec/types/__init__.py @@ -17,10 +17,8 @@ from xrpl.core.binarycodec.types.uint32 import UInt32 from xrpl.core.binarycodec.types.uint64 import UInt64 from xrpl.core.binarycodec.types.vector256 import Vector256 +from xrpl.core.binarycodec.types.xchain_attestation_batch import XChainAttestationBatch from xrpl.core.binarycodec.types.xchain_bridge import XChainBridge -from xrpl.core.binarycodec.types.xchain_claim_attestation_batch import ( - XChainAttestationBatch, -) __all__ = [ "AccountID", diff --git a/xrpl/core/binarycodec/types/xchain_claim_attestation_batch.py b/xrpl/core/binarycodec/types/xchain_attestation_batch.py similarity index 100% rename from xrpl/core/binarycodec/types/xchain_claim_attestation_batch.py rename to xrpl/core/binarycodec/types/xchain_attestation_batch.py From 729b20a53c6e75a6a08a67bdb322946c3a3be6d1 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Fri, 29 Jul 2022 23:29:28 +0200 Subject: [PATCH 019/111] fix existing tests w/updated rippled, add AccountCreate test --- .../fixtures/data/codec-fixtures.json | 51 +++++++++++++------ tests/unit/core/binarycodec/test_main.py | 2 +- .../binarycodec/definitions/definitions.json | 49 +++++++++++------- 3 files changed, 68 insertions(+), 34 deletions(-) diff --git a/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json b/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json index 22f6aebea..e7b7be07a 100644 --- a/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json +++ b/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json @@ -4451,9 +4451,9 @@ } }, { - "binary": "12001E2200000000240000000168400000000000000A601540000000000003E86016400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02074463044022044798D0E4310C7E79B2929308E765F0C29B2D2A1DB4FDF0D7A62DAB39A4874F402207DC871A0E0049078ECB98EAD1E0B78DAD17F4E3E6DF4AB2E5F6DAC9451A5630A8114AF80285F637EE4AF3C20378F9DFB12511ACB8D27011B14AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", + "binary": "12001E2200000000240000000168400000000000000A601540000000000003E86016400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020744630440220101BCA4B5B5A37C6F44480F9A34752C9AA8B2CDF5AD47E3CB424DEDC21C06DB702206EEB257E82A89B1F46A0A2C7F070B0BD181D980FF86FE4269E369F6FC7A270918114B5F762798A53D543A014CAF8B297CFF8F2F937E8011A14AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", "json": { - "Account": "rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", + "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "XChainBridge": { "LockingChainDoor": "rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", "LockingChainIssue": "XRP", @@ -4467,13 +4467,13 @@ "SignatureReward": "1000", "SigningPubKey": "0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020", "TransactionType": "XChainCreateBridge", - "TxnSignature": "3044022044798D0E4310C7E79B2929308E765F0C29B2D2A1DB4FDF0D7A62DAB39A4874F402207DC871A0E0049078ECB98EAD1E0B78DAD17F4E3E6DF4AB2E5F6DAC9451A5630A" + "TxnSignature": "30440220101BCA4B5B5A37C6F44480F9A34752C9AA8B2CDF5AD47E3CB424DEDC21C06DB702206EEB257E82A89B1F46A0A2C7F070B0BD181D980FF86FE4269E369F6FC7A27091" } }, { - "binary": "12001F2280000000240000000168400000000000000A6015400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD0207446304402203858DCC266B53EDFDF16359AF483323BF4DF7176CD0EDCCC253EF5556C9D131B0220755FE28874AA927C9B41D4C7D35D88BCA4B38B5B8E2F87D21B738F087F32B3988114550FC62003E785DC231A1058A05E56E3F09CF4E6801214AF80285F637EE4AF3C20378F9DFB12511ACB8D27011B14AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", + "binary": "12001F2280000000240000000168400000000000000A6015400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020744630440220247B20A1B9C48E21A374CB9B3E1FE2A7C528151868DF8D307E9FBE15237E531A02207C20C092DDCC525E583EF4AB7CB91E862A6DED19426997D3F0A2C84E2BE8C5DD8114B5F762798A53D543A014CAF8B297CFF8F2F937E8801214AF80285F637EE4AF3C20378F9DFB12511ACB8D27011A14AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", "json": { - "Account": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", + "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "XChainBridge": { "LockingChainDoor": "rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", "LockingChainIssue": "XRP", @@ -4487,13 +4487,13 @@ "SignatureReward": "10000", "SigningPubKey": "0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020", "TransactionType": "XChainCreateClaimID", - "TxnSignature": "304402203858DCC266B53EDFDF16359AF483323BF4DF7176CD0EDCCC253EF5556C9D131B0220755FE28874AA927C9B41D4C7D35D88BCA4B38B5B8E2F87D21B738F087F32B398" + "TxnSignature": "30440220247B20A1B9C48E21A374CB9B3E1FE2A7C528151868DF8D307E9FBE15237E531A02207C20C092DDCC525E583EF4AB7CB91E862A6DED19426997D3F0A2C84E2BE8C5DD" } }, { - "binary": "120020228000000024000000013014000000000000000161400000000000271068400000000000000A73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD0207446304402201B39894271B8512FE9C6E146587F695BC0E2AF19EC47570054FAA8B95A2CBC0C02201A9A63FEACD2416BC6E49EA45143927C474CC2CC85AA135A46A183423E76615A8114550FC62003E785DC231A1058A05E56E3F09CF4E6011B14AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", + "binary": "120020228000000024000000013014000000000000000161400000000000271068400000000000000A73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02074453043021F177323F0D93612C82A4393A99B23905A7E675753FD80C52997AFAB13F5F9D002203BFFAF457E90BDA65AABE8F8762BD96162FAD98A0C030CCD69B06EE9B12BBFFE8114B5F762798A53D543A014CAF8B297CFF8F2F937E8011A14AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", "json": { - "Account": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", + "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "Amount": "10000", "XChainBridge": { "LockingChainDoor": "rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", @@ -4506,14 +4506,14 @@ "Sequence": 1, "SigningPubKey": "0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020", "TransactionType": "XChainCommit", - "TxnSignature": "304402201B39894271B8512FE9C6E146587F695BC0E2AF19EC47570054FAA8B95A2CBC0C02201A9A63FEACD2416BC6E49EA45143927C474CC2CC85AA135A46A183423E76615A", + "TxnSignature": "3043021F177323F0D93612C82A4393A99B23905A7E675753FD80C52997AFAB13F5F9D002203BFFAF457E90BDA65AABE8F8762BD96162FAD98A0C030CCD69B06EE9B12BBFFE", "XChainClaimID": "0000000000000001" } }, { - "binary": "120021228000000024000000013014000000000000000161400000000000271068400000000000000A73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02074473045022100CA14E5FB5F30FC698119ED7E7D8F291E48A21693190A01AD89E140035476EE9D02206A642A396246C726739195D5D2CCC0635E1A67EDB84DEFBD54D42F7809F45F8B8114550FC62003E785DC231A1058A05E56E3F09CF4E68314550FC62003E785DC231A1058A05E56E3F09CF4E6011B14AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", + "binary": "120021228000000024000000013014000000000000000161400000000000271068400000000000000A73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020744630440220445F7469FDA401787D9EE8A9B6E24DFF81E94F4C09FD311D2C0A58FCC02C684A022029E2EF34A5EA35F50D5BB57AC6320AD3AE12C13C8D1379B255A486D72CED142E8114B5F762798A53D543A014CAF8B297CFF8F2F937E88314550FC62003E785DC231A1058A05E56E3F09CF4E6011A14AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", "json": { - "Account": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", + "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "Amount": "10000", "XChainBridge": { "LockingChainDoor": "rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", @@ -4527,20 +4527,20 @@ "Sequence": 1, "SigningPubKey": "0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020", "TransactionType": "XChainClaim", - "TxnSignature": "3045022100CA14E5FB5F30FC698119ED7E7D8F291E48A21693190A01AD89E140035476EE9D02206A642A396246C726739195D5D2CCC0635E1A67EDB84DEFBD54D42F7809F45F8B", + "TxnSignature": "30440220445F7469FDA401787D9EE8A9B6E24DFF81E94F4C09FD311D2C0A58FCC02C684A022029E2EF34A5EA35F50D5BB57AC6320AD3AE12C13C8D1379B255A486D72CED142E", "XChainClaimID": "0000000000000001" } }, { - "binary": "1200242280000000240000000468400000000000000A73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02074473045022100DCAC6A97BC4AA1379504FD5293FDFA46A4C216DDC13F3950F9692E0F803862A602206583360A60961E2988041E7E8589037A233771DCFB84E7A4710940A878EAFD7581142F3CC37C1D5616B3BBF1AABC49F6BFF46A920087011C14C48CAD01682D7A86296EF14523074D4852C02EA9000000000000000000000000000000000000000014CC86E58C9B58D4CF71CB8C1B41F21BB290CE13D40000000000000000000000000000000000000000E01C30140000000000000000614000000005F5E100712103DAB289CA36FF377F3F4304C7A7203FDE5EDCBFC209F430F6A4355361425526D0760361626381142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314621D345F8F094A085132431C69C89EC05D212CC28014142F3CC37C1D5616B3BBF1AABC49F6BFF46A92008700101301E1F1F1", + "binary": "1200242280000000240000000468400000000000000A73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02074473045022100A6A8CA05B2B6CB60E0FD645A4DA0314D46D79D9FA3D63307FC997357366151B202202266CC23E2CA827905F37F78F54AD435F73A3B704EDD634B89201E23625CE2E28114B5F762798A53D543A014CAF8B297CFF8F2F937E8011B14C48CAD01682D7A86296EF14523074D4852C02EA9000000000000000000000000000000000000000014CC86E58C9B58D4CF71CB8C1B41F21BB290CE13D40000000000000000000000000000000000000000E01C30140000000000000000614000000005F5E100712103DAB289CA36FF377F3F4304C7A7203FDE5EDCBFC209F430F6A4355361425526D0760361626381142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314621D345F8F094A085132431C69C89EC05D212CC28014142F3CC37C1D5616B3BBF1AABC49F6BFF46A92008700101301E1F1F1", "json": { - "Account" : "rnJmYAiqEVngtnb5ckRroXLtCbWC7CRUBx", + "Account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "Fee" : "10", "Flags" : 2147483648, "Sequence" : 4, "SigningPubKey" : "0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020", "TransactionType" : "XChainAddAttestation", - "TxnSignature" : "3045022100DCAC6A97BC4AA1379504FD5293FDFA46A4C216DDC13F3950F9692E0F803862A602206583360A60961E2988041E7E8589037A233771DCFB84E7A4710940A878EAFD75", + "TxnSignature" : "3045022100A6A8CA05B2B6CB60E0FD645A4DA0314D46D79D9FA3D63307FC997357366151B202202266CC23E2CA827905F37F78F54AD435F73A3B704EDD634B89201E23625CE2E2", "XChainAttestationBatch" : { "XChainBridge" : { "IssuingChainDoor" : "rKeSSvHvaMZJp9ykaxutVwkhZgWuWMLnQt", @@ -4565,6 +4565,27 @@ "XChainCreateAccountAttestationBatch" : [] } } + }, + { + "binary": "120022228000000024000000016140000000000F424068400000000000000A6015400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD0207446304402202984DDE7F0B566F081F7953D7212BF031ACBF8860FE114102E9512C4C8768C77022070113F4630B1DC3045E4A98DDD648CEBC31B12774F7B44A1B8123CD2C9F5CF188114B5F762798A53D543A014CAF8B297CFF8F2F937E88314AF80285F637EE4AF3C20378F9DFB12511ACB8D27011A14AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", + "json": { + "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", + "XChainBridge": { + "LockingChainDoor": "rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", + "LockingChainIssue": "XRP", + "IssuingChainDoor": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", + "IssuingChainIssue": "XRP" + }, + "Amount": "1000000", + "Fee": "10", + "Flags": 2147483648, + "Destination": "rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", + "Sequence": 1, + "SignatureReward": "10000", + "SigningPubKey": "0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020", + "TransactionType": "SidechainXChainAccountCreate", + "TxnSignature": "304402202984DDE7F0B566F081F7953D7212BF031ACBF8860FE114102E9512C4C8768C77022070113F4630B1DC3045E4A98DDD648CEBC31B12774F7B44A1B8123CD2C9F5CF18" + } } ], "ledgerData": [{ diff --git a/tests/unit/core/binarycodec/test_main.py b/tests/unit/core/binarycodec/test_main.py index ac32822e2..6c6ead083 100644 --- a/tests/unit/core/binarycodec/test_main.py +++ b/tests/unit/core/binarycodec/test_main.py @@ -337,8 +337,8 @@ def _check_binary_and_json(self, test): test_binary = test["binary"] test_json = test["json"] with self.subTest(test_binary=test_binary, test_json=test_json): - self.assertEqual(encode(test_json), test_binary) self.assertEqual(decode(test_binary), test_json) + self.assertEqual(encode(test_json), test_binary) def _check_xaddress_jsons(self, test): x_json = test["xjson"] diff --git a/xrpl/core/binarycodec/definitions/definitions.json b/xrpl/core/binarycodec/definitions/definitions.json index 02ebd23d2..28d3e98e0 100644 --- a/xrpl/core/binarycodec/definitions/definitions.json +++ b/xrpl/core/binarycodec/definitions/definitions.json @@ -21,11 +21,10 @@ "UInt192": 21, "UInt384": 22, "UInt512": 23, - "XChainAttestations": 24, - "XChainClaimProof": 25, - "Issue": 26, - "XChainBridge": 27, - "XChainAttestationBatch": 28, + "XChainClaimProof": 24, + "Issue": 25, + "XChainBridge": 26, + "XChainAttestationBatch": 27, "Transaction": 10001, "LedgerEntry": 10002, "Validation": 10003, @@ -43,6 +42,7 @@ "LedgerHashes": 104, "Amendments": 102, "XChainClaimID": 113, + "XChainCreateAccountClaimID": 116, "FeeSettings": 115, "Escrow": 117, "PayChannel": 120, @@ -1958,16 +1958,6 @@ "type": "XChainClaimProof" } ], - [ - "XChainAttestations", - { - "nth": 1, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "XChainAttestations" - } - ], [ "LockingChainIssue", { @@ -2219,7 +2209,7 @@ } ], [ - "XChainProofSig", + "XChainClaimProofSig", { "nth": 25, "isVLEncoded": false, @@ -2229,7 +2219,7 @@ } ], [ - "XChainAttestationSigs", + "XChainCreateAccountProofSig", { "nth": 26, "isVLEncoded": false, @@ -2447,6 +2437,26 @@ "isSigningField": true, "type": "STArray" } + ], + [ + "XChainClaimAttestations", + { + "nth": 24, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "STArray" + } + ], + [ + "XChainCreateAccountAttestations", + { + "nth": 25, + "isVLEncoded": false, + "isSerialized": true, + "isSigningField": true, + "type": "STArray" + } ] ], "TRANSACTION_RESULTS": { @@ -2603,7 +2613,10 @@ "tecXCHAIN_CLAIM_WRONG_CHAIN": 169, "tecXCHAIN_REWARD_MISMATCH": 170, "tecXCHAIN_NO_SIGNERS_LIST": 171, - "tecXCHAIN_SENDING_ACCOUNT_MISMATCH": 172 + "tecXCHAIN_SENDING_ACCOUNT_MISMATCH": 172, + "tecXCHAIN_INSUFF_CREATE_AMOUNT": 173, + "tecXCHAIN_ACCOUNT_CREATE_PAST": 174, + "tecXCHAIN_ACCOUNT_CREATE_TOO_MANY": 175 }, "TRANSACTION_TYPES": { "Invalid": -1, From 15e298a5c2f0f2781307c088609e025c1346a3af Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Sun, 31 Jul 2022 15:31:37 +0200 Subject: [PATCH 020/111] add CreateAccount AddAttestation test --- .../fixtures/data/codec-fixtures.json | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json b/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json index e7b7be07a..f645044ff 100644 --- a/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json +++ b/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json @@ -4586,6 +4586,94 @@ "TransactionType": "SidechainXChainAccountCreate", "TxnSignature": "304402202984DDE7F0B566F081F7953D7212BF031ACBF8860FE114102E9512C4C8768C77022070113F4630B1DC3045E4A98DDD648CEBC31B12774F7B44A1B8123CD2C9F5CF18" } + }, + { + "binary": "1200242280000000240000000168400000000000000A73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD0207447304502210098F47661D8EF89CC2DFF3EAA92AF3843CEFD398EAD1E7496FAEAC269DE688FB80220143EBE519FC1936E884B1AFA047D4CB7CD2E2A28F0B27EC982D1BB3E63FC95358114B5F762798A53D543A014CAF8B297CFF8F2F937E8011B14C48CAD01682D7A86296EF14523074D4852C02EA9000000000000000000000000000000000000000014CC86E58C9B58D4CF71CB8C1B41F21BB290CE13D40000000000000000000000000000000000000000F1E01D3015000000000000000161400000003B9ACA00601540000000000F4240712103ADB44CA8E56F78A0096825E5667C450ABD5C24C34E027BC1AAF7E5BD114CB5B576463044022036C8B90F85E8073C465F00625248A72D4714600F98EBBADBAD3B7ED226109A3A02204C5A0AE12D169CF790F66541F3DB59C289E0D99CA7511FDFE352BB601F667A2681142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801414A482A071D77722C2B683FFE01DC30134035E8E7200101301E1E01D3015000000000000000161400000003B9ACA00601540000000000F4240712102A14E886B3C3579FBAE3139F29728B903E6F4295AEE92160C8480695524D66A157646304402200C3F5EEE2D7DCB609EE8558258E6AAF1EF823133C2B7C716E0DC9AAD2110F08D0220180E9F285CB2F78E362D37E947C000A8ED60A4BD8EFF21F74C5E529E1A8870ED81142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801414A482A071D77722C2B683FFE01DC30134035E8E7200101301E1E01D3015000000000000000161400000003B9ACA00601540000000000F4240712102F7390DCF3352060847B81666EBAC79D52DEA2443BDF58439F75397C45334E2DC764730450221008E31CFF0198F09CBA8610A946C23E170A3F11BCB8FC95D0D56C7B79A126D97D102203F4E952C449F2F01C4AF67FC37772A0D4459D770387CC11DBD5464FAB218542881142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801414A482A071D77722C2B683FFE01DC30134035E8E7200101301E1E01D3015000000000000000161400000003B9ACA00601540000000000F4240712102498BD8CD9CA6A4BA567A2ECFA163F118AFD30511CBBA71429C2EC2F74D76059276473045022100F4E2D672F456CB9929EF01766AB72B42C71314A181232098563B8666E4EEA49C02203F936877E9DCC8FF5F7713579233985DF3DADB155F2BDA78FE3A4321373F370E81142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801414A482A071D77722C2B683FFE01DC30134035E8E7200101301E1E01D3015000000000000000161400000003B9ACA00601540000000000F4240712103219642288DEE8A3AA8FEA1F7DAE9ED4D9A9F0EADA1E2DE3DB56DD9598D9AD81776473045022100D1BAFA57F40E16485310698B7B0BD0D4650E18782C4D65787A393CBB6D659EB802204EA28303089CCCD1463866A1BA0493A9B135AEA1EDFC8DD69A1A247DD9FEDB2181142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801414A482A071D77722C2B683FFE01DC30134035E8E7200101301E1F1", + "json": { + "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", + "Fee": "10", + "Flags": 2147483648, + "Sequence": 1, + "SigningPubKey": "0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020", + "TransactionType": "XChainAddAttestation", + "TxnSignature": "304502210098F47661D8EF89CC2DFF3EAA92AF3843CEFD398EAD1E7496FAEAC269DE688FB80220143EBE519FC1936E884B1AFA047D4CB7CD2E2A28F0B27EC982D1BB3E63FC9535", + "XChainAttestationBatch": { + "XChainBridge": { + "IssuingChainDoor": "rKeSSvHvaMZJp9ykaxutVwkhZgWuWMLnQt", + "IssuingChainIssue": "XRP", + "LockingChainDoor": "rJvExveLEL4jNDEeLKCVdxaSCN9cEBnEQC", + "LockingChainIssue": "XRP" + }, + "XChainClaimAttestationBatch": [], + "XChainCreateAccountAttestationBatch": [ + { + "XChainCreateAccountAttestationBatchElement": { + "Account": "rnJmYAiqEVngtnb5ckRroXLtCbWC7CRUBx", + "Amount": "1000000000", + "AttestationRewardAccount": "rEziJZmeZzsJvGVUmpUTey7qxQLKYxaK9f", + "Destination": "rKT9gDkaedAosiHyHZTjyZs2HvXpzuiGmC", + "PublicKey": "03ADB44CA8E56F78A0096825E5667C450ABD5C24C34E027BC1AAF7E5BD114CB5B5", + "Signature": "3044022036C8B90F85E8073C465F00625248A72D4714600F98EBBADBAD3B7ED226109A3A02204C5A0AE12D169CF790F66541F3DB59C289E0D99CA7511FDFE352BB601F667A26", + "SignatureReward": "1000000", + "WasLockingChainSend": 1, + "XChainAccountCreateCount": "0000000000000001" + } + }, + { + "XChainCreateAccountAttestationBatchElement": { + "Account": "rnJmYAiqEVngtnb5ckRroXLtCbWC7CRUBx", + "Amount": "1000000000", + "AttestationRewardAccount": "rEziJZmeZzsJvGVUmpUTey7qxQLKYxaK9f", + "Destination": "rKT9gDkaedAosiHyHZTjyZs2HvXpzuiGmC", + "PublicKey": "02A14E886B3C3579FBAE3139F29728B903E6F4295AEE92160C8480695524D66A15", + "Signature": "304402200C3F5EEE2D7DCB609EE8558258E6AAF1EF823133C2B7C716E0DC9AAD2110F08D0220180E9F285CB2F78E362D37E947C000A8ED60A4BD8EFF21F74C5E529E1A8870ED", + "SignatureReward": "1000000", + "WasLockingChainSend": 1, + "XChainAccountCreateCount": "0000000000000001" + } + }, + { + "XChainCreateAccountAttestationBatchElement": { + "Account": "rnJmYAiqEVngtnb5ckRroXLtCbWC7CRUBx", + "Amount": "1000000000", + "AttestationRewardAccount": "rEziJZmeZzsJvGVUmpUTey7qxQLKYxaK9f", + "Destination": "rKT9gDkaedAosiHyHZTjyZs2HvXpzuiGmC", + "PublicKey": "02F7390DCF3352060847B81666EBAC79D52DEA2443BDF58439F75397C45334E2DC", + "Signature": "30450221008E31CFF0198F09CBA8610A946C23E170A3F11BCB8FC95D0D56C7B79A126D97D102203F4E952C449F2F01C4AF67FC37772A0D4459D770387CC11DBD5464FAB2185428", + "SignatureReward": "1000000", + "WasLockingChainSend": 1, + "XChainAccountCreateCount": "0000000000000001" + } + }, + { + "XChainCreateAccountAttestationBatchElement": { + "Account": "rnJmYAiqEVngtnb5ckRroXLtCbWC7CRUBx", + "Amount": "1000000000", + "AttestationRewardAccount": "rEziJZmeZzsJvGVUmpUTey7qxQLKYxaK9f", + "Destination": "rKT9gDkaedAosiHyHZTjyZs2HvXpzuiGmC", + "PublicKey": "02498BD8CD9CA6A4BA567A2ECFA163F118AFD30511CBBA71429C2EC2F74D760592", + "Signature": "3045022100F4E2D672F456CB9929EF01766AB72B42C71314A181232098563B8666E4EEA49C02203F936877E9DCC8FF5F7713579233985DF3DADB155F2BDA78FE3A4321373F370E", + "SignatureReward": "1000000", + "WasLockingChainSend": 1, + "XChainAccountCreateCount": "0000000000000001" + } + }, + { + "XChainCreateAccountAttestationBatchElement": { + "Account": "rnJmYAiqEVngtnb5ckRroXLtCbWC7CRUBx", + "Amount": "1000000000", + "AttestationRewardAccount": "rEziJZmeZzsJvGVUmpUTey7qxQLKYxaK9f", + "Destination": "rKT9gDkaedAosiHyHZTjyZs2HvXpzuiGmC", + "PublicKey": "03219642288DEE8A3AA8FEA1F7DAE9ED4D9A9F0EADA1E2DE3DB56DD9598D9AD817", + "Signature": "3045022100D1BAFA57F40E16485310698B7B0BD0D4650E18782C4D65787A393CBB6D659EB802204EA28303089CCCD1463866A1BA0493A9B135AEA1EDFC8DD69A1A247DD9FEDB21", + "SignatureReward": "1000000", + "WasLockingChainSend": 1, + "XChainAccountCreateCount": "0000000000000001" + } + } + ] + } + } } ], "ledgerData": [{ From c35447bd36abda79c33d20a8907d8e7a7c3fc2ab Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Sun, 31 Jul 2022 15:57:45 +0200 Subject: [PATCH 021/111] add/update models --- .../sidechain_xchain_account_create.py | 29 ++++++ .../transactions/types/transaction_type.py | 2 +- .../transactions/xchain_add_attestation.py | 89 ++++++++++++++++++- 3 files changed, 118 insertions(+), 2 deletions(-) create mode 100644 xrpl/models/transactions/sidechain_xchain_account_create.py diff --git a/xrpl/models/transactions/sidechain_xchain_account_create.py b/xrpl/models/transactions/sidechain_xchain_account_create.py new file mode 100644 index 000000000..bbfe2807f --- /dev/null +++ b/xrpl/models/transactions/sidechain_xchain_account_create.py @@ -0,0 +1,29 @@ +"""Model for a SidechainXChainAccountCreate transaction type.""" + +from dataclasses import dataclass, field + +from xrpl.models.amounts import Amount +from xrpl.models.required import REQUIRED +from xrpl.models.transactions.transaction import Transaction +from xrpl.models.transactions.types import TransactionType +from xrpl.models.utils import require_kwargs_on_init +from xrpl.models.xchain_bridge import XChainBridge + + +@require_kwargs_on_init +@dataclass(frozen=True) +class SidechainXChainAccountCreate(Transaction): + """Represents a SidechainXChainAccountCreate transaction.""" + + xchain_bridge: XChainBridge = REQUIRED # type: ignore + + signature_reward: Amount = REQUIRED # type: ignore + + destination: str = REQUIRED # type: ignore + + amount: Amount = REQUIRED # type: ignore + + transaction_type: TransactionType = field( + default=TransactionType.SIDECHAIN_XCHAIN_ACCOUNT_CREATE, + init=False, + ) diff --git a/xrpl/models/transactions/types/transaction_type.py b/xrpl/models/transactions/types/transaction_type.py index 5d5c2c2f2..2ed6ca886 100644 --- a/xrpl/models/transactions/types/transaction_type.py +++ b/xrpl/models/transactions/types/transaction_type.py @@ -33,7 +33,7 @@ class TransactionType(str, Enum): XCHAIN_ADD_ATTESTATION = "XChainAddAttestation" XCHAIN_CLAIM = "XChainClaim" XCHAIN_COMMIT = "XChainCommit" - # XCHAIN_CREATE_ACCOUNT_COMMIT = "XChainCreateAccountCommit" + SIDECHAIN_XCHAIN_ACCOUNT_CREATE = "SidechainXChainAccountCreate" XCHAIN_CREATE_BRIDGE = "XChainCreateBridge" XCHAIN_CREATE_CLAIM_ID = "XChainCreateClaimID" # XCHAIN_MODIFY_BRIDGE = "XChainModifyBridge" diff --git a/xrpl/models/transactions/xchain_add_attestation.py b/xrpl/models/transactions/xchain_add_attestation.py index c3947b214..c6f072bef 100644 --- a/xrpl/models/transactions/xchain_add_attestation.py +++ b/xrpl/models/transactions/xchain_add_attestation.py @@ -96,6 +96,93 @@ def to_dict(self: XChainClaimAttestationBatchElement) -> Dict[str, Any]: return {"xchain_claim_attestation_batch_element": super().to_dict()} +@require_kwargs_on_init +@dataclass(frozen=True) +class XChainCreateAccountAttestationBatchElement(BaseModel): + """Represents a single account creation attestation.""" + + account: str = REQUIRED # type: ignore + + amount: Amount = REQUIRED # type: ignore + + attestation_reward_account: str = REQUIRED # type: ignore + + destination: str = REQUIRED # type: ignore + + public_key: str = REQUIRED # type: ignore + + signature: str = REQUIRED # type: ignore + + was_locking_chain_send: Union[Literal[0, 1]] = REQUIRED # type: ignore + + xchain_account_create_count: str = REQUIRED # type: ignore + + @classmethod + def is_dict_of_model( + cls: Type[XChainCreateAccountAttestationBatchElement], + dictionary: Dict[str, Any], + ) -> bool: + """ + Returns True if the input dictionary was derived by the `to_dict` + method of an instance of this class. In other words, True if this is + a dictionary representation of an instance of this class. + + NOTE: does not account for model inheritance, IE will only return True + if dictionary represents an instance of this class, but not if + dictionary represents an instance of a subclass of this class. + + Args: + dictionary: The dictionary to check. + + Returns: + True if dictionary is a dict representation of an instance of this + class. + """ + return ( + isinstance(dictionary, dict) + and "xchain_create_account_attestation_batch_element" in dictionary + and super().is_dict_of_model( + dictionary["xchain_create_account_attestation_batch_element"] + ) + ) + + @classmethod + def from_dict( + cls: Type[XChainCreateAccountAttestationBatchElement], value: Dict[str, Any] + ) -> XChainCreateAccountAttestationBatchElement: + """ + Construct a new XChainCreateAccountAttestationBatchElement from a dictionary of + parameters. + + Args: + value: The value to construct the + XChainCreateAccountAttestationBatchElement from. + + Returns: + A new XChainCreateAccountAttestationBatchElement object, constructed using + the given parameters. + """ + if ( + len(value) == 1 + and "xchain_create_account_attestation_batch_element" in value + ): + return super(XChainCreateAccountAttestationBatchElement, cls).from_dict( + value["xchain_create_account_attestation_batch_element"] + ) + return super(XChainCreateAccountAttestationBatchElement, cls).from_dict(value) + + def to_dict(self: XChainCreateAccountAttestationBatchElement) -> Dict[str, Any]: + """ + Returns the dictionary representation of a + XChainCreateAccountAttestationBatchElement. + + Returns: + The dictionary representation of a + XChainCreateAccountAttestationBatchElement. + """ + return {"xchain_create_account_attestation_batch_element": super().to_dict()} + + @require_kwargs_on_init @dataclass(frozen=True) class XChainAttestationBatch(BaseModel): @@ -108,7 +195,7 @@ class XChainAttestationBatch(BaseModel): ] = REQUIRED # type: ignore xchain_create_account_attestation_batch: List[ - XChainClaimAttestationBatchElement + XChainCreateAccountAttestationBatchElement ] = REQUIRED # type: ignore From 90dc8ed82c501fbba3b4f5e3d6ee3193d58445a6 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Sun, 31 Jul 2022 16:00:43 +0200 Subject: [PATCH 022/111] export new tx --- xrpl/models/transactions/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xrpl/models/transactions/__init__.py b/xrpl/models/transactions/__init__.py index 0c58dcc4f..2c9d1da0c 100644 --- a/xrpl/models/transactions/__init__.py +++ b/xrpl/models/transactions/__init__.py @@ -45,6 +45,9 @@ from xrpl.models.transactions.payment_channel_create import PaymentChannelCreate from xrpl.models.transactions.payment_channel_fund import PaymentChannelFund from xrpl.models.transactions.set_regular_key import SetRegularKey +from xrpl.models.transactions.sidechain_xchain_account_create import ( + SidechainXChainAccountCreate, +) from xrpl.models.transactions.signer_list_set import SignerEntry, SignerListSet from xrpl.models.transactions.ticket_create import TicketCreate from xrpl.models.transactions.transaction import Memo, Signer, Transaction @@ -108,4 +111,5 @@ "XChainCommit", "XChainCreateBridge", "XChainCreateClaimID", + "SidechainXChainAccountCreate", ] From e21ed03888e93148315e393a06f9d8184544428b Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Tue, 2 Aug 2022 11:47:14 +0200 Subject: [PATCH 023/111] fix XChainCommit --- xrpl/models/transactions/xchain_commit.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xrpl/models/transactions/xchain_commit.py b/xrpl/models/transactions/xchain_commit.py index 4921a1e89..7d23ca870 100644 --- a/xrpl/models/transactions/xchain_commit.py +++ b/xrpl/models/transactions/xchain_commit.py @@ -1,7 +1,7 @@ """Model for a XChainCommit transaction type.""" from dataclasses import dataclass, field -from typing import Union +from typing import Optional, Union from xrpl.models.amounts import Amount from xrpl.models.required import REQUIRED @@ -22,6 +22,8 @@ class XChainCommit(Transaction): amount: Amount = REQUIRED # type: ignore + other_chain_destination: Optional[str] = None + transaction_type: TransactionType = field( default=TransactionType.XCHAIN_COMMIT, init=False, From bbb09c4b730a27b53bd04e8224608f7114c2ec06 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Tue, 2 Aug 2022 11:53:36 +0200 Subject: [PATCH 024/111] fix XChainAddAttestation --- xrpl/models/transactions/xchain_add_attestation.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/xrpl/models/transactions/xchain_add_attestation.py b/xrpl/models/transactions/xchain_add_attestation.py index c6f072bef..2589cf97c 100644 --- a/xrpl/models/transactions/xchain_add_attestation.py +++ b/xrpl/models/transactions/xchain_add_attestation.py @@ -3,7 +3,7 @@ from __future__ import annotations from dataclasses import dataclass, field -from typing import Any, Dict, List, Optional, Type, Union +from typing import Any, Dict, List, Type, Union from typing_extensions import Literal @@ -204,11 +204,7 @@ class XChainAttestationBatch(BaseModel): class XChainAddAttestation(Transaction): """Represents a XChainAddAttestation transaction.""" - xchain_bridge: XChainBridge = REQUIRED # type: ignore - - signature_reward: Amount = REQUIRED # type: ignore - - min_account_create_amount: Optional[Amount] = None + xchain_attestation_batch: XChainAttestationBatch = REQUIRED # type: ignore transaction_type: TransactionType = field( default=TransactionType.XCHAIN_ADD_ATTESTATION, From c34afedae6f308efec2bccc7fc04dcdd547b741d Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Tue, 2 Aug 2022 19:03:22 +0200 Subject: [PATCH 025/111] add XChainModifyBridge tx model --- .../transactions/types/transaction_type.py | 2 +- .../transactions/xchain_modify_bridge.py | 28 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 xrpl/models/transactions/xchain_modify_bridge.py diff --git a/xrpl/models/transactions/types/transaction_type.py b/xrpl/models/transactions/types/transaction_type.py index 2ed6ca886..13048e8b4 100644 --- a/xrpl/models/transactions/types/transaction_type.py +++ b/xrpl/models/transactions/types/transaction_type.py @@ -36,4 +36,4 @@ class TransactionType(str, Enum): SIDECHAIN_XCHAIN_ACCOUNT_CREATE = "SidechainXChainAccountCreate" XCHAIN_CREATE_BRIDGE = "XChainCreateBridge" XCHAIN_CREATE_CLAIM_ID = "XChainCreateClaimID" - # XCHAIN_MODIFY_BRIDGE = "XChainModifyBridge" + XCHAIN_MODIFY_BRIDGE = "XChainModifyBridge" diff --git a/xrpl/models/transactions/xchain_modify_bridge.py b/xrpl/models/transactions/xchain_modify_bridge.py new file mode 100644 index 000000000..a6faf9924 --- /dev/null +++ b/xrpl/models/transactions/xchain_modify_bridge.py @@ -0,0 +1,28 @@ +"""Model for a XChainModifyBridge transaction type.""" + +from dataclasses import dataclass, field +from typing import Optional + +from xrpl.models.amounts import Amount +from xrpl.models.required import REQUIRED +from xrpl.models.transactions.transaction import Transaction +from xrpl.models.transactions.types import TransactionType +from xrpl.models.utils import require_kwargs_on_init +from xrpl.models.xchain_bridge import XChainBridge + + +@require_kwargs_on_init +@dataclass(frozen=True) +class XChainModifyBridge(Transaction): + """Represents a XChainModifyBridge transaction.""" + + xchain_bridge: XChainBridge = REQUIRED # type: ignore + + signature_reward: Amount = REQUIRED # type: ignore + + min_account_create_amount: Optional[Amount] = None + + transaction_type: TransactionType = field( + default=TransactionType.XCHAIN_MODIFY_BRIDGE, + init=False, + ) From 1e36a2e806856e5f3cc77f9b59b0f89c2faf8e4f Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Tue, 2 Aug 2022 20:22:22 +0200 Subject: [PATCH 026/111] rename field --- xrpl/models/transactions/xchain_commit.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xrpl/models/transactions/xchain_commit.py b/xrpl/models/transactions/xchain_commit.py index 7d23ca870..ac8869a56 100644 --- a/xrpl/models/transactions/xchain_commit.py +++ b/xrpl/models/transactions/xchain_commit.py @@ -22,7 +22,7 @@ class XChainCommit(Transaction): amount: Amount = REQUIRED # type: ignore - other_chain_destination: Optional[str] = None + other_chain_account: Optional[str] = None transaction_type: TransactionType = field( default=TransactionType.XCHAIN_COMMIT, From a5b26a4b8d0c7144974d58362864f68f34e78f10 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Tue, 2 Aug 2022 20:40:18 +0200 Subject: [PATCH 027/111] actually export tx --- xrpl/models/transactions/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xrpl/models/transactions/__init__.py b/xrpl/models/transactions/__init__.py index 2c9d1da0c..c1d9d87ba 100644 --- a/xrpl/models/transactions/__init__.py +++ b/xrpl/models/transactions/__init__.py @@ -61,6 +61,7 @@ from xrpl.models.transactions.xchain_commit import XChainCommit from xrpl.models.transactions.xchain_create_bridge import XChainCreateBridge from xrpl.models.transactions.xchain_create_claim_id import XChainCreateClaimID +from xrpl.models.transactions.xchain_modify_bridge import XChainModifyBridge __all__ = [ "AccountDelete", @@ -111,5 +112,6 @@ "XChainCommit", "XChainCreateBridge", "XChainCreateClaimID", + "XChainModifyBridge", "SidechainXChainAccountCreate", ] From 8cfd6010b3782abcea0e7eda0c7edbaecf9399f3 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Wed, 3 Aug 2022 12:35:18 +0200 Subject: [PATCH 028/111] Update definitions.json --- xrpl/core/binarycodec/definitions/definitions.json | 1 + 1 file changed, 1 insertion(+) diff --git a/xrpl/core/binarycodec/definitions/definitions.json b/xrpl/core/binarycodec/definitions/definitions.json index 28d3e98e0..e96439fe0 100644 --- a/xrpl/core/binarycodec/definitions/definitions.json +++ b/xrpl/core/binarycodec/definitions/definitions.json @@ -2655,6 +2655,7 @@ "SidechainXChainAccountCreate": 34, "SidechainXChainAccountClaim": 35, "XChainAddAttestation": 36, + "XChainModifyBridge": 37, "EnableAmendment": 100, "SetFee": 101, "UNLModify": 102 From 48633207c085b8702c881b4a91bf08e5c1387235 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Wed, 3 Aug 2022 12:51:55 +0200 Subject: [PATCH 029/111] add XChainModifyBridge binary codec test --- .../fixtures/data/codec-fixtures.json | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json b/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json index f645044ff..29d3b7f1a 100644 --- a/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json +++ b/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json @@ -4470,6 +4470,26 @@ "TxnSignature": "30440220101BCA4B5B5A37C6F44480F9A34752C9AA8B2CDF5AD47E3CB424DEDC21C06DB702206EEB257E82A89B1F46A0A2C7F070B0BD181D980FF86FE4269E369F6FC7A27091" } }, + { + "binary": "1200252200000000240000000168400000000000000A601540000000000003E86016400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02074473045022100D2CABC1B0E0635A8EE2E6554F6D474C49BC292C995C5C9F83179F4A60634B04C02205D1DB569D9593136F2FBEA7140010C8F46794D653AFDBEA8D30B8750BA4805E58114B5F762798A53D543A014CAF8B297CFF8F2F937E8011A14AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", + "json": { + "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", + "XChainBridge": { + "LockingChainDoor": "rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", + "LockingChainIssue": "XRP", + "IssuingChainDoor": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", + "IssuingChainIssue": "XRP" + }, + "Fee": "10", + "Flags": 0, + "MinAccountCreateAmount": "10000", + "Sequence": 1, + "SignatureReward": "1000", + "SigningPubKey": "0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020", + "TransactionType": "XChainModifyBridge", + "TxnSignature": "3045022100D2CABC1B0E0635A8EE2E6554F6D474C49BC292C995C5C9F83179F4A60634B04C02205D1DB569D9593136F2FBEA7140010C8F46794D653AFDBEA8D30B8750BA4805E5" + } + }, { "binary": "12001F2280000000240000000168400000000000000A6015400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020744630440220247B20A1B9C48E21A374CB9B3E1FE2A7C528151868DF8D307E9FBE15237E531A02207C20C092DDCC525E583EF4AB7CB91E862A6DED19426997D3F0A2C84E2BE8C5DD8114B5F762798A53D543A014CAF8B297CFF8F2F937E8801214AF80285F637EE4AF3C20378F9DFB12511ACB8D27011A14AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", "json": { From 573faea775e93b522569d31f5766d3f2b6185115 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Wed, 3 Aug 2022 13:44:39 +0200 Subject: [PATCH 030/111] edit changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index edb0034cc..2d2a23b0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Created function alias to `safe_sign_and_autofill_transaction` called `autofill_and_sign` to reflect order of operations - Created function alias to `submit_transaction` called `submit` - Created function alias to `safe_sign_and_submit_transaction` called `sign_and_submit` +- Support for cross-chain bridge proposal ### Changed: - `check_fee` now has a higher limit that is less likely to be hit From 98be5415fe9dc9eee3c1e43f64b9ff9d583370d6 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Mon, 15 Aug 2022 12:39:29 +0200 Subject: [PATCH 031/111] update RPCs --- xrpl/models/requests/account_objects.py | 1 + xrpl/models/requests/ledger_entry.py | 44 +++++++++++++++++++++---- 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/xrpl/models/requests/account_objects.py b/xrpl/models/requests/account_objects.py index 167d66ee0..d46d81acf 100644 --- a/xrpl/models/requests/account_objects.py +++ b/xrpl/models/requests/account_objects.py @@ -26,6 +26,7 @@ class AccountObjectType(str, Enum): SIGNER_LIST = "signer_list" STATE = "state" TICKET = "ticket" + XCHAIN_SEQ = "xchain_seq" @require_kwargs_on_init diff --git a/xrpl/models/requests/ledger_entry.py b/xrpl/models/requests/ledger_entry.py index b409e2cbe..17990f883 100644 --- a/xrpl/models/requests/ledger_entry.py +++ b/xrpl/models/requests/ledger_entry.py @@ -8,12 +8,14 @@ from __future__ import annotations from dataclasses import dataclass, field -from typing import Dict, List, Optional, Union +from typing import Dict, List, Literal, Optional, Union from xrpl.models.base_model import BaseModel +from xrpl.models.currencies import IssuedCurrency from xrpl.models.requests.request import Request, RequestMethod 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 @@ -112,7 +114,7 @@ class Offer(BaseModel): @require_kwargs_on_init @dataclass(frozen=True) class RippleState(BaseModel): - """Required fields for requesting a RippleState.""" + """Required fields for requesting a RippleState if not querying by object ID.""" accounts: List[str] = REQUIRED # type: ignore """ @@ -132,10 +134,7 @@ class RippleState(BaseModel): @require_kwargs_on_init @dataclass(frozen=True) class Ticket(BaseModel): - """ - Required fields for requesting a Ticket, if not querying by - object ID. - """ + """Required fields for requesting a Ticket if not querying by object ID.""" owner: str = REQUIRED # type: ignore """ @@ -152,6 +151,33 @@ class Ticket(BaseModel): """ +@require_kwargs_on_init +@dataclass(frozen=True) +class XChainClaimID(BaseModel): + """Required fields for requesting an XChainClaimID if not querying by object ID.""" + + locking_chain_door: str + locking_chain_issue: Union[Literal["XRP"], IssuedCurrency] + issuing_chain_door: str + issuing_chain_issue: Union[Literal["XRP"], IssuedCurrency] + xchain_claim_id: Union[int, str] + + +@require_kwargs_on_init +@dataclass(frozen=True) +class XChainCreateAccountClaimID(BaseModel): + """ + Required fields for requesting an XChainCreateAccountClaimID if not querying by + object ID. + """ + + locking_chain_door: str + locking_chain_issue: Union[Literal["XRP"], IssuedCurrency] + issuing_chain_door: str + issuing_chain_issue: Union[Literal["XRP"], IssuedCurrency] + xchain_create_account_claim_id: Union[int, str] + + @require_kwargs_on_init @dataclass(frozen=True) class LedgerEntry(Request): @@ -174,6 +200,12 @@ class LedgerEntry(Request): payment_channel: Optional[str] = None ripple_state: Optional[RippleState] = None ticket: Optional[Union[str, Ticket]] = None + xchain_bridge: Optional[Union[str, XChainBridge]] = None + xchain_claim_id: Optional[Union[str, XChainClaimID]] = None + xchain_create_account_claim_id: Optional[ + Union[str, XChainCreateAccountClaimID] + ] = None + binary: bool = False ledger_hash: Optional[str] = None ledger_index: Optional[Union[str, int]] = None From ac805d18149055325426c15679ceb1f975ce4fdb Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Tue, 16 Aug 2022 17:56:31 +0200 Subject: [PATCH 032/111] make claim attestation destination optional --- xrpl/models/transactions/xchain_add_attestation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xrpl/models/transactions/xchain_add_attestation.py b/xrpl/models/transactions/xchain_add_attestation.py index 2589cf97c..7756c6266 100644 --- a/xrpl/models/transactions/xchain_add_attestation.py +++ b/xrpl/models/transactions/xchain_add_attestation.py @@ -3,7 +3,7 @@ from __future__ import annotations from dataclasses import dataclass, field -from typing import Any, Dict, List, Type, Union +from typing import Any, Dict, List, Optional, Type, Union from typing_extensions import Literal @@ -27,7 +27,7 @@ class XChainClaimAttestationBatchElement(BaseModel): attestation_reward_account: str = REQUIRED # type: ignore - destination: str = REQUIRED # type: ignore + destination: Optional[str] = None public_key: str = REQUIRED # type: ignore From 78a2ac3572859fd1e1f3e505fc49a45b8981bbf3 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Thu, 18 Aug 2022 18:42:35 +0200 Subject: [PATCH 033/111] make signature reward optional for modify bridge --- xrpl/models/transactions/xchain_modify_bridge.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xrpl/models/transactions/xchain_modify_bridge.py b/xrpl/models/transactions/xchain_modify_bridge.py index a6faf9924..5710487de 100644 --- a/xrpl/models/transactions/xchain_modify_bridge.py +++ b/xrpl/models/transactions/xchain_modify_bridge.py @@ -18,7 +18,7 @@ class XChainModifyBridge(Transaction): xchain_bridge: XChainBridge = REQUIRED # type: ignore - signature_reward: Amount = REQUIRED # type: ignore + signature_reward: Optional[Amount] = None min_account_create_amount: Optional[Amount] = None From c4e591e36959031e4a25f8813b603d12de730b40 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Fri, 26 Aug 2022 15:26:24 +0200 Subject: [PATCH 034/111] update to new rippled changes --- .../fixtures/data/codec-fixtures.json | 14 +++++----- .../binarycodec/definitions/definitions.json | 26 +++++++++++++------ xrpl/models/transactions/xchain_commit.py | 2 +- .../transactions/xchain_create_claim_id.py | 2 +- 4 files changed, 27 insertions(+), 17 deletions(-) diff --git a/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json b/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json index 29d3b7f1a..bc87a4284 100644 --- a/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json +++ b/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json @@ -4502,7 +4502,7 @@ }, "Fee": "10", "Flags": 2147483648, - "OtherChainAccount": "rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", + "OtherChainSource": "rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", "Sequence": 1, "SignatureReward": "10000", "SigningPubKey": "0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020", @@ -4573,7 +4573,7 @@ "XChainClaimAttestationBatchElement" : { "Account" : "rnJmYAiqEVngtnb5ckRroXLtCbWC7CRUBx", "Amount" : "100000000", - "AttestationRewardAccount" : "rnJmYAiqEVngtnb5ckRroXLtCbWC7CRUBx", + "AttestationSignerAccount" : "rnJmYAiqEVngtnb5ckRroXLtCbWC7CRUBx", "Destination" : "r9A8UyNpW3X46FUc6P7JZqgn6WgAPjBwPg", "PublicKey" : "03DAB289CA36FF377F3F4304C7A7203FDE5EDCBFC209F430F6A4355361425526D0", "Signature" : "616263", @@ -4630,7 +4630,7 @@ "XChainCreateAccountAttestationBatchElement": { "Account": "rnJmYAiqEVngtnb5ckRroXLtCbWC7CRUBx", "Amount": "1000000000", - "AttestationRewardAccount": "rEziJZmeZzsJvGVUmpUTey7qxQLKYxaK9f", + "AttestationSignerAccount": "rEziJZmeZzsJvGVUmpUTey7qxQLKYxaK9f", "Destination": "rKT9gDkaedAosiHyHZTjyZs2HvXpzuiGmC", "PublicKey": "03ADB44CA8E56F78A0096825E5667C450ABD5C24C34E027BC1AAF7E5BD114CB5B5", "Signature": "3044022036C8B90F85E8073C465F00625248A72D4714600F98EBBADBAD3B7ED226109A3A02204C5A0AE12D169CF790F66541F3DB59C289E0D99CA7511FDFE352BB601F667A26", @@ -4643,7 +4643,7 @@ "XChainCreateAccountAttestationBatchElement": { "Account": "rnJmYAiqEVngtnb5ckRroXLtCbWC7CRUBx", "Amount": "1000000000", - "AttestationRewardAccount": "rEziJZmeZzsJvGVUmpUTey7qxQLKYxaK9f", + "AttestationSignerAccount": "rEziJZmeZzsJvGVUmpUTey7qxQLKYxaK9f", "Destination": "rKT9gDkaedAosiHyHZTjyZs2HvXpzuiGmC", "PublicKey": "02A14E886B3C3579FBAE3139F29728B903E6F4295AEE92160C8480695524D66A15", "Signature": "304402200C3F5EEE2D7DCB609EE8558258E6AAF1EF823133C2B7C716E0DC9AAD2110F08D0220180E9F285CB2F78E362D37E947C000A8ED60A4BD8EFF21F74C5E529E1A8870ED", @@ -4656,7 +4656,7 @@ "XChainCreateAccountAttestationBatchElement": { "Account": "rnJmYAiqEVngtnb5ckRroXLtCbWC7CRUBx", "Amount": "1000000000", - "AttestationRewardAccount": "rEziJZmeZzsJvGVUmpUTey7qxQLKYxaK9f", + "AttestationSignerAccount": "rEziJZmeZzsJvGVUmpUTey7qxQLKYxaK9f", "Destination": "rKT9gDkaedAosiHyHZTjyZs2HvXpzuiGmC", "PublicKey": "02F7390DCF3352060847B81666EBAC79D52DEA2443BDF58439F75397C45334E2DC", "Signature": "30450221008E31CFF0198F09CBA8610A946C23E170A3F11BCB8FC95D0D56C7B79A126D97D102203F4E952C449F2F01C4AF67FC37772A0D4459D770387CC11DBD5464FAB2185428", @@ -4669,7 +4669,7 @@ "XChainCreateAccountAttestationBatchElement": { "Account": "rnJmYAiqEVngtnb5ckRroXLtCbWC7CRUBx", "Amount": "1000000000", - "AttestationRewardAccount": "rEziJZmeZzsJvGVUmpUTey7qxQLKYxaK9f", + "AttestationSignerAccount": "rEziJZmeZzsJvGVUmpUTey7qxQLKYxaK9f", "Destination": "rKT9gDkaedAosiHyHZTjyZs2HvXpzuiGmC", "PublicKey": "02498BD8CD9CA6A4BA567A2ECFA163F118AFD30511CBBA71429C2EC2F74D760592", "Signature": "3045022100F4E2D672F456CB9929EF01766AB72B42C71314A181232098563B8666E4EEA49C02203F936877E9DCC8FF5F7713579233985DF3DADB155F2BDA78FE3A4321373F370E", @@ -4682,7 +4682,7 @@ "XChainCreateAccountAttestationBatchElement": { "Account": "rnJmYAiqEVngtnb5ckRroXLtCbWC7CRUBx", "Amount": "1000000000", - "AttestationRewardAccount": "rEziJZmeZzsJvGVUmpUTey7qxQLKYxaK9f", + "AttestationSignerAccount": "rEziJZmeZzsJvGVUmpUTey7qxQLKYxaK9f", "Destination": "rKT9gDkaedAosiHyHZTjyZs2HvXpzuiGmC", "PublicKey": "03219642288DEE8A3AA8FEA1F7DAE9ED4D9A9F0EADA1E2DE3DB56DD9598D9AD817", "Signature": "3045022100D1BAFA57F40E16485310698B7B0BD0D4650E18782C4D65787A393CBB6D659EB802204EA28303089CCCD1463866A1BA0493A9B135AEA1EDFC8DD69A1A247DD9FEDB21", diff --git a/xrpl/core/binarycodec/definitions/definitions.json b/xrpl/core/binarycodec/definitions/definitions.json index e96439fe0..a9774ce16 100644 --- a/xrpl/core/binarycodec/definitions/definitions.json +++ b/xrpl/core/binarycodec/definitions/definitions.json @@ -1849,7 +1849,7 @@ } ], [ - "OtherChainAccount", + "OtherChainSource", { "nth": 18, "isVLEncoded": true, @@ -1859,7 +1859,7 @@ } ], [ - "AttestationSignerAccount", + "OtherChainDestination", { "nth": 19, "isVLEncoded": true, @@ -1869,7 +1869,7 @@ } ], [ - "AttestationRewardAccount", + "AttestationSignerAccount", { "nth": 20, "isVLEncoded": true, @@ -1879,7 +1879,7 @@ } ], [ - "LockingChainDoor", + "AttestationRewardAccount", { "nth": 21, "isVLEncoded": true, @@ -1889,7 +1889,7 @@ } ], [ - "IssuingChainDoor", + "LockingChainDoor", { "nth": 22, "isVLEncoded": true, @@ -1898,6 +1898,16 @@ "type": "AccountID" } ], + [ + "IssuingChainDoor", + { + "nth": 23, + "isVLEncoded": true, + "isSerialized": true, + "isSigningField": true, + "type": "AccountID" + } + ], [ "Indexes", { @@ -2610,13 +2620,14 @@ "tecXCHAIN_PROOF_UNKNOWN_KEY": 166, "tecXCHAIN_CREATE_ACCOUNT_NONXRP_ISSUE": 167, "tecXCHAIN_CLAIM_ACCOUNT_DST_EXISTS": 168, - "tecXCHAIN_CLAIM_WRONG_CHAIN": 169, + "tecXCHAIN_WRONG_CHAIN": 169, "tecXCHAIN_REWARD_MISMATCH": 170, "tecXCHAIN_NO_SIGNERS_LIST": 171, "tecXCHAIN_SENDING_ACCOUNT_MISMATCH": 172, "tecXCHAIN_INSUFF_CREATE_AMOUNT": 173, "tecXCHAIN_ACCOUNT_CREATE_PAST": 174, - "tecXCHAIN_ACCOUNT_CREATE_TOO_MANY": 175 + "tecXCHAIN_ACCOUNT_CREATE_TOO_MANY": 175, + "tecXCHAIN_PAYMENT_FAILED": 176 }, "TRANSACTION_TYPES": { "Invalid": -1, @@ -2653,7 +2664,6 @@ "XChainCommit": 32, "XChainClaim": 33, "SidechainXChainAccountCreate": 34, - "SidechainXChainAccountClaim": 35, "XChainAddAttestation": 36, "XChainModifyBridge": 37, "EnableAmendment": 100, diff --git a/xrpl/models/transactions/xchain_commit.py b/xrpl/models/transactions/xchain_commit.py index ac8869a56..7d23ca870 100644 --- a/xrpl/models/transactions/xchain_commit.py +++ b/xrpl/models/transactions/xchain_commit.py @@ -22,7 +22,7 @@ class XChainCommit(Transaction): amount: Amount = REQUIRED # type: ignore - other_chain_account: Optional[str] = None + other_chain_destination: Optional[str] = None transaction_type: TransactionType = field( default=TransactionType.XCHAIN_COMMIT, diff --git a/xrpl/models/transactions/xchain_create_claim_id.py b/xrpl/models/transactions/xchain_create_claim_id.py index 53314b461..eb0ce5aaa 100644 --- a/xrpl/models/transactions/xchain_create_claim_id.py +++ b/xrpl/models/transactions/xchain_create_claim_id.py @@ -19,7 +19,7 @@ class XChainCreateClaimID(Transaction): signature_reward: Amount = REQUIRED # type: ignore - other_chain_account: str = REQUIRED # type: ignore + other_chain_source: str = REQUIRED # type: ignore transaction_type: TransactionType = field( default=TransactionType.XCHAIN_CREATE_CLAIM_ID, From b31526d616f1ccc199047b29883c2062d4da8ff8 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Fri, 26 Aug 2022 16:17:15 +0200 Subject: [PATCH 035/111] one more fix --- xrpl/models/transactions/xchain_add_attestation.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xrpl/models/transactions/xchain_add_attestation.py b/xrpl/models/transactions/xchain_add_attestation.py index 7756c6266..06e429773 100644 --- a/xrpl/models/transactions/xchain_add_attestation.py +++ b/xrpl/models/transactions/xchain_add_attestation.py @@ -113,6 +113,8 @@ class XChainCreateAccountAttestationBatchElement(BaseModel): signature: str = REQUIRED # type: ignore + signature_reward: Amount = REQUIRED # type: ignore + was_locking_chain_send: Union[Literal[0, 1]] = REQUIRED # type: ignore xchain_account_create_count: str = REQUIRED # type: ignore From 02d8fc3beff0422ed03c73589125db4d33c096dd Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Mon, 29 Aug 2022 21:18:04 +0300 Subject: [PATCH 036/111] Update definitions.json --- xrpl/core/binarycodec/definitions/definitions.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xrpl/core/binarycodec/definitions/definitions.json b/xrpl/core/binarycodec/definitions/definitions.json index a9774ce16..34fc6b58d 100644 --- a/xrpl/core/binarycodec/definitions/definitions.json +++ b/xrpl/core/binarycodec/definitions/definitions.json @@ -2627,7 +2627,8 @@ "tecXCHAIN_INSUFF_CREATE_AMOUNT": 173, "tecXCHAIN_ACCOUNT_CREATE_PAST": 174, "tecXCHAIN_ACCOUNT_CREATE_TOO_MANY": 175, - "tecXCHAIN_PAYMENT_FAILED": 176 + "tecXCHAIN_PAYMENT_FAILED": 176, + "tecXCHAIN_SELF_COMMIT": 177 }, "TRANSACTION_TYPES": { "Invalid": -1, From dbd0781750d33f8c38c63d600eea4c078cd36089 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Mon, 29 Aug 2022 21:26:51 +0300 Subject: [PATCH 037/111] fix spacing --- .../fixtures/data/codec-fixtures.json | 68 +++++++++---------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json b/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json index bc87a4284..a81b0ad89 100644 --- a/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json +++ b/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json @@ -4562,27 +4562,27 @@ "TransactionType" : "XChainAddAttestation", "TxnSignature" : "3045022100A6A8CA05B2B6CB60E0FD645A4DA0314D46D79D9FA3D63307FC997357366151B202202266CC23E2CA827905F37F78F54AD435F73A3B704EDD634B89201E23625CE2E2", "XChainAttestationBatch" : { - "XChainBridge" : { - "IssuingChainDoor" : "rKeSSvHvaMZJp9ykaxutVwkhZgWuWMLnQt", - "IssuingChainIssue" : "XRP", - "LockingChainDoor" : "rJvExveLEL4jNDEeLKCVdxaSCN9cEBnEQC", - "LockingChainIssue" : "XRP" + "XChainBridge" : { + "IssuingChainDoor" : "rKeSSvHvaMZJp9ykaxutVwkhZgWuWMLnQt", + "IssuingChainIssue" : "XRP", + "LockingChainDoor" : "rJvExveLEL4jNDEeLKCVdxaSCN9cEBnEQC", + "LockingChainIssue" : "XRP" }, "XChainClaimAttestationBatch" : [ - { - "XChainClaimAttestationBatchElement" : { - "Account" : "rnJmYAiqEVngtnb5ckRroXLtCbWC7CRUBx", - "Amount" : "100000000", - "AttestationSignerAccount" : "rnJmYAiqEVngtnb5ckRroXLtCbWC7CRUBx", - "Destination" : "r9A8UyNpW3X46FUc6P7JZqgn6WgAPjBwPg", - "PublicKey" : "03DAB289CA36FF377F3F4304C7A7203FDE5EDCBFC209F430F6A4355361425526D0", - "Signature" : "616263", - "WasLockingChainSend" : 1, - "XChainClaimID" : "0000000000000000" - } + { + "XChainClaimAttestationBatchElement" : { + "Account" : "rnJmYAiqEVngtnb5ckRroXLtCbWC7CRUBx", + "Amount" : "100000000", + "AttestationSignerAccount" : "rnJmYAiqEVngtnb5ckRroXLtCbWC7CRUBx", + "Destination" : "r9A8UyNpW3X46FUc6P7JZqgn6WgAPjBwPg", + "PublicKey" : "03DAB289CA36FF377F3F4304C7A7203FDE5EDCBFC209F430F6A4355361425526D0", + "Signature" : "616263", + "WasLockingChainSend" : 1, + "XChainClaimID" : "0000000000000000" } - ], - "XChainCreateAccountAttestationBatch" : [] + } + ], + "XChainCreateAccountAttestationBatch" : [] } } }, @@ -4642,27 +4642,27 @@ { "XChainCreateAccountAttestationBatchElement": { "Account": "rnJmYAiqEVngtnb5ckRroXLtCbWC7CRUBx", - "Amount": "1000000000", - "AttestationSignerAccount": "rEziJZmeZzsJvGVUmpUTey7qxQLKYxaK9f", - "Destination": "rKT9gDkaedAosiHyHZTjyZs2HvXpzuiGmC", - "PublicKey": "02A14E886B3C3579FBAE3139F29728B903E6F4295AEE92160C8480695524D66A15", - "Signature": "304402200C3F5EEE2D7DCB609EE8558258E6AAF1EF823133C2B7C716E0DC9AAD2110F08D0220180E9F285CB2F78E362D37E947C000A8ED60A4BD8EFF21F74C5E529E1A8870ED", - "SignatureReward": "1000000", - "WasLockingChainSend": 1, - "XChainAccountCreateCount": "0000000000000001" + "Amount": "1000000000", + "AttestationSignerAccount": "rEziJZmeZzsJvGVUmpUTey7qxQLKYxaK9f", + "Destination": "rKT9gDkaedAosiHyHZTjyZs2HvXpzuiGmC", + "PublicKey": "02A14E886B3C3579FBAE3139F29728B903E6F4295AEE92160C8480695524D66A15", + "Signature": "304402200C3F5EEE2D7DCB609EE8558258E6AAF1EF823133C2B7C716E0DC9AAD2110F08D0220180E9F285CB2F78E362D37E947C000A8ED60A4BD8EFF21F74C5E529E1A8870ED", + "SignatureReward": "1000000", + "WasLockingChainSend": 1, + "XChainAccountCreateCount": "0000000000000001" } }, { "XChainCreateAccountAttestationBatchElement": { "Account": "rnJmYAiqEVngtnb5ckRroXLtCbWC7CRUBx", - "Amount": "1000000000", - "AttestationSignerAccount": "rEziJZmeZzsJvGVUmpUTey7qxQLKYxaK9f", - "Destination": "rKT9gDkaedAosiHyHZTjyZs2HvXpzuiGmC", - "PublicKey": "02F7390DCF3352060847B81666EBAC79D52DEA2443BDF58439F75397C45334E2DC", - "Signature": "30450221008E31CFF0198F09CBA8610A946C23E170A3F11BCB8FC95D0D56C7B79A126D97D102203F4E952C449F2F01C4AF67FC37772A0D4459D770387CC11DBD5464FAB2185428", - "SignatureReward": "1000000", - "WasLockingChainSend": 1, - "XChainAccountCreateCount": "0000000000000001" + "Amount": "1000000000", + "AttestationSignerAccount": "rEziJZmeZzsJvGVUmpUTey7qxQLKYxaK9f", + "Destination": "rKT9gDkaedAosiHyHZTjyZs2HvXpzuiGmC", + "PublicKey": "02F7390DCF3352060847B81666EBAC79D52DEA2443BDF58439F75397C45334E2DC", + "Signature": "30450221008E31CFF0198F09CBA8610A946C23E170A3F11BCB8FC95D0D56C7B79A126D97D102203F4E952C449F2F01C4AF67FC37772A0D4459D770387CC11DBD5464FAB2185428", + "SignatureReward": "1000000", + "WasLockingChainSend": 1, + "XChainAccountCreateCount": "0000000000000001" } }, { From eedc4450d3cfe0db6c88c6684c9c3c92eac62b41 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Tue, 30 Aug 2022 20:46:57 +0300 Subject: [PATCH 038/111] update definitions.json to avoid conflict with amm --- .../fixtures/data/codec-fixtures.json | 12 ++++++------ .../binarycodec/definitions/definitions.json | 18 +++++++++--------- xrpl/wallet/main.py | 1 + 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json b/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json index a81b0ad89..1d828dae2 100644 --- a/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json +++ b/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json @@ -4451,7 +4451,7 @@ } }, { - "binary": "12001E2200000000240000000168400000000000000A601540000000000003E86016400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020744630440220101BCA4B5B5A37C6F44480F9A34752C9AA8B2CDF5AD47E3CB424DEDC21C06DB702206EEB257E82A89B1F46A0A2C7F070B0BD181D980FF86FE4269E369F6FC7A270918114B5F762798A53D543A014CAF8B297CFF8F2F937E8011A14AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", + "binary": "12001E2200000000240000000168400000000000000A601D40000000000003E8601E400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020744630440220101BCA4B5B5A37C6F44480F9A34752C9AA8B2CDF5AD47E3CB424DEDC21C06DB702206EEB257E82A89B1F46A0A2C7F070B0BD181D980FF86FE4269E369F6FC7A270918114B5F762798A53D543A014CAF8B297CFF8F2F937E8011A14AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", "json": { "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "XChainBridge": { @@ -4471,7 +4471,7 @@ } }, { - "binary": "1200252200000000240000000168400000000000000A601540000000000003E86016400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02074473045022100D2CABC1B0E0635A8EE2E6554F6D474C49BC292C995C5C9F83179F4A60634B04C02205D1DB569D9593136F2FBEA7140010C8F46794D653AFDBEA8D30B8750BA4805E58114B5F762798A53D543A014CAF8B297CFF8F2F937E8011A14AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", + "binary": "1200252200000000240000000168400000000000000A601D40000000000003E8601E400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02074473045022100D2CABC1B0E0635A8EE2E6554F6D474C49BC292C995C5C9F83179F4A60634B04C02205D1DB569D9593136F2FBEA7140010C8F46794D653AFDBEA8D30B8750BA4805E58114B5F762798A53D543A014CAF8B297CFF8F2F937E8011A14AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", "json": { "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "XChainBridge": { @@ -4491,7 +4491,7 @@ } }, { - "binary": "12001F2280000000240000000168400000000000000A6015400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020744630440220247B20A1B9C48E21A374CB9B3E1FE2A7C528151868DF8D307E9FBE15237E531A02207C20C092DDCC525E583EF4AB7CB91E862A6DED19426997D3F0A2C84E2BE8C5DD8114B5F762798A53D543A014CAF8B297CFF8F2F937E8801214AF80285F637EE4AF3C20378F9DFB12511ACB8D27011A14AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", + "binary": "12001F2280000000240000000168400000000000000A601D400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020744630440220247B20A1B9C48E21A374CB9B3E1FE2A7C528151868DF8D307E9FBE15237E531A02207C20C092DDCC525E583EF4AB7CB91E862A6DED19426997D3F0A2C84E2BE8C5DD8114B5F762798A53D543A014CAF8B297CFF8F2F937E8801214AF80285F637EE4AF3C20378F9DFB12511ACB8D27011A14AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", "json": { "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "XChainBridge": { @@ -4552,7 +4552,7 @@ } }, { - "binary": "1200242280000000240000000468400000000000000A73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02074473045022100A6A8CA05B2B6CB60E0FD645A4DA0314D46D79D9FA3D63307FC997357366151B202202266CC23E2CA827905F37F78F54AD435F73A3B704EDD634B89201E23625CE2E28114B5F762798A53D543A014CAF8B297CFF8F2F937E8011B14C48CAD01682D7A86296EF14523074D4852C02EA9000000000000000000000000000000000000000014CC86E58C9B58D4CF71CB8C1B41F21BB290CE13D40000000000000000000000000000000000000000E01C30140000000000000000614000000005F5E100712103DAB289CA36FF377F3F4304C7A7203FDE5EDCBFC209F430F6A4355361425526D0760361626381142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314621D345F8F094A085132431C69C89EC05D212CC28014142F3CC37C1D5616B3BBF1AABC49F6BFF46A92008700101301E1F1F1", + "binary": "1200242280000000240000000468400000000000000A73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02074473045022100A6A8CA05B2B6CB60E0FD645A4DA0314D46D79D9FA3D63307FC997357366151B202202266CC23E2CA827905F37F78F54AD435F73A3B704EDD634B89201E23625CE2E28114B5F762798A53D543A014CAF8B297CFF8F2F937E8011B14C48CAD01682D7A86296EF14523074D4852C02EA9000000000000000000000000000000000000000014CC86E58C9B58D4CF71CB8C1B41F21BB290CE13D40000000000000000000000000000000000000000E02330140000000000000000614000000005F5E100712103DAB289CA36FF377F3F4304C7A7203FDE5EDCBFC209F430F6A4355361425526D0760361626381142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314621D345F8F094A085132431C69C89EC05D212CC28014142F3CC37C1D5616B3BBF1AABC49F6BFF46A92008700101301E1F1F1", "json": { "Account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "Fee" : "10", @@ -4587,7 +4587,7 @@ } }, { - "binary": "120022228000000024000000016140000000000F424068400000000000000A6015400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD0207446304402202984DDE7F0B566F081F7953D7212BF031ACBF8860FE114102E9512C4C8768C77022070113F4630B1DC3045E4A98DDD648CEBC31B12774F7B44A1B8123CD2C9F5CF188114B5F762798A53D543A014CAF8B297CFF8F2F937E88314AF80285F637EE4AF3C20378F9DFB12511ACB8D27011A14AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", + "binary": "120022228000000024000000016140000000000F424068400000000000000A601D400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD0207446304402202984DDE7F0B566F081F7953D7212BF031ACBF8860FE114102E9512C4C8768C77022070113F4630B1DC3045E4A98DDD648CEBC31B12774F7B44A1B8123CD2C9F5CF188114B5F762798A53D543A014CAF8B297CFF8F2F937E88314AF80285F637EE4AF3C20378F9DFB12511ACB8D27011A14AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", "json": { "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "XChainBridge": { @@ -4608,7 +4608,7 @@ } }, { - "binary": "1200242280000000240000000168400000000000000A73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD0207447304502210098F47661D8EF89CC2DFF3EAA92AF3843CEFD398EAD1E7496FAEAC269DE688FB80220143EBE519FC1936E884B1AFA047D4CB7CD2E2A28F0B27EC982D1BB3E63FC95358114B5F762798A53D543A014CAF8B297CFF8F2F937E8011B14C48CAD01682D7A86296EF14523074D4852C02EA9000000000000000000000000000000000000000014CC86E58C9B58D4CF71CB8C1B41F21BB290CE13D40000000000000000000000000000000000000000F1E01D3015000000000000000161400000003B9ACA00601540000000000F4240712103ADB44CA8E56F78A0096825E5667C450ABD5C24C34E027BC1AAF7E5BD114CB5B576463044022036C8B90F85E8073C465F00625248A72D4714600F98EBBADBAD3B7ED226109A3A02204C5A0AE12D169CF790F66541F3DB59C289E0D99CA7511FDFE352BB601F667A2681142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801414A482A071D77722C2B683FFE01DC30134035E8E7200101301E1E01D3015000000000000000161400000003B9ACA00601540000000000F4240712102A14E886B3C3579FBAE3139F29728B903E6F4295AEE92160C8480695524D66A157646304402200C3F5EEE2D7DCB609EE8558258E6AAF1EF823133C2B7C716E0DC9AAD2110F08D0220180E9F285CB2F78E362D37E947C000A8ED60A4BD8EFF21F74C5E529E1A8870ED81142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801414A482A071D77722C2B683FFE01DC30134035E8E7200101301E1E01D3015000000000000000161400000003B9ACA00601540000000000F4240712102F7390DCF3352060847B81666EBAC79D52DEA2443BDF58439F75397C45334E2DC764730450221008E31CFF0198F09CBA8610A946C23E170A3F11BCB8FC95D0D56C7B79A126D97D102203F4E952C449F2F01C4AF67FC37772A0D4459D770387CC11DBD5464FAB218542881142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801414A482A071D77722C2B683FFE01DC30134035E8E7200101301E1E01D3015000000000000000161400000003B9ACA00601540000000000F4240712102498BD8CD9CA6A4BA567A2ECFA163F118AFD30511CBBA71429C2EC2F74D76059276473045022100F4E2D672F456CB9929EF01766AB72B42C71314A181232098563B8666E4EEA49C02203F936877E9DCC8FF5F7713579233985DF3DADB155F2BDA78FE3A4321373F370E81142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801414A482A071D77722C2B683FFE01DC30134035E8E7200101301E1E01D3015000000000000000161400000003B9ACA00601540000000000F4240712103219642288DEE8A3AA8FEA1F7DAE9ED4D9A9F0EADA1E2DE3DB56DD9598D9AD81776473045022100D1BAFA57F40E16485310698B7B0BD0D4650E18782C4D65787A393CBB6D659EB802204EA28303089CCCD1463866A1BA0493A9B135AEA1EDFC8DD69A1A247DD9FEDB2181142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801414A482A071D77722C2B683FFE01DC30134035E8E7200101301E1F1", + "binary": "1200242280000000240000000168400000000000000A73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD0207447304502210098F47661D8EF89CC2DFF3EAA92AF3843CEFD398EAD1E7496FAEAC269DE688FB80220143EBE519FC1936E884B1AFA047D4CB7CD2E2A28F0B27EC982D1BB3E63FC95358114B5F762798A53D543A014CAF8B297CFF8F2F937E8011B14C48CAD01682D7A86296EF14523074D4852C02EA9000000000000000000000000000000000000000014CC86E58C9B58D4CF71CB8C1B41F21BB290CE13D40000000000000000000000000000000000000000F1E0243015000000000000000161400000003B9ACA00601D40000000000F4240712103ADB44CA8E56F78A0096825E5667C450ABD5C24C34E027BC1AAF7E5BD114CB5B576463044022036C8B90F85E8073C465F00625248A72D4714600F98EBBADBAD3B7ED226109A3A02204C5A0AE12D169CF790F66541F3DB59C289E0D99CA7511FDFE352BB601F667A2681142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801414A482A071D77722C2B683FFE01DC30134035E8E7200101301E1E0243015000000000000000161400000003B9ACA00601D40000000000F4240712102A14E886B3C3579FBAE3139F29728B903E6F4295AEE92160C8480695524D66A157646304402200C3F5EEE2D7DCB609EE8558258E6AAF1EF823133C2B7C716E0DC9AAD2110F08D0220180E9F285CB2F78E362D37E947C000A8ED60A4BD8EFF21F74C5E529E1A8870ED81142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801414A482A071D77722C2B683FFE01DC30134035E8E7200101301E1E0243015000000000000000161400000003B9ACA00601D40000000000F4240712102F7390DCF3352060847B81666EBAC79D52DEA2443BDF58439F75397C45334E2DC764730450221008E31CFF0198F09CBA8610A946C23E170A3F11BCB8FC95D0D56C7B79A126D97D102203F4E952C449F2F01C4AF67FC37772A0D4459D770387CC11DBD5464FAB218542881142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801414A482A071D77722C2B683FFE01DC30134035E8E7200101301E1E0243015000000000000000161400000003B9ACA00601D40000000000F4240712102498BD8CD9CA6A4BA567A2ECFA163F118AFD30511CBBA71429C2EC2F74D76059276473045022100F4E2D672F456CB9929EF01766AB72B42C71314A181232098563B8666E4EEA49C02203F936877E9DCC8FF5F7713579233985DF3DADB155F2BDA78FE3A4321373F370E81142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801414A482A071D77722C2B683FFE01DC30134035E8E7200101301E1E0243015000000000000000161400000003B9ACA00601D40000000000F4240712103219642288DEE8A3AA8FEA1F7DAE9ED4D9A9F0EADA1E2DE3DB56DD9598D9AD81776473045022100D1BAFA57F40E16485310698B7B0BD0D4650E18782C4D65787A393CBB6D659EB802204EA28303089CCCD1463866A1BA0493A9B135AEA1EDFC8DD69A1A247DD9FEDB2181142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801414A482A071D77722C2B683FFE01DC30134035E8E7200101301E1F1", "json": { "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "Fee": "10", diff --git a/xrpl/core/binarycodec/definitions/definitions.json b/xrpl/core/binarycodec/definitions/definitions.json index 34fc6b58d..3b608c632 100644 --- a/xrpl/core/binarycodec/definitions/definitions.json +++ b/xrpl/core/binarycodec/definitions/definitions.json @@ -1471,7 +1471,7 @@ [ "XChainFee", { - "nth": 20, + "nth": 28, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -1481,7 +1481,7 @@ [ "SignatureReward", { - "nth": 21, + "nth": 29, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -1491,7 +1491,7 @@ [ "MinAccountCreateAmount", { - "nth": 22, + "nth": 30, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -2221,7 +2221,7 @@ [ "XChainClaimProofSig", { - "nth": 25, + "nth": 32, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -2231,7 +2231,7 @@ [ "XChainCreateAccountProofSig", { - "nth": 26, + "nth": 33, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -2241,7 +2241,7 @@ [ "XChainAttestationBatchElement", { - "nth": 27, + "nth": 34, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -2251,7 +2251,7 @@ [ "XChainClaimAttestationBatchElement", { - "nth": 28, + "nth": 35, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -2261,7 +2261,7 @@ [ "XChainCreateAccountAttestationBatchElement", { - "nth": 29, + "nth": 36, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -2271,7 +2271,7 @@ [ "XChainAttestationBatchInner", { - "nth": 30, + "nth": 37, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, diff --git a/xrpl/wallet/main.py b/xrpl/wallet/main.py index 29c42dabc..44b0bc6b0 100644 --- a/xrpl/wallet/main.py +++ b/xrpl/wallet/main.py @@ -39,6 +39,7 @@ def __init__( """ pk, sk = derive_keypair(self.seed, algorithm=algorithm) + self.algorithm = algorithm self.public_key = pk """ The public key that is used to identify this wallet's signatures, as From d187b3b6be7075115a38756939b26e7d0ac3ab67 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Wed, 31 Aug 2022 15:10:26 +0300 Subject: [PATCH 039/111] Update definitions.json --- .../fixtures/data/codec-fixtures.json | 16 ++--- .../binarycodec/definitions/definitions.json | 71 +++++++++++-------- 2 files changed, 49 insertions(+), 38 deletions(-) diff --git a/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json b/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json index 1d828dae2..d4accb481 100644 --- a/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json +++ b/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json @@ -4451,7 +4451,7 @@ } }, { - "binary": "12001E2200000000240000000168400000000000000A601D40000000000003E8601E400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020744630440220101BCA4B5B5A37C6F44480F9A34752C9AA8B2CDF5AD47E3CB424DEDC21C06DB702206EEB257E82A89B1F46A0A2C7F070B0BD181D980FF86FE4269E369F6FC7A270918114B5F762798A53D543A014CAF8B297CFF8F2F937E8011A14AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", + "binary": "1200282200000000240000000168400000000000000A601D40000000000003E8601E400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020744630440220101BCA4B5B5A37C6F44480F9A34752C9AA8B2CDF5AD47E3CB424DEDC21C06DB702206EEB257E82A89B1F46A0A2C7F070B0BD181D980FF86FE4269E369F6FC7A270918114B5F762798A53D543A014CAF8B297CFF8F2F937E8011A14AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", "json": { "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "XChainBridge": { @@ -4471,7 +4471,7 @@ } }, { - "binary": "1200252200000000240000000168400000000000000A601D40000000000003E8601E400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02074473045022100D2CABC1B0E0635A8EE2E6554F6D474C49BC292C995C5C9F83179F4A60634B04C02205D1DB569D9593136F2FBEA7140010C8F46794D653AFDBEA8D30B8750BA4805E58114B5F762798A53D543A014CAF8B297CFF8F2F937E8011A14AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", + "binary": "12002E2200000000240000000168400000000000000A601D40000000000003E8601E400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02074473045022100D2CABC1B0E0635A8EE2E6554F6D474C49BC292C995C5C9F83179F4A60634B04C02205D1DB569D9593136F2FBEA7140010C8F46794D653AFDBEA8D30B8750BA4805E58114B5F762798A53D543A014CAF8B297CFF8F2F937E8011A14AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", "json": { "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "XChainBridge": { @@ -4491,7 +4491,7 @@ } }, { - "binary": "12001F2280000000240000000168400000000000000A601D400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020744630440220247B20A1B9C48E21A374CB9B3E1FE2A7C528151868DF8D307E9FBE15237E531A02207C20C092DDCC525E583EF4AB7CB91E862A6DED19426997D3F0A2C84E2BE8C5DD8114B5F762798A53D543A014CAF8B297CFF8F2F937E8801214AF80285F637EE4AF3C20378F9DFB12511ACB8D27011A14AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", + "binary": "1200292280000000240000000168400000000000000A601D400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020744630440220247B20A1B9C48E21A374CB9B3E1FE2A7C528151868DF8D307E9FBE15237E531A02207C20C092DDCC525E583EF4AB7CB91E862A6DED19426997D3F0A2C84E2BE8C5DD8114B5F762798A53D543A014CAF8B297CFF8F2F937E8801214AF80285F637EE4AF3C20378F9DFB12511ACB8D27011A14AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", "json": { "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "XChainBridge": { @@ -4511,7 +4511,7 @@ } }, { - "binary": "120020228000000024000000013014000000000000000161400000000000271068400000000000000A73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02074453043021F177323F0D93612C82A4393A99B23905A7E675753FD80C52997AFAB13F5F9D002203BFFAF457E90BDA65AABE8F8762BD96162FAD98A0C030CCD69B06EE9B12BBFFE8114B5F762798A53D543A014CAF8B297CFF8F2F937E8011A14AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", + "binary": "12002A228000000024000000013014000000000000000161400000000000271068400000000000000A73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02074453043021F177323F0D93612C82A4393A99B23905A7E675753FD80C52997AFAB13F5F9D002203BFFAF457E90BDA65AABE8F8762BD96162FAD98A0C030CCD69B06EE9B12BBFFE8114B5F762798A53D543A014CAF8B297CFF8F2F937E8011A14AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", "json": { "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "Amount": "10000", @@ -4531,7 +4531,7 @@ } }, { - "binary": "120021228000000024000000013014000000000000000161400000000000271068400000000000000A73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020744630440220445F7469FDA401787D9EE8A9B6E24DFF81E94F4C09FD311D2C0A58FCC02C684A022029E2EF34A5EA35F50D5BB57AC6320AD3AE12C13C8D1379B255A486D72CED142E8114B5F762798A53D543A014CAF8B297CFF8F2F937E88314550FC62003E785DC231A1058A05E56E3F09CF4E6011A14AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", + "binary": "12002B228000000024000000013014000000000000000161400000000000271068400000000000000A73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020744630440220445F7469FDA401787D9EE8A9B6E24DFF81E94F4C09FD311D2C0A58FCC02C684A022029E2EF34A5EA35F50D5BB57AC6320AD3AE12C13C8D1379B255A486D72CED142E8114B5F762798A53D543A014CAF8B297CFF8F2F937E88314550FC62003E785DC231A1058A05E56E3F09CF4E6011A14AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", "json": { "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "Amount": "10000", @@ -4552,7 +4552,7 @@ } }, { - "binary": "1200242280000000240000000468400000000000000A73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02074473045022100A6A8CA05B2B6CB60E0FD645A4DA0314D46D79D9FA3D63307FC997357366151B202202266CC23E2CA827905F37F78F54AD435F73A3B704EDD634B89201E23625CE2E28114B5F762798A53D543A014CAF8B297CFF8F2F937E8011B14C48CAD01682D7A86296EF14523074D4852C02EA9000000000000000000000000000000000000000014CC86E58C9B58D4CF71CB8C1B41F21BB290CE13D40000000000000000000000000000000000000000E02330140000000000000000614000000005F5E100712103DAB289CA36FF377F3F4304C7A7203FDE5EDCBFC209F430F6A4355361425526D0760361626381142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314621D345F8F094A085132431C69C89EC05D212CC28014142F3CC37C1D5616B3BBF1AABC49F6BFF46A92008700101301E1F1F1", + "binary": "12002D2280000000240000000468400000000000000A73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02074473045022100A6A8CA05B2B6CB60E0FD645A4DA0314D46D79D9FA3D63307FC997357366151B202202266CC23E2CA827905F37F78F54AD435F73A3B704EDD634B89201E23625CE2E28114B5F762798A53D543A014CAF8B297CFF8F2F937E8011B14C48CAD01682D7A86296EF14523074D4852C02EA9000000000000000000000000000000000000000014CC86E58C9B58D4CF71CB8C1B41F21BB290CE13D40000000000000000000000000000000000000000E02330140000000000000000614000000005F5E100712103DAB289CA36FF377F3F4304C7A7203FDE5EDCBFC209F430F6A4355361425526D0760361626381142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314621D345F8F094A085132431C69C89EC05D212CC28014142F3CC37C1D5616B3BBF1AABC49F6BFF46A92008700101301E1F1F1", "json": { "Account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "Fee" : "10", @@ -4587,7 +4587,7 @@ } }, { - "binary": "120022228000000024000000016140000000000F424068400000000000000A601D400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD0207446304402202984DDE7F0B566F081F7953D7212BF031ACBF8860FE114102E9512C4C8768C77022070113F4630B1DC3045E4A98DDD648CEBC31B12774F7B44A1B8123CD2C9F5CF188114B5F762798A53D543A014CAF8B297CFF8F2F937E88314AF80285F637EE4AF3C20378F9DFB12511ACB8D27011A14AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", + "binary": "12002C228000000024000000016140000000000F424068400000000000000A601D400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD0207446304402202984DDE7F0B566F081F7953D7212BF031ACBF8860FE114102E9512C4C8768C77022070113F4630B1DC3045E4A98DDD648CEBC31B12774F7B44A1B8123CD2C9F5CF188114B5F762798A53D543A014CAF8B297CFF8F2F937E88314AF80285F637EE4AF3C20378F9DFB12511ACB8D27011A14AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", "json": { "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "XChainBridge": { @@ -4608,7 +4608,7 @@ } }, { - "binary": "1200242280000000240000000168400000000000000A73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD0207447304502210098F47661D8EF89CC2DFF3EAA92AF3843CEFD398EAD1E7496FAEAC269DE688FB80220143EBE519FC1936E884B1AFA047D4CB7CD2E2A28F0B27EC982D1BB3E63FC95358114B5F762798A53D543A014CAF8B297CFF8F2F937E8011B14C48CAD01682D7A86296EF14523074D4852C02EA9000000000000000000000000000000000000000014CC86E58C9B58D4CF71CB8C1B41F21BB290CE13D40000000000000000000000000000000000000000F1E0243015000000000000000161400000003B9ACA00601D40000000000F4240712103ADB44CA8E56F78A0096825E5667C450ABD5C24C34E027BC1AAF7E5BD114CB5B576463044022036C8B90F85E8073C465F00625248A72D4714600F98EBBADBAD3B7ED226109A3A02204C5A0AE12D169CF790F66541F3DB59C289E0D99CA7511FDFE352BB601F667A2681142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801414A482A071D77722C2B683FFE01DC30134035E8E7200101301E1E0243015000000000000000161400000003B9ACA00601D40000000000F4240712102A14E886B3C3579FBAE3139F29728B903E6F4295AEE92160C8480695524D66A157646304402200C3F5EEE2D7DCB609EE8558258E6AAF1EF823133C2B7C716E0DC9AAD2110F08D0220180E9F285CB2F78E362D37E947C000A8ED60A4BD8EFF21F74C5E529E1A8870ED81142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801414A482A071D77722C2B683FFE01DC30134035E8E7200101301E1E0243015000000000000000161400000003B9ACA00601D40000000000F4240712102F7390DCF3352060847B81666EBAC79D52DEA2443BDF58439F75397C45334E2DC764730450221008E31CFF0198F09CBA8610A946C23E170A3F11BCB8FC95D0D56C7B79A126D97D102203F4E952C449F2F01C4AF67FC37772A0D4459D770387CC11DBD5464FAB218542881142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801414A482A071D77722C2B683FFE01DC30134035E8E7200101301E1E0243015000000000000000161400000003B9ACA00601D40000000000F4240712102498BD8CD9CA6A4BA567A2ECFA163F118AFD30511CBBA71429C2EC2F74D76059276473045022100F4E2D672F456CB9929EF01766AB72B42C71314A181232098563B8666E4EEA49C02203F936877E9DCC8FF5F7713579233985DF3DADB155F2BDA78FE3A4321373F370E81142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801414A482A071D77722C2B683FFE01DC30134035E8E7200101301E1E0243015000000000000000161400000003B9ACA00601D40000000000F4240712103219642288DEE8A3AA8FEA1F7DAE9ED4D9A9F0EADA1E2DE3DB56DD9598D9AD81776473045022100D1BAFA57F40E16485310698B7B0BD0D4650E18782C4D65787A393CBB6D659EB802204EA28303089CCCD1463866A1BA0493A9B135AEA1EDFC8DD69A1A247DD9FEDB2181142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801414A482A071D77722C2B683FFE01DC30134035E8E7200101301E1F1", + "binary": "12002D2280000000240000000168400000000000000A73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD0207447304502210098F47661D8EF89CC2DFF3EAA92AF3843CEFD398EAD1E7496FAEAC269DE688FB80220143EBE519FC1936E884B1AFA047D4CB7CD2E2A28F0B27EC982D1BB3E63FC95358114B5F762798A53D543A014CAF8B297CFF8F2F937E8011B14C48CAD01682D7A86296EF14523074D4852C02EA9000000000000000000000000000000000000000014CC86E58C9B58D4CF71CB8C1B41F21BB290CE13D40000000000000000000000000000000000000000F1E0243015000000000000000161400000003B9ACA00601D40000000000F4240712103ADB44CA8E56F78A0096825E5667C450ABD5C24C34E027BC1AAF7E5BD114CB5B576463044022036C8B90F85E8073C465F00625248A72D4714600F98EBBADBAD3B7ED226109A3A02204C5A0AE12D169CF790F66541F3DB59C289E0D99CA7511FDFE352BB601F667A2681142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801414A482A071D77722C2B683FFE01DC30134035E8E7200101301E1E0243015000000000000000161400000003B9ACA00601D40000000000F4240712102A14E886B3C3579FBAE3139F29728B903E6F4295AEE92160C8480695524D66A157646304402200C3F5EEE2D7DCB609EE8558258E6AAF1EF823133C2B7C716E0DC9AAD2110F08D0220180E9F285CB2F78E362D37E947C000A8ED60A4BD8EFF21F74C5E529E1A8870ED81142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801414A482A071D77722C2B683FFE01DC30134035E8E7200101301E1E0243015000000000000000161400000003B9ACA00601D40000000000F4240712102F7390DCF3352060847B81666EBAC79D52DEA2443BDF58439F75397C45334E2DC764730450221008E31CFF0198F09CBA8610A946C23E170A3F11BCB8FC95D0D56C7B79A126D97D102203F4E952C449F2F01C4AF67FC37772A0D4459D770387CC11DBD5464FAB218542881142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801414A482A071D77722C2B683FFE01DC30134035E8E7200101301E1E0243015000000000000000161400000003B9ACA00601D40000000000F4240712102498BD8CD9CA6A4BA567A2ECFA163F118AFD30511CBBA71429C2EC2F74D76059276473045022100F4E2D672F456CB9929EF01766AB72B42C71314A181232098563B8666E4EEA49C02203F936877E9DCC8FF5F7713579233985DF3DADB155F2BDA78FE3A4321373F370E81142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801414A482A071D77722C2B683FFE01DC30134035E8E7200101301E1E0243015000000000000000161400000003B9ACA00601D40000000000F4240712103219642288DEE8A3AA8FEA1F7DAE9ED4D9A9F0EADA1E2DE3DB56DD9598D9AD81776473045022100D1BAFA57F40E16485310698B7B0BD0D4650E18782C4D65787A393CBB6D659EB802204EA28303089CCCD1463866A1BA0493A9B135AEA1EDFC8DD69A1A247DD9FEDB2181142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801414A482A071D77722C2B683FFE01DC30134035E8E7200101301E1F1", "json": { "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "Fee": "10", diff --git a/xrpl/core/binarycodec/definitions/definitions.json b/xrpl/core/binarycodec/definitions/definitions.json index 3b608c632..ab19d79ae 100644 --- a/xrpl/core/binarycodec/definitions/definitions.json +++ b/xrpl/core/binarycodec/definitions/definitions.json @@ -2522,13 +2522,15 @@ "temUNKNOWN": -264, "temSEQ_AND_TICKET": -263, "temBAD_NFTOKEN_TRANSFER_FEE": -262, - "temEQUAL_DOOR_ACCOUNTS": -261, - "temBAD_XCHAIN_PROOF": -260, - "temSIDECHAIN_BAD_ISSUES": -259, - "temSIDECHAIN_NONDOOR_OWNER": -258, - "temXCHAIN_BRIDGE_BAD_MIN_ACCOUNT_CREATE_AMOUNT": -257, - "temXCHAIN_BRIDGE_BAD_REWARD_AMOUNT": -256, - "temXCHAIN_TOO_MANY_ATTESTATIONS": -255, + "temBAD_AMM_OPTIONS": -261, + "temBAD_AMM_TOKENS": -260, + "temEQUAL_DOOR_ACCOUNTS": -259, + "temBAD_XCHAIN_PROOF": -258, + "temSIDECHAIN_BAD_ISSUES": -257, + "temSIDECHAIN_NONDOOR_OWNER": -256, + "temXCHAIN_BRIDGE_BAD_MIN_ACCOUNT_CREATE_AMOUNT": -255, + "temXCHAIN_BRIDGE_BAD_REWARD_AMOUNT": -254, + "temXCHAIN_TOO_MANY_ATTESTATIONS": -253, "tefFAILURE": -199, "tefALREADY": -198, @@ -2613,22 +2615,31 @@ "tecINSUFFICIENT_FUNDS": 159, "tecOBJECT_NOT_FOUND": 160, "tecINSUFFICIENT_PAYMENT": 161, - "tecBAD_XCHAIN_TRANSFER_ISSUE": 162, - "tecXCHAIN_NO_CLAIM_ID": 163, - "tecXCHAIN_BAD_CLAIM_ID": 164, - "tecXCHAIN_CLAIM_NO_QUORUM": 165, - "tecXCHAIN_PROOF_UNKNOWN_KEY": 166, - "tecXCHAIN_CREATE_ACCOUNT_NONXRP_ISSUE": 167, - "tecXCHAIN_CLAIM_ACCOUNT_DST_EXISTS": 168, - "tecXCHAIN_WRONG_CHAIN": 169, - "tecXCHAIN_REWARD_MISMATCH": 170, - "tecXCHAIN_NO_SIGNERS_LIST": 171, - "tecXCHAIN_SENDING_ACCOUNT_MISMATCH": 172, - "tecXCHAIN_INSUFF_CREATE_AMOUNT": 173, - "tecXCHAIN_ACCOUNT_CREATE_PAST": 174, - "tecXCHAIN_ACCOUNT_CREATE_TOO_MANY": 175, - "tecXCHAIN_PAYMENT_FAILED": 176, - "tecXCHAIN_SELF_COMMIT": 177 + "tecUNFUNDED_AMM": 162, + "tecAMM_BALANCE": 163, + "tecAMM_FAILED_DEPOSIT": 164, + "tecAMM_FAILED_WITHDRAW": 165, + "tecAMM_INVALID_TOKENS": 166, + "tecAMM_EXISTS": 167, + "tecAMM_FAILED_BID": 168, + "tecAMM_DIRECT_PAYMENT": 169, + "tecAMM_FAILED_VOTE": 170, + "tecBAD_XCHAIN_TRANSFER_ISSUE": 171, + "tecXCHAIN_NO_CLAIM_ID": 172, + "tecXCHAIN_BAD_CLAIM_ID": 173, + "tecXCHAIN_CLAIM_NO_QUORUM": 174, + "tecXCHAIN_PROOF_UNKNOWN_KEY": 175, + "tecXCHAIN_CREATE_ACCOUNT_NONXRP_ISSUE": 176, + "tecXCHAIN_CLAIM_ACCOUNT_DST_EXISTS": 177, + "tecXCHAIN_WRONG_CHAIN": 178, + "tecXCHAIN_REWARD_MISMATCH": 179, + "tecXCHAIN_NO_SIGNERS_LIST": 180, + "tecXCHAIN_SENDING_ACCOUNT_MISMATCH": 181, + "tecXCHAIN_INSUFF_CREATE_AMOUNT": 182, + "tecXCHAIN_ACCOUNT_CREATE_PAST": 183, + "tecXCHAIN_ACCOUNT_CREATE_TOO_MANY": 184, + "tecXCHAIN_PAYMENT_FAILED": 185, + "tecXCHAIN_SELF_COMMIT": 186 }, "TRANSACTION_TYPES": { "Invalid": -1, @@ -2660,13 +2671,13 @@ "NFTokenCreateOffer": 27, "NFTokenCancelOffer": 28, "NFTokenAcceptOffer": 29, - "XChainCreateBridge": 30, - "XChainCreateClaimID": 31, - "XChainCommit": 32, - "XChainClaim": 33, - "SidechainXChainAccountCreate": 34, - "XChainAddAttestation": 36, - "XChainModifyBridge": 37, + "XChainCreateBridge": 40, + "XChainCreateClaimID": 41, + "XChainCommit": 42, + "XChainClaim": 43, + "SidechainXChainAccountCreate": 44, + "XChainAddAttestation": 45, + "XChainModifyBridge": 46, "EnableAmendment": 100, "SetFee": 101, "UNLModify": 102 From 5c0e9a401107b004c1a87cbf58ff0660734ddd34 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Wed, 31 Aug 2022 19:23:53 +0300 Subject: [PATCH 040/111] more updates --- .../fixtures/data/codec-fixtures.json | 18 +++++++++--------- .../binarycodec/definitions/definitions.json | 19 ++++--------------- xrpl/models/transactions/__init__.py | 8 ++++---- .../transactions/types/transaction_type.py | 2 +- ...ate.py => xchain_account_create_commit.py} | 8 ++++---- 5 files changed, 22 insertions(+), 33 deletions(-) rename xrpl/models/transactions/{sidechain_xchain_account_create.py => xchain_account_create_commit.py} (73%) diff --git a/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json b/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json index d4accb481..c39ed30ff 100644 --- a/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json +++ b/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json @@ -4451,7 +4451,7 @@ } }, { - "binary": "1200282200000000240000000168400000000000000A601D40000000000003E8601E400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020744630440220101BCA4B5B5A37C6F44480F9A34752C9AA8B2CDF5AD47E3CB424DEDC21C06DB702206EEB257E82A89B1F46A0A2C7F070B0BD181D980FF86FE4269E369F6FC7A270918114B5F762798A53D543A014CAF8B297CFF8F2F937E8011A14AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", + "binary": "1200282200000000240000000168400000000000000A601D40000000000003E8601E400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020744630440220101BCA4B5B5A37C6F44480F9A34752C9AA8B2CDF5AD47E3CB424DEDC21C06DB702206EEB257E82A89B1F46A0A2C7F070B0BD181D980FF86FE4269E369F6FC7A270918114B5F762798A53D543A014CAF8B297CFF8F2F937E8011914AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", "json": { "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "XChainBridge": { @@ -4471,7 +4471,7 @@ } }, { - "binary": "12002E2200000000240000000168400000000000000A601D40000000000003E8601E400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02074473045022100D2CABC1B0E0635A8EE2E6554F6D474C49BC292C995C5C9F83179F4A60634B04C02205D1DB569D9593136F2FBEA7140010C8F46794D653AFDBEA8D30B8750BA4805E58114B5F762798A53D543A014CAF8B297CFF8F2F937E8011A14AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", + "binary": "12002E2200000000240000000168400000000000000A601D40000000000003E8601E400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02074473045022100D2CABC1B0E0635A8EE2E6554F6D474C49BC292C995C5C9F83179F4A60634B04C02205D1DB569D9593136F2FBEA7140010C8F46794D653AFDBEA8D30B8750BA4805E58114B5F762798A53D543A014CAF8B297CFF8F2F937E8011914AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", "json": { "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "XChainBridge": { @@ -4491,7 +4491,7 @@ } }, { - "binary": "1200292280000000240000000168400000000000000A601D400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020744630440220247B20A1B9C48E21A374CB9B3E1FE2A7C528151868DF8D307E9FBE15237E531A02207C20C092DDCC525E583EF4AB7CB91E862A6DED19426997D3F0A2C84E2BE8C5DD8114B5F762798A53D543A014CAF8B297CFF8F2F937E8801214AF80285F637EE4AF3C20378F9DFB12511ACB8D27011A14AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", + "binary": "1200292280000000240000000168400000000000000A601D400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020744630440220247B20A1B9C48E21A374CB9B3E1FE2A7C528151868DF8D307E9FBE15237E531A02207C20C092DDCC525E583EF4AB7CB91E862A6DED19426997D3F0A2C84E2BE8C5DD8114B5F762798A53D543A014CAF8B297CFF8F2F937E8801214AF80285F637EE4AF3C20378F9DFB12511ACB8D27011914AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", "json": { "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "XChainBridge": { @@ -4511,7 +4511,7 @@ } }, { - "binary": "12002A228000000024000000013014000000000000000161400000000000271068400000000000000A73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02074453043021F177323F0D93612C82A4393A99B23905A7E675753FD80C52997AFAB13F5F9D002203BFFAF457E90BDA65AABE8F8762BD96162FAD98A0C030CCD69B06EE9B12BBFFE8114B5F762798A53D543A014CAF8B297CFF8F2F937E8011A14AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", + "binary": "12002A228000000024000000013014000000000000000161400000000000271068400000000000000A73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02074453043021F177323F0D93612C82A4393A99B23905A7E675753FD80C52997AFAB13F5F9D002203BFFAF457E90BDA65AABE8F8762BD96162FAD98A0C030CCD69B06EE9B12BBFFE8114B5F762798A53D543A014CAF8B297CFF8F2F937E8011914AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", "json": { "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "Amount": "10000", @@ -4531,7 +4531,7 @@ } }, { - "binary": "12002B228000000024000000013014000000000000000161400000000000271068400000000000000A73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020744630440220445F7469FDA401787D9EE8A9B6E24DFF81E94F4C09FD311D2C0A58FCC02C684A022029E2EF34A5EA35F50D5BB57AC6320AD3AE12C13C8D1379B255A486D72CED142E8114B5F762798A53D543A014CAF8B297CFF8F2F937E88314550FC62003E785DC231A1058A05E56E3F09CF4E6011A14AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", + "binary": "12002B228000000024000000013014000000000000000161400000000000271068400000000000000A73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020744630440220445F7469FDA401787D9EE8A9B6E24DFF81E94F4C09FD311D2C0A58FCC02C684A022029E2EF34A5EA35F50D5BB57AC6320AD3AE12C13C8D1379B255A486D72CED142E8114B5F762798A53D543A014CAF8B297CFF8F2F937E88314550FC62003E785DC231A1058A05E56E3F09CF4E6011914AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", "json": { "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "Amount": "10000", @@ -4552,7 +4552,7 @@ } }, { - "binary": "12002D2280000000240000000468400000000000000A73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02074473045022100A6A8CA05B2B6CB60E0FD645A4DA0314D46D79D9FA3D63307FC997357366151B202202266CC23E2CA827905F37F78F54AD435F73A3B704EDD634B89201E23625CE2E28114B5F762798A53D543A014CAF8B297CFF8F2F937E8011B14C48CAD01682D7A86296EF14523074D4852C02EA9000000000000000000000000000000000000000014CC86E58C9B58D4CF71CB8C1B41F21BB290CE13D40000000000000000000000000000000000000000E02330140000000000000000614000000005F5E100712103DAB289CA36FF377F3F4304C7A7203FDE5EDCBFC209F430F6A4355361425526D0760361626381142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314621D345F8F094A085132431C69C89EC05D212CC28014142F3CC37C1D5616B3BBF1AABC49F6BFF46A92008700101301E1F1F1", + "binary": "12002D2280000000240000000468400000000000000A73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02074473045022100A6A8CA05B2B6CB60E0FD645A4DA0314D46D79D9FA3D63307FC997357366151B202202266CC23E2CA827905F37F78F54AD435F73A3B704EDD634B89201E23625CE2E28114B5F762798A53D543A014CAF8B297CFF8F2F937E8011A14C48CAD01682D7A86296EF14523074D4852C02EA9000000000000000000000000000000000000000014CC86E58C9B58D4CF71CB8C1B41F21BB290CE13D40000000000000000000000000000000000000000E02330140000000000000000614000000005F5E100712103DAB289CA36FF377F3F4304C7A7203FDE5EDCBFC209F430F6A4355361425526D0760361626381142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314621D345F8F094A085132431C69C89EC05D212CC28014142F3CC37C1D5616B3BBF1AABC49F6BFF46A92008700101301E1F1F1", "json": { "Account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "Fee" : "10", @@ -4587,7 +4587,7 @@ } }, { - "binary": "12002C228000000024000000016140000000000F424068400000000000000A601D400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD0207446304402202984DDE7F0B566F081F7953D7212BF031ACBF8860FE114102E9512C4C8768C77022070113F4630B1DC3045E4A98DDD648CEBC31B12774F7B44A1B8123CD2C9F5CF188114B5F762798A53D543A014CAF8B297CFF8F2F937E88314AF80285F637EE4AF3C20378F9DFB12511ACB8D27011A14AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", + "binary": "12002C228000000024000000016140000000000F424068400000000000000A601D400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD0207446304402202984DDE7F0B566F081F7953D7212BF031ACBF8860FE114102E9512C4C8768C77022070113F4630B1DC3045E4A98DDD648CEBC31B12774F7B44A1B8123CD2C9F5CF188114B5F762798A53D543A014CAF8B297CFF8F2F937E88314AF80285F637EE4AF3C20378F9DFB12511ACB8D27011914AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", "json": { "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "XChainBridge": { @@ -4603,12 +4603,12 @@ "Sequence": 1, "SignatureReward": "10000", "SigningPubKey": "0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020", - "TransactionType": "SidechainXChainAccountCreate", + "TransactionType": "XChainAccountCreateCommit", "TxnSignature": "304402202984DDE7F0B566F081F7953D7212BF031ACBF8860FE114102E9512C4C8768C77022070113F4630B1DC3045E4A98DDD648CEBC31B12774F7B44A1B8123CD2C9F5CF18" } }, { - "binary": "12002D2280000000240000000168400000000000000A73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD0207447304502210098F47661D8EF89CC2DFF3EAA92AF3843CEFD398EAD1E7496FAEAC269DE688FB80220143EBE519FC1936E884B1AFA047D4CB7CD2E2A28F0B27EC982D1BB3E63FC95358114B5F762798A53D543A014CAF8B297CFF8F2F937E8011B14C48CAD01682D7A86296EF14523074D4852C02EA9000000000000000000000000000000000000000014CC86E58C9B58D4CF71CB8C1B41F21BB290CE13D40000000000000000000000000000000000000000F1E0243015000000000000000161400000003B9ACA00601D40000000000F4240712103ADB44CA8E56F78A0096825E5667C450ABD5C24C34E027BC1AAF7E5BD114CB5B576463044022036C8B90F85E8073C465F00625248A72D4714600F98EBBADBAD3B7ED226109A3A02204C5A0AE12D169CF790F66541F3DB59C289E0D99CA7511FDFE352BB601F667A2681142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801414A482A071D77722C2B683FFE01DC30134035E8E7200101301E1E0243015000000000000000161400000003B9ACA00601D40000000000F4240712102A14E886B3C3579FBAE3139F29728B903E6F4295AEE92160C8480695524D66A157646304402200C3F5EEE2D7DCB609EE8558258E6AAF1EF823133C2B7C716E0DC9AAD2110F08D0220180E9F285CB2F78E362D37E947C000A8ED60A4BD8EFF21F74C5E529E1A8870ED81142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801414A482A071D77722C2B683FFE01DC30134035E8E7200101301E1E0243015000000000000000161400000003B9ACA00601D40000000000F4240712102F7390DCF3352060847B81666EBAC79D52DEA2443BDF58439F75397C45334E2DC764730450221008E31CFF0198F09CBA8610A946C23E170A3F11BCB8FC95D0D56C7B79A126D97D102203F4E952C449F2F01C4AF67FC37772A0D4459D770387CC11DBD5464FAB218542881142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801414A482A071D77722C2B683FFE01DC30134035E8E7200101301E1E0243015000000000000000161400000003B9ACA00601D40000000000F4240712102498BD8CD9CA6A4BA567A2ECFA163F118AFD30511CBBA71429C2EC2F74D76059276473045022100F4E2D672F456CB9929EF01766AB72B42C71314A181232098563B8666E4EEA49C02203F936877E9DCC8FF5F7713579233985DF3DADB155F2BDA78FE3A4321373F370E81142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801414A482A071D77722C2B683FFE01DC30134035E8E7200101301E1E0243015000000000000000161400000003B9ACA00601D40000000000F4240712103219642288DEE8A3AA8FEA1F7DAE9ED4D9A9F0EADA1E2DE3DB56DD9598D9AD81776473045022100D1BAFA57F40E16485310698B7B0BD0D4650E18782C4D65787A393CBB6D659EB802204EA28303089CCCD1463866A1BA0493A9B135AEA1EDFC8DD69A1A247DD9FEDB2181142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801414A482A071D77722C2B683FFE01DC30134035E8E7200101301E1F1", + "binary": "12002D2280000000240000000168400000000000000A73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD0207447304502210098F47661D8EF89CC2DFF3EAA92AF3843CEFD398EAD1E7496FAEAC269DE688FB80220143EBE519FC1936E884B1AFA047D4CB7CD2E2A28F0B27EC982D1BB3E63FC95358114B5F762798A53D543A014CAF8B297CFF8F2F937E8011A14C48CAD01682D7A86296EF14523074D4852C02EA9000000000000000000000000000000000000000014CC86E58C9B58D4CF71CB8C1B41F21BB290CE13D40000000000000000000000000000000000000000F1E0243015000000000000000161400000003B9ACA00601D40000000000F4240712103ADB44CA8E56F78A0096825E5667C450ABD5C24C34E027BC1AAF7E5BD114CB5B576463044022036C8B90F85E8073C465F00625248A72D4714600F98EBBADBAD3B7ED226109A3A02204C5A0AE12D169CF790F66541F3DB59C289E0D99CA7511FDFE352BB601F667A2681142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801414A482A071D77722C2B683FFE01DC30134035E8E7200101301E1E0243015000000000000000161400000003B9ACA00601D40000000000F4240712102A14E886B3C3579FBAE3139F29728B903E6F4295AEE92160C8480695524D66A157646304402200C3F5EEE2D7DCB609EE8558258E6AAF1EF823133C2B7C716E0DC9AAD2110F08D0220180E9F285CB2F78E362D37E947C000A8ED60A4BD8EFF21F74C5E529E1A8870ED81142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801414A482A071D77722C2B683FFE01DC30134035E8E7200101301E1E0243015000000000000000161400000003B9ACA00601D40000000000F4240712102F7390DCF3352060847B81666EBAC79D52DEA2443BDF58439F75397C45334E2DC764730450221008E31CFF0198F09CBA8610A946C23E170A3F11BCB8FC95D0D56C7B79A126D97D102203F4E952C449F2F01C4AF67FC37772A0D4459D770387CC11DBD5464FAB218542881142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801414A482A071D77722C2B683FFE01DC30134035E8E7200101301E1E0243015000000000000000161400000003B9ACA00601D40000000000F4240712102498BD8CD9CA6A4BA567A2ECFA163F118AFD30511CBBA71429C2EC2F74D76059276473045022100F4E2D672F456CB9929EF01766AB72B42C71314A181232098563B8666E4EEA49C02203F936877E9DCC8FF5F7713579233985DF3DADB155F2BDA78FE3A4321373F370E81142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801414A482A071D77722C2B683FFE01DC30134035E8E7200101301E1E0243015000000000000000161400000003B9ACA00601D40000000000F4240712103219642288DEE8A3AA8FEA1F7DAE9ED4D9A9F0EADA1E2DE3DB56DD9598D9AD81776473045022100D1BAFA57F40E16485310698B7B0BD0D4650E18782C4D65787A393CBB6D659EB802204EA28303089CCCD1463866A1BA0493A9B135AEA1EDFC8DD69A1A247DD9FEDB2181142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801414A482A071D77722C2B683FFE01DC30134035E8E7200101301E1F1", "json": { "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "Fee": "10", diff --git a/xrpl/core/binarycodec/definitions/definitions.json b/xrpl/core/binarycodec/definitions/definitions.json index ab19d79ae..c90297ff7 100644 --- a/xrpl/core/binarycodec/definitions/definitions.json +++ b/xrpl/core/binarycodec/definitions/definitions.json @@ -21,10 +21,9 @@ "UInt192": 21, "UInt384": 22, "UInt512": 23, - "XChainClaimProof": 24, - "Issue": 25, - "XChainBridge": 26, - "XChainAttestationBatch": 27, + "Issue": 24, + "XChainBridge": 25, + "XChainAttestationBatch": 26, "Transaction": 10001, "LedgerEntry": 10002, "Validation": 10003, @@ -1958,16 +1957,6 @@ "type": "PathSet" } ], - [ - "XChainClaimProof", - { - "nth": 1, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "XChainClaimProof" - } - ], [ "LockingChainIssue", { @@ -2675,7 +2664,7 @@ "XChainCreateClaimID": 41, "XChainCommit": 42, "XChainClaim": 43, - "SidechainXChainAccountCreate": 44, + "XChainAccountCreateCommit": 44, "XChainAddAttestation": 45, "XChainModifyBridge": 46, "EnableAmendment": 100, diff --git a/xrpl/models/transactions/__init__.py b/xrpl/models/transactions/__init__.py index c1d9d87ba..01fe949f2 100644 --- a/xrpl/models/transactions/__init__.py +++ b/xrpl/models/transactions/__init__.py @@ -45,9 +45,6 @@ from xrpl.models.transactions.payment_channel_create import PaymentChannelCreate from xrpl.models.transactions.payment_channel_fund import PaymentChannelFund from xrpl.models.transactions.set_regular_key import SetRegularKey -from xrpl.models.transactions.sidechain_xchain_account_create import ( - SidechainXChainAccountCreate, -) from xrpl.models.transactions.signer_list_set import SignerEntry, SignerListSet from xrpl.models.transactions.ticket_create import TicketCreate from xrpl.models.transactions.transaction import Memo, Signer, Transaction @@ -56,6 +53,9 @@ TrustSetFlag, TrustSetFlagInterface, ) +from xrpl.models.transactions.xchain_account_create_commit import ( + XChainAccountCreateCommit, +) from xrpl.models.transactions.xchain_add_attestation import XChainAddAttestation from xrpl.models.transactions.xchain_claim import XChainClaim from xrpl.models.transactions.xchain_commit import XChainCommit @@ -113,5 +113,5 @@ "XChainCreateBridge", "XChainCreateClaimID", "XChainModifyBridge", - "SidechainXChainAccountCreate", + "XChainAccountCreateCommit", ] diff --git a/xrpl/models/transactions/types/transaction_type.py b/xrpl/models/transactions/types/transaction_type.py index 13048e8b4..9b926e525 100644 --- a/xrpl/models/transactions/types/transaction_type.py +++ b/xrpl/models/transactions/types/transaction_type.py @@ -33,7 +33,7 @@ class TransactionType(str, Enum): XCHAIN_ADD_ATTESTATION = "XChainAddAttestation" XCHAIN_CLAIM = "XChainClaim" XCHAIN_COMMIT = "XChainCommit" - SIDECHAIN_XCHAIN_ACCOUNT_CREATE = "SidechainXChainAccountCreate" + XCHAIN_ACCOUNT_CREATE_COMMIT = "XChainAccountCreateCommit" XCHAIN_CREATE_BRIDGE = "XChainCreateBridge" XCHAIN_CREATE_CLAIM_ID = "XChainCreateClaimID" XCHAIN_MODIFY_BRIDGE = "XChainModifyBridge" diff --git a/xrpl/models/transactions/sidechain_xchain_account_create.py b/xrpl/models/transactions/xchain_account_create_commit.py similarity index 73% rename from xrpl/models/transactions/sidechain_xchain_account_create.py rename to xrpl/models/transactions/xchain_account_create_commit.py index bbfe2807f..cebc36b3b 100644 --- a/xrpl/models/transactions/sidechain_xchain_account_create.py +++ b/xrpl/models/transactions/xchain_account_create_commit.py @@ -1,4 +1,4 @@ -"""Model for a SidechainXChainAccountCreate transaction type.""" +"""Model for a XChainAccountCreateCommit transaction type.""" from dataclasses import dataclass, field @@ -12,8 +12,8 @@ @require_kwargs_on_init @dataclass(frozen=True) -class SidechainXChainAccountCreate(Transaction): - """Represents a SidechainXChainAccountCreate transaction.""" +class XChainAccountCreateCommit(Transaction): + """Represents a XChainAccountCreateCommit transaction.""" xchain_bridge: XChainBridge = REQUIRED # type: ignore @@ -24,6 +24,6 @@ class SidechainXChainAccountCreate(Transaction): amount: Amount = REQUIRED # type: ignore transaction_type: TransactionType = field( - default=TransactionType.SIDECHAIN_XCHAIN_ACCOUNT_CREATE, + default=TransactionType.XCHAIN_ACCOUNT_CREATE_COMMIT, init=False, ) From 7c333ff57ce6e826586e30aee58b99caa8409d3e Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Wed, 31 Aug 2022 19:48:24 +0300 Subject: [PATCH 041/111] fix fixtures --- .../fixtures/data/codec-fixtures.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json b/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json index c39ed30ff..c3bef7006 100644 --- a/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json +++ b/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json @@ -4552,7 +4552,7 @@ } }, { - "binary": "12002D2280000000240000000468400000000000000A73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02074473045022100A6A8CA05B2B6CB60E0FD645A4DA0314D46D79D9FA3D63307FC997357366151B202202266CC23E2CA827905F37F78F54AD435F73A3B704EDD634B89201E23625CE2E28114B5F762798A53D543A014CAF8B297CFF8F2F937E8011A14C48CAD01682D7A86296EF14523074D4852C02EA9000000000000000000000000000000000000000014CC86E58C9B58D4CF71CB8C1B41F21BB290CE13D40000000000000000000000000000000000000000E02330140000000000000000614000000005F5E100712103DAB289CA36FF377F3F4304C7A7203FDE5EDCBFC209F430F6A4355361425526D0760361626381142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314621D345F8F094A085132431C69C89EC05D212CC28014142F3CC37C1D5616B3BBF1AABC49F6BFF46A92008700101301E1F1F1", + "binary": "12002D2280000000240000000468400000000000000A73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02074473045022100A6A8CA05B2B6CB60E0FD645A4DA0314D46D79D9FA3D63307FC997357366151B202202266CC23E2CA827905F37F78F54AD435F73A3B704EDD634B89201E23625CE2E28114B5F762798A53D543A014CAF8B297CFF8F2F937E8011A14C48CAD01682D7A86296EF14523074D4852C02EA9000000000000000000000000000000000000000014CC86E58C9B58D4CF71CB8C1B41F21BB290CE13D40000000000000000000000000000000000000000E02330140000000000000000614000000005F5E100712103DAB289CA36FF377F3F4304C7A7203FDE5EDCBFC209F430F6A4355361425526D0760361626381142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314621D345F8F094A085132431C69C89EC05D212CC28015142F3CC37C1D5616B3BBF1AABC49F6BFF46A92008700101301E1F1F1", "json": { "Account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "Fee" : "10", @@ -4573,7 +4573,7 @@ "XChainClaimAttestationBatchElement" : { "Account" : "rnJmYAiqEVngtnb5ckRroXLtCbWC7CRUBx", "Amount" : "100000000", - "AttestationSignerAccount" : "rnJmYAiqEVngtnb5ckRroXLtCbWC7CRUBx", + "AttestationRewardAccount" : "rnJmYAiqEVngtnb5ckRroXLtCbWC7CRUBx", "Destination" : "r9A8UyNpW3X46FUc6P7JZqgn6WgAPjBwPg", "PublicKey" : "03DAB289CA36FF377F3F4304C7A7203FDE5EDCBFC209F430F6A4355361425526D0", "Signature" : "616263", @@ -4608,7 +4608,7 @@ } }, { - "binary": "12002D2280000000240000000168400000000000000A73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD0207447304502210098F47661D8EF89CC2DFF3EAA92AF3843CEFD398EAD1E7496FAEAC269DE688FB80220143EBE519FC1936E884B1AFA047D4CB7CD2E2A28F0B27EC982D1BB3E63FC95358114B5F762798A53D543A014CAF8B297CFF8F2F937E8011A14C48CAD01682D7A86296EF14523074D4852C02EA9000000000000000000000000000000000000000014CC86E58C9B58D4CF71CB8C1B41F21BB290CE13D40000000000000000000000000000000000000000F1E0243015000000000000000161400000003B9ACA00601D40000000000F4240712103ADB44CA8E56F78A0096825E5667C450ABD5C24C34E027BC1AAF7E5BD114CB5B576463044022036C8B90F85E8073C465F00625248A72D4714600F98EBBADBAD3B7ED226109A3A02204C5A0AE12D169CF790F66541F3DB59C289E0D99CA7511FDFE352BB601F667A2681142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801414A482A071D77722C2B683FFE01DC30134035E8E7200101301E1E0243015000000000000000161400000003B9ACA00601D40000000000F4240712102A14E886B3C3579FBAE3139F29728B903E6F4295AEE92160C8480695524D66A157646304402200C3F5EEE2D7DCB609EE8558258E6AAF1EF823133C2B7C716E0DC9AAD2110F08D0220180E9F285CB2F78E362D37E947C000A8ED60A4BD8EFF21F74C5E529E1A8870ED81142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801414A482A071D77722C2B683FFE01DC30134035E8E7200101301E1E0243015000000000000000161400000003B9ACA00601D40000000000F4240712102F7390DCF3352060847B81666EBAC79D52DEA2443BDF58439F75397C45334E2DC764730450221008E31CFF0198F09CBA8610A946C23E170A3F11BCB8FC95D0D56C7B79A126D97D102203F4E952C449F2F01C4AF67FC37772A0D4459D770387CC11DBD5464FAB218542881142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801414A482A071D77722C2B683FFE01DC30134035E8E7200101301E1E0243015000000000000000161400000003B9ACA00601D40000000000F4240712102498BD8CD9CA6A4BA567A2ECFA163F118AFD30511CBBA71429C2EC2F74D76059276473045022100F4E2D672F456CB9929EF01766AB72B42C71314A181232098563B8666E4EEA49C02203F936877E9DCC8FF5F7713579233985DF3DADB155F2BDA78FE3A4321373F370E81142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801414A482A071D77722C2B683FFE01DC30134035E8E7200101301E1E0243015000000000000000161400000003B9ACA00601D40000000000F4240712103219642288DEE8A3AA8FEA1F7DAE9ED4D9A9F0EADA1E2DE3DB56DD9598D9AD81776473045022100D1BAFA57F40E16485310698B7B0BD0D4650E18782C4D65787A393CBB6D659EB802204EA28303089CCCD1463866A1BA0493A9B135AEA1EDFC8DD69A1A247DD9FEDB2181142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801414A482A071D77722C2B683FFE01DC30134035E8E7200101301E1F1", + "binary": "12002D2280000000240000000168400000000000000A73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD0207447304502210098F47661D8EF89CC2DFF3EAA92AF3843CEFD398EAD1E7496FAEAC269DE688FB80220143EBE519FC1936E884B1AFA047D4CB7CD2E2A28F0B27EC982D1BB3E63FC95358114B5F762798A53D543A014CAF8B297CFF8F2F937E8011A14C48CAD01682D7A86296EF14523074D4852C02EA9000000000000000000000000000000000000000014CC86E58C9B58D4CF71CB8C1B41F21BB290CE13D40000000000000000000000000000000000000000F1E0243015000000000000000161400000003B9ACA00601D40000000000F4240712103ADB44CA8E56F78A0096825E5667C450ABD5C24C34E027BC1AAF7E5BD114CB5B576463044022036C8B90F85E8073C465F00625248A72D4714600F98EBBADBAD3B7ED226109A3A02204C5A0AE12D169CF790F66541F3DB59C289E0D99CA7511FDFE352BB601F667A2681142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801514A482A071D77722C2B683FFE01DC30134035E8E7200101301E1E0243015000000000000000161400000003B9ACA00601D40000000000F4240712102A14E886B3C3579FBAE3139F29728B903E6F4295AEE92160C8480695524D66A157646304402200C3F5EEE2D7DCB609EE8558258E6AAF1EF823133C2B7C716E0DC9AAD2110F08D0220180E9F285CB2F78E362D37E947C000A8ED60A4BD8EFF21F74C5E529E1A8870ED81142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801514A482A071D77722C2B683FFE01DC30134035E8E7200101301E1E0243015000000000000000161400000003B9ACA00601D40000000000F4240712102F7390DCF3352060847B81666EBAC79D52DEA2443BDF58439F75397C45334E2DC764730450221008E31CFF0198F09CBA8610A946C23E170A3F11BCB8FC95D0D56C7B79A126D97D102203F4E952C449F2F01C4AF67FC37772A0D4459D770387CC11DBD5464FAB218542881142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801514A482A071D77722C2B683FFE01DC30134035E8E7200101301E1E0243015000000000000000161400000003B9ACA00601D40000000000F4240712102498BD8CD9CA6A4BA567A2ECFA163F118AFD30511CBBA71429C2EC2F74D76059276473045022100F4E2D672F456CB9929EF01766AB72B42C71314A181232098563B8666E4EEA49C02203F936877E9DCC8FF5F7713579233985DF3DADB155F2BDA78FE3A4321373F370E81142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801514A482A071D77722C2B683FFE01DC30134035E8E7200101301E1E0243015000000000000000161400000003B9ACA00601D40000000000F4240712103219642288DEE8A3AA8FEA1F7DAE9ED4D9A9F0EADA1E2DE3DB56DD9598D9AD81776473045022100D1BAFA57F40E16485310698B7B0BD0D4650E18782C4D65787A393CBB6D659EB802204EA28303089CCCD1463866A1BA0493A9B135AEA1EDFC8DD69A1A247DD9FEDB2181142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801514A482A071D77722C2B683FFE01DC30134035E8E7200101301E1F1", "json": { "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "Fee": "10", @@ -4630,7 +4630,7 @@ "XChainCreateAccountAttestationBatchElement": { "Account": "rnJmYAiqEVngtnb5ckRroXLtCbWC7CRUBx", "Amount": "1000000000", - "AttestationSignerAccount": "rEziJZmeZzsJvGVUmpUTey7qxQLKYxaK9f", + "AttestationRewardAccount": "rEziJZmeZzsJvGVUmpUTey7qxQLKYxaK9f", "Destination": "rKT9gDkaedAosiHyHZTjyZs2HvXpzuiGmC", "PublicKey": "03ADB44CA8E56F78A0096825E5667C450ABD5C24C34E027BC1AAF7E5BD114CB5B5", "Signature": "3044022036C8B90F85E8073C465F00625248A72D4714600F98EBBADBAD3B7ED226109A3A02204C5A0AE12D169CF790F66541F3DB59C289E0D99CA7511FDFE352BB601F667A26", @@ -4643,7 +4643,7 @@ "XChainCreateAccountAttestationBatchElement": { "Account": "rnJmYAiqEVngtnb5ckRroXLtCbWC7CRUBx", "Amount": "1000000000", - "AttestationSignerAccount": "rEziJZmeZzsJvGVUmpUTey7qxQLKYxaK9f", + "AttestationRewardAccount": "rEziJZmeZzsJvGVUmpUTey7qxQLKYxaK9f", "Destination": "rKT9gDkaedAosiHyHZTjyZs2HvXpzuiGmC", "PublicKey": "02A14E886B3C3579FBAE3139F29728B903E6F4295AEE92160C8480695524D66A15", "Signature": "304402200C3F5EEE2D7DCB609EE8558258E6AAF1EF823133C2B7C716E0DC9AAD2110F08D0220180E9F285CB2F78E362D37E947C000A8ED60A4BD8EFF21F74C5E529E1A8870ED", @@ -4656,7 +4656,7 @@ "XChainCreateAccountAttestationBatchElement": { "Account": "rnJmYAiqEVngtnb5ckRroXLtCbWC7CRUBx", "Amount": "1000000000", - "AttestationSignerAccount": "rEziJZmeZzsJvGVUmpUTey7qxQLKYxaK9f", + "AttestationRewardAccount": "rEziJZmeZzsJvGVUmpUTey7qxQLKYxaK9f", "Destination": "rKT9gDkaedAosiHyHZTjyZs2HvXpzuiGmC", "PublicKey": "02F7390DCF3352060847B81666EBAC79D52DEA2443BDF58439F75397C45334E2DC", "Signature": "30450221008E31CFF0198F09CBA8610A946C23E170A3F11BCB8FC95D0D56C7B79A126D97D102203F4E952C449F2F01C4AF67FC37772A0D4459D770387CC11DBD5464FAB2185428", @@ -4669,7 +4669,7 @@ "XChainCreateAccountAttestationBatchElement": { "Account": "rnJmYAiqEVngtnb5ckRroXLtCbWC7CRUBx", "Amount": "1000000000", - "AttestationSignerAccount": "rEziJZmeZzsJvGVUmpUTey7qxQLKYxaK9f", + "AttestationRewardAccount": "rEziJZmeZzsJvGVUmpUTey7qxQLKYxaK9f", "Destination": "rKT9gDkaedAosiHyHZTjyZs2HvXpzuiGmC", "PublicKey": "02498BD8CD9CA6A4BA567A2ECFA163F118AFD30511CBBA71429C2EC2F74D760592", "Signature": "3045022100F4E2D672F456CB9929EF01766AB72B42C71314A181232098563B8666E4EEA49C02203F936877E9DCC8FF5F7713579233985DF3DADB155F2BDA78FE3A4321373F370E", @@ -4682,7 +4682,7 @@ "XChainCreateAccountAttestationBatchElement": { "Account": "rnJmYAiqEVngtnb5ckRroXLtCbWC7CRUBx", "Amount": "1000000000", - "AttestationSignerAccount": "rEziJZmeZzsJvGVUmpUTey7qxQLKYxaK9f", + "AttestationRewardAccount": "rEziJZmeZzsJvGVUmpUTey7qxQLKYxaK9f", "Destination": "rKT9gDkaedAosiHyHZTjyZs2HvXpzuiGmC", "PublicKey": "03219642288DEE8A3AA8FEA1F7DAE9ED4D9A9F0EADA1E2DE3DB56DD9598D9AD817", "Signature": "3045022100D1BAFA57F40E16485310698B7B0BD0D4650E18782C4D65787A393CBB6D659EB802204EA28303089CCCD1463866A1BA0493A9B135AEA1EDFC8DD69A1A247DD9FEDB21", From 75a43ecfc7683ddbc58f53e891c76a367a66e8dd Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Thu, 1 Sep 2022 11:11:19 +0300 Subject: [PATCH 042/111] update rpcs --- xrpl/models/requests/account_objects.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xrpl/models/requests/account_objects.py b/xrpl/models/requests/account_objects.py index d46d81acf..d8e94567b 100644 --- a/xrpl/models/requests/account_objects.py +++ b/xrpl/models/requests/account_objects.py @@ -26,7 +26,7 @@ class AccountObjectType(str, Enum): SIGNER_LIST = "signer_list" STATE = "state" TICKET = "ticket" - XCHAIN_SEQ = "xchain_seq" + XCHAIN_CLAIM_ID = "xchain_claim_id" @require_kwargs_on_init From 98b807d48d88a91221d0cc208d24874e37066b12 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Fri, 30 Sep 2022 12:28:46 -0400 Subject: [PATCH 043/111] use NestedModel --- .vscode/settings.json | 3 +- mypy.ini | 2 +- .../transactions/xchain_add_attestation.py | 130 +----------------- 3 files changed, 7 insertions(+), 128 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 484b83a52..b8be05d5b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -15,6 +15,7 @@ "nftoken", "rippletest", "ripplex", - "xaddress" + "xaddress", + "xchain" ], } diff --git a/mypy.ini b/mypy.ini index d1c0e9110..ec65bc07d 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1,2 +1,2 @@ [mypy] -exclude = dist +exclude = ['.venv', 'dist'] diff --git a/xrpl/models/transactions/xchain_add_attestation.py b/xrpl/models/transactions/xchain_add_attestation.py index 06e429773..5bbab956e 100644 --- a/xrpl/models/transactions/xchain_add_attestation.py +++ b/xrpl/models/transactions/xchain_add_attestation.py @@ -3,12 +3,13 @@ from __future__ import annotations from dataclasses import dataclass, field -from typing import Any, Dict, List, Optional, Type, Union +from typing import List, Optional, Union from typing_extensions import Literal from xrpl.models.amounts import Amount from xrpl.models.base_model import BaseModel +from xrpl.models.nested_model import NestedModel from xrpl.models.required import REQUIRED from xrpl.models.transactions.transaction import Transaction from xrpl.models.transactions.types import TransactionType @@ -18,7 +19,7 @@ @require_kwargs_on_init @dataclass(frozen=True) -class XChainClaimAttestationBatchElement(BaseModel): +class XChainClaimAttestationBatchElement(NestedModel): """Represents a single claim attestation.""" account: str = REQUIRED # type: ignore @@ -37,68 +38,10 @@ class XChainClaimAttestationBatchElement(BaseModel): xchain_claim_id: str = REQUIRED # type: ignore - @classmethod - def is_dict_of_model( - cls: Type[XChainClaimAttestationBatchElement], dictionary: Dict[str, Any] - ) -> bool: - """ - Returns True if the input dictionary was derived by the `to_dict` - method of an instance of this class. In other words, True if this is - a dictionary representation of an instance of this class. - - NOTE: does not account for model inheritance, IE will only return True - if dictionary represents an instance of this class, but not if - dictionary represents an instance of a subclass of this class. - - Args: - dictionary: The dictionary to check. - - Returns: - True if dictionary is a dict representation of an instance of this - class. - """ - return ( - isinstance(dictionary, dict) - and "xchain_claim_attestation_batch_element" in dictionary - and super().is_dict_of_model( - dictionary["xchain_claim_attestation_batch_element"] - ) - ) - - @classmethod - def from_dict( - cls: Type[XChainClaimAttestationBatchElement], value: Dict[str, Any] - ) -> XChainClaimAttestationBatchElement: - """ - Construct a new XChainClaimAttestationBatchElement from a dictionary of - parameters. - - Args: - value: The value to construct the XChainClaimAttestationBatchElement from. - - Returns: - A new XChainClaimAttestationBatchElement object, constructed using the - given parameters. - """ - if len(value) == 1 and "xchain_claim_attestation_batch_element" in value: - return super(XChainClaimAttestationBatchElement, cls).from_dict( - value["xchain_claim_attestation_batch_element"] - ) - return super(XChainClaimAttestationBatchElement, cls).from_dict(value) - - def to_dict(self: XChainClaimAttestationBatchElement) -> Dict[str, Any]: - """ - Returns the dictionary representation of a XChainClaimAttestationBatchElement. - - Returns: - The dictionary representation of a XChainClaimAttestationBatchElement. - """ - return {"xchain_claim_attestation_batch_element": super().to_dict()} - @require_kwargs_on_init @dataclass(frozen=True) -class XChainCreateAccountAttestationBatchElement(BaseModel): +class XChainCreateAccountAttestationBatchElement(NestedModel): """Represents a single account creation attestation.""" account: str = REQUIRED # type: ignore @@ -119,71 +62,6 @@ class XChainCreateAccountAttestationBatchElement(BaseModel): xchain_account_create_count: str = REQUIRED # type: ignore - @classmethod - def is_dict_of_model( - cls: Type[XChainCreateAccountAttestationBatchElement], - dictionary: Dict[str, Any], - ) -> bool: - """ - Returns True if the input dictionary was derived by the `to_dict` - method of an instance of this class. In other words, True if this is - a dictionary representation of an instance of this class. - - NOTE: does not account for model inheritance, IE will only return True - if dictionary represents an instance of this class, but not if - dictionary represents an instance of a subclass of this class. - - Args: - dictionary: The dictionary to check. - - Returns: - True if dictionary is a dict representation of an instance of this - class. - """ - return ( - isinstance(dictionary, dict) - and "xchain_create_account_attestation_batch_element" in dictionary - and super().is_dict_of_model( - dictionary["xchain_create_account_attestation_batch_element"] - ) - ) - - @classmethod - def from_dict( - cls: Type[XChainCreateAccountAttestationBatchElement], value: Dict[str, Any] - ) -> XChainCreateAccountAttestationBatchElement: - """ - Construct a new XChainCreateAccountAttestationBatchElement from a dictionary of - parameters. - - Args: - value: The value to construct the - XChainCreateAccountAttestationBatchElement from. - - Returns: - A new XChainCreateAccountAttestationBatchElement object, constructed using - the given parameters. - """ - if ( - len(value) == 1 - and "xchain_create_account_attestation_batch_element" in value - ): - return super(XChainCreateAccountAttestationBatchElement, cls).from_dict( - value["xchain_create_account_attestation_batch_element"] - ) - return super(XChainCreateAccountAttestationBatchElement, cls).from_dict(value) - - def to_dict(self: XChainCreateAccountAttestationBatchElement) -> Dict[str, Any]: - """ - Returns the dictionary representation of a - XChainCreateAccountAttestationBatchElement. - - Returns: - The dictionary representation of a - XChainCreateAccountAttestationBatchElement. - """ - return {"xchain_create_account_attestation_batch_element": super().to_dict()} - @require_kwargs_on_init @dataclass(frozen=True) From 042fb26cb547ef9f63479caf332bd571be3ac6a8 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Fri, 30 Sep 2022 12:33:21 -0400 Subject: [PATCH 044/111] make test easier to read --- tests/unit/models/test_base_model.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/models/test_base_model.py b/tests/unit/models/test_base_model.py index c0861d19a..3b6cd5077 100644 --- a/tests/unit/models/test_base_model.py +++ b/tests/unit/models/test_base_model.py @@ -614,7 +614,7 @@ def test_to_from_xrpl_xchain(self): "TransactionType": "XChainClaim", "Flags": 0, "SigningPubKey": "", - "XChainClaimID": "0000000000000001", + "XChainClaimID": 1, } tx_obj = XChainClaim( account=account, @@ -626,7 +626,7 @@ def test_to_from_xrpl_xchain(self): issuing_chain_issue="XRP", ), destination=destination, - xchain_claim_id="0000000000000001", + xchain_claim_id=1, ) self.assertEqual(tx_obj.to_xrpl(), tx_json) self.assertEqual(Transaction.from_xrpl(tx_json), tx_obj) From 677876e8a9aa839138d36275565fcfd138440392 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Fri, 30 Sep 2022 12:44:44 -0400 Subject: [PATCH 045/111] respond to comments --- xrpl/core/binarycodec/types/issued_currency.py | 2 +- xrpl/core/binarycodec/types/xchain_bridge.py | 2 +- xrpl/models/transactions/transaction.py | 4 ++-- xrpl/wallet/main.py | 1 - 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/xrpl/core/binarycodec/types/issued_currency.py b/xrpl/core/binarycodec/types/issued_currency.py index ab284ec57..9427a6fad 100644 --- a/xrpl/core/binarycodec/types/issued_currency.py +++ b/xrpl/core/binarycodec/types/issued_currency.py @@ -71,7 +71,7 @@ def from_parser( if currency.to_json() == "XRP": return cls(bytes(currency)) - issuer = parser.read(20) + issuer = parser.read(20) # the length in bytes of an account ID return cls(bytes(currency) + issuer) def to_json(self: IssuedCurrency) -> Union[str, Dict[Any, Any]]: diff --git a/xrpl/core/binarycodec/types/xchain_bridge.py b/xrpl/core/binarycodec/types/xchain_bridge.py index f9b385611..3e96c77fb 100644 --- a/xrpl/core/binarycodec/types/xchain_bridge.py +++ b/xrpl/core/binarycodec/types/xchain_bridge.py @@ -47,7 +47,7 @@ def from_value( for (name, object_type) in _TYPE_ORDER: obj = object_type.from_value(value[name]) if object_type == AccountID: - buffer += bytes.fromhex("14") + buffer += bytes.fromhex("14") # AccountID length (I think) buffer += bytes(obj) return cls(buffer) diff --git a/xrpl/models/transactions/transaction.py b/xrpl/models/transactions/transaction.py index 414da363a..fc30aa206 100644 --- a/xrpl/models/transactions/transaction.py +++ b/xrpl/models/transactions/transaction.py @@ -30,6 +30,8 @@ "xchain": "XChain", } + +# special cases that should not be snake cased and only contain primitive members _LOWER_CASE_MODELS: List[Type[BaseModel]] = [ IssuedCurrencyAmount, PathStep, @@ -73,8 +75,6 @@ def _key_to_tx_json(key: str) -> str: def _value_to_tx_json(value: XRPL_VALUE_TYPE) -> XRPL_VALUE_TYPE: - # IssuedCurrencyAmount and PathStep are special cases and should not be snake cased - # and only contain primitive members if any([model.is_dict_of_model(value) for model in _LOWER_CASE_MODELS]): return value if isinstance(value, dict): diff --git a/xrpl/wallet/main.py b/xrpl/wallet/main.py index 44b0bc6b0..29c42dabc 100644 --- a/xrpl/wallet/main.py +++ b/xrpl/wallet/main.py @@ -39,7 +39,6 @@ def __init__( """ pk, sk = derive_keypair(self.seed, algorithm=algorithm) - self.algorithm = algorithm self.public_key = pk """ The public key that is used to identify this wallet's signatures, as From fdba19d867c4d11889d8aaf4a3fa0cbccc28efd4 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Fri, 30 Sep 2022 12:50:26 -0400 Subject: [PATCH 046/111] fix mypy --- mypy.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypy.ini b/mypy.ini index ec65bc07d..d1c0e9110 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1,2 +1,2 @@ [mypy] -exclude = ['.venv', 'dist'] +exclude = dist From decdc5997b91e3ed6001c14d43f71cd32e20f922 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Tue, 4 Oct 2022 15:02:06 -0400 Subject: [PATCH 047/111] add destination tag to XChainClaim --- xrpl/models/transactions/xchain_claim.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xrpl/models/transactions/xchain_claim.py b/xrpl/models/transactions/xchain_claim.py index 736fc2a9d..5a7c86ad2 100644 --- a/xrpl/models/transactions/xchain_claim.py +++ b/xrpl/models/transactions/xchain_claim.py @@ -1,7 +1,7 @@ """Model for a XChainClaim transaction type.""" from dataclasses import dataclass, field -from typing import Union +from typing import Optional, Union from xrpl.models.amounts import Amount from xrpl.models.required import REQUIRED @@ -22,6 +22,8 @@ class XChainClaim(Transaction): destination: str = REQUIRED # type: ignore + destination_tag: Optional[int] = None + amount: Amount = REQUIRED # type: ignore transaction_type: TransactionType = field( From b20d0a72eb00f2efe4670cc169c4b3991fd21728 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Wed, 26 Oct 2022 10:24:25 -0400 Subject: [PATCH 048/111] fix import --- xrpl/models/requests/ledger_entry.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xrpl/models/requests/ledger_entry.py b/xrpl/models/requests/ledger_entry.py index 17990f883..62175442c 100644 --- a/xrpl/models/requests/ledger_entry.py +++ b/xrpl/models/requests/ledger_entry.py @@ -8,7 +8,9 @@ from __future__ import annotations from dataclasses import dataclass, field -from typing import Dict, List, Literal, Optional, Union +from typing import Dict, List, Optional, Union + +from typing_extensions import Literal from xrpl.models.base_model import BaseModel from xrpl.models.currencies import IssuedCurrency From c500d9969da0f76bedda6b4304fb9b38fdc8ae71 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Tue, 8 Nov 2022 14:17:04 -0500 Subject: [PATCH 049/111] rename IssuedCurrency -> Issue to match rippled --- xrpl/core/binarycodec/types/__init__.py | 4 +-- .../types/{issued_currency.py => issue.py} | 34 +++++++++---------- xrpl/core/binarycodec/types/xchain_bridge.py | 6 ++-- 3 files changed, 21 insertions(+), 23 deletions(-) rename xrpl/core/binarycodec/types/{issued_currency.py => issue.py} (67%) diff --git a/xrpl/core/binarycodec/types/__init__.py b/xrpl/core/binarycodec/types/__init__.py index 5052b9b15..8536b536c 100644 --- a/xrpl/core/binarycodec/types/__init__.py +++ b/xrpl/core/binarycodec/types/__init__.py @@ -7,7 +7,7 @@ from xrpl.core.binarycodec.types.hash128 import Hash128 from xrpl.core.binarycodec.types.hash160 import Hash160 from xrpl.core.binarycodec.types.hash256 import Hash256 -from xrpl.core.binarycodec.types.issued_currency import IssuedCurrency +from xrpl.core.binarycodec.types.issue import Issue from xrpl.core.binarycodec.types.path_set import PathSet from xrpl.core.binarycodec.types.st_array import STArray from xrpl.core.binarycodec.types.st_object import STObject @@ -29,7 +29,7 @@ "Hash128", "Hash160", "Hash256", - "IssuedCurrency", + "Issue", "PathSet", "STObject", "STArray", diff --git a/xrpl/core/binarycodec/types/issued_currency.py b/xrpl/core/binarycodec/types/issue.py similarity index 67% rename from xrpl/core/binarycodec/types/issued_currency.py rename to xrpl/core/binarycodec/types/issue.py index 9427a6fad..b3109cb38 100644 --- a/xrpl/core/binarycodec/types/issued_currency.py +++ b/xrpl/core/binarycodec/types/issue.py @@ -12,29 +12,27 @@ from xrpl.models.currencies import IssuedCurrency as IssuedCurrencyModel -class IssuedCurrency(SerializedType): +class Issue(SerializedType): """Codec for serializing and deserializing issued currency fields.""" - def __init__(self: IssuedCurrency, buffer: bytes) -> None: - """Construct an IssuedCurrency from given bytes.""" + def __init__(self: Issue, buffer: bytes) -> None: + """Construct an Issue from given bytes.""" super().__init__(buffer) @classmethod - def from_value( - cls: Type[IssuedCurrency], value: Union[str, Dict[str, str]] - ) -> IssuedCurrency: + def from_value(cls: Type[Issue], value: Union[str, Dict[str, str]]) -> Issue: """ - Construct an IssuedCurrency object from a string or dictionary representation + Construct an Issue object from a string or dictionary representation of an issued currency. Args: - value: The dictionary to construct an IssuedCurrency object from. + value: The dictionary to construct an Issue object from. Returns: - An IssuedCurrency object constructed from value. + An Issue object constructed from value. Raises: - XRPLBinaryCodecException: If the IssuedCurrency representation is invalid. + XRPLBinaryCodecException: If the Issue representation is invalid. """ if isinstance(value, str): if value != "XRP": @@ -47,25 +45,25 @@ def from_value( return cls(currency_bytes + issuer_bytes) raise XRPLBinaryCodecException( - "Invalid type to construct an IssuedCurrency: expected str or dict," + "Invalid type to construct an Issue: expected str or dict," f" received {value.__class__.__name__}." ) @classmethod def from_parser( - cls: Type[IssuedCurrency], + cls: Type[Issue], parser: BinaryParser, length_hint: Optional[int] = None, - ) -> IssuedCurrency: + ) -> Issue: """ - Construct an IssuedCurrency object from an existing BinaryParser. + Construct an Issue object from an existing BinaryParser. Args: - parser: The parser to construct the IssuedCurrency object from. + parser: The parser to construct the Issue object from. length_hint: The number of bytes to consume from the parser. Returns: - The IssuedCurrency object constructed from a parser. + The Issue object constructed from a parser. """ currency = Currency.from_parser(parser) if currency.to_json() == "XRP": @@ -74,12 +72,12 @@ def from_parser( issuer = parser.read(20) # the length in bytes of an account ID return cls(bytes(currency) + issuer) - def to_json(self: IssuedCurrency) -> Union[str, Dict[Any, Any]]: + def to_json(self: Issue) -> Union[str, Dict[Any, Any]]: """ Returns the JSON representation of an issued currency. Returns: - The JSON representation of an IssuedCurrency. + The JSON representation of an Issue. """ parser = BinaryParser(str(self)) currency: Union[str, Dict[Any, Any]] = Currency.from_parser(parser).to_json() diff --git a/xrpl/core/binarycodec/types/xchain_bridge.py b/xrpl/core/binarycodec/types/xchain_bridge.py index 3e96c77fb..227b5d414 100644 --- a/xrpl/core/binarycodec/types/xchain_bridge.py +++ b/xrpl/core/binarycodec/types/xchain_bridge.py @@ -6,14 +6,14 @@ from xrpl.core.binarycodec.binary_wrappers.binary_parser import BinaryParser from xrpl.core.binarycodec.exceptions import XRPLBinaryCodecException from xrpl.core.binarycodec.types.account_id import AccountID -from xrpl.core.binarycodec.types.issued_currency import IssuedCurrency +from xrpl.core.binarycodec.types.issue import Issue from xrpl.core.binarycodec.types.serialized_type import SerializedType _TYPE_ORDER: List[Tuple[str, Type[SerializedType]]] = [ ("LockingChainDoor", AccountID), - ("LockingChainIssue", IssuedCurrency), + ("LockingChainIssue", Issue), ("IssuingChainDoor", AccountID), - ("IssuingChainIssue", IssuedCurrency), + ("IssuingChainIssue", Issue), ] _TYPE_KEYS = {type[0] for type in _TYPE_ORDER} From debdd23eabf99fb3697281896e0d348b17de6d24 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Wed, 9 Nov 2022 22:18:06 -0500 Subject: [PATCH 050/111] add xchain bridge to account objects --- xrpl/models/requests/account_objects.py | 1 + 1 file changed, 1 insertion(+) diff --git a/xrpl/models/requests/account_objects.py b/xrpl/models/requests/account_objects.py index d8e94567b..7b93540bf 100644 --- a/xrpl/models/requests/account_objects.py +++ b/xrpl/models/requests/account_objects.py @@ -26,6 +26,7 @@ class AccountObjectType(str, Enum): SIGNER_LIST = "signer_list" STATE = "state" TICKET = "ticket" + XCHAIN_BRIDGE = "xchain_bridge" XCHAIN_CLAIM_ID = "xchain_claim_id" From b65f755c5ad29ca4fb716a4411f42cda1953b44a Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Thu, 10 Nov 2022 12:26:40 -0500 Subject: [PATCH 051/111] fix account objects filters --- xrpl/models/requests/account_objects.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xrpl/models/requests/account_objects.py b/xrpl/models/requests/account_objects.py index 7b93540bf..9626dfac8 100644 --- a/xrpl/models/requests/account_objects.py +++ b/xrpl/models/requests/account_objects.py @@ -26,7 +26,7 @@ class AccountObjectType(str, Enum): SIGNER_LIST = "signer_list" STATE = "state" TICKET = "ticket" - XCHAIN_BRIDGE = "xchain_bridge" + XCHAIN_CREATE_ACCOUNT_CLAIM_ID = "xchain_create_account_claim_id" XCHAIN_CLAIM_ID = "xchain_claim_id" From fbdd483f8b97c6b4c033a57aa0d3b88f26a10b58 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Wed, 16 Nov 2022 17:06:28 -0500 Subject: [PATCH 052/111] update Issue form --- .../fixtures/data/codec-fixtures.json | 32 +++++++++---------- xrpl/core/binarycodec/types/issue.py | 12 +++---- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json b/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json index c3bef7006..dae22f7ec 100644 --- a/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json +++ b/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json @@ -4456,9 +4456,9 @@ "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "XChainBridge": { "LockingChainDoor": "rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", - "LockingChainIssue": "XRP", + "LockingChainIssue": {"currency": "XRP"}, "IssuingChainDoor": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", - "IssuingChainIssue": "XRP" + "IssuingChainIssue": {"currency": "XRP"} }, "Fee": "10", "Flags": 0, @@ -4476,9 +4476,9 @@ "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "XChainBridge": { "LockingChainDoor": "rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", - "LockingChainIssue": "XRP", + "LockingChainIssue": {"currency": "XRP"}, "IssuingChainDoor": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", - "IssuingChainIssue": "XRP" + "IssuingChainIssue": {"currency": "XRP"} }, "Fee": "10", "Flags": 0, @@ -4496,9 +4496,9 @@ "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "XChainBridge": { "LockingChainDoor": "rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", - "LockingChainIssue": "XRP", + "LockingChainIssue": {"currency": "XRP"}, "IssuingChainDoor": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", - "IssuingChainIssue": "XRP" + "IssuingChainIssue": {"currency": "XRP"} }, "Fee": "10", "Flags": 2147483648, @@ -4517,9 +4517,9 @@ "Amount": "10000", "XChainBridge": { "LockingChainDoor": "rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", - "LockingChainIssue": "XRP", + "LockingChainIssue": {"currency": "XRP"}, "IssuingChainDoor": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", - "IssuingChainIssue": "XRP" + "IssuingChainIssue": {"currency": "XRP"} }, "Fee": "10", "Flags": 2147483648, @@ -4537,9 +4537,9 @@ "Amount": "10000", "XChainBridge": { "LockingChainDoor": "rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", - "LockingChainIssue": "XRP", + "LockingChainIssue": {"currency": "XRP"}, "IssuingChainDoor": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", - "IssuingChainIssue": "XRP" + "IssuingChainIssue": {"currency": "XRP"} }, "Destination": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", "Fee": "10", @@ -4564,9 +4564,9 @@ "XChainAttestationBatch" : { "XChainBridge" : { "IssuingChainDoor" : "rKeSSvHvaMZJp9ykaxutVwkhZgWuWMLnQt", - "IssuingChainIssue" : "XRP", + "IssuingChainIssue" : {"currency": "XRP"}, "LockingChainDoor" : "rJvExveLEL4jNDEeLKCVdxaSCN9cEBnEQC", - "LockingChainIssue" : "XRP" + "LockingChainIssue" : {"currency": "XRP"} }, "XChainClaimAttestationBatch" : [ { @@ -4592,9 +4592,9 @@ "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "XChainBridge": { "LockingChainDoor": "rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", - "LockingChainIssue": "XRP", + "LockingChainIssue": {"currency": "XRP"}, "IssuingChainDoor": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", - "IssuingChainIssue": "XRP" + "IssuingChainIssue": {"currency": "XRP"} }, "Amount": "1000000", "Fee": "10", @@ -4620,9 +4620,9 @@ "XChainAttestationBatch": { "XChainBridge": { "IssuingChainDoor": "rKeSSvHvaMZJp9ykaxutVwkhZgWuWMLnQt", - "IssuingChainIssue": "XRP", + "IssuingChainIssue": {"currency": "XRP"}, "LockingChainDoor": "rJvExveLEL4jNDEeLKCVdxaSCN9cEBnEQC", - "LockingChainIssue": "XRP" + "LockingChainIssue": {"currency": "XRP"} }, "XChainClaimAttestationBatch": [], "XChainCreateAccountAttestationBatch": [ diff --git a/xrpl/core/binarycodec/types/issue.py b/xrpl/core/binarycodec/types/issue.py index b3109cb38..959198777 100644 --- a/xrpl/core/binarycodec/types/issue.py +++ b/xrpl/core/binarycodec/types/issue.py @@ -9,6 +9,7 @@ from xrpl.core.binarycodec.types.account_id import AccountID from xrpl.core.binarycodec.types.currency import Currency from xrpl.core.binarycodec.types.serialized_type import SerializedType +from xrpl.models.currencies import XRP as XRPModel from xrpl.models.currencies import IssuedCurrency as IssuedCurrencyModel @@ -20,7 +21,7 @@ def __init__(self: Issue, buffer: bytes) -> None: super().__init__(buffer) @classmethod - def from_value(cls: Type[Issue], value: Union[str, Dict[str, str]]) -> Issue: + def from_value(cls: Type[Issue], value: Dict[str, str]) -> Issue: """ Construct an Issue object from a string or dictionary representation of an issued currency. @@ -34,10 +35,9 @@ def from_value(cls: Type[Issue], value: Union[str, Dict[str, str]]) -> Issue: Raises: XRPLBinaryCodecException: If the Issue representation is invalid. """ - if isinstance(value, str): - if value != "XRP": - raise XRPLBinaryCodecException(f"{value} is an illegal currency") - return cls(bytes(Currency.from_value(value))) + if XRPModel.is_dict_of_model(value): + currency_bytes = bytes(Currency.from_value(value["currency"])) + return cls(currency_bytes) if IssuedCurrencyModel.is_dict_of_model(value): currency_bytes = bytes(Currency.from_value(value["currency"])) @@ -82,7 +82,7 @@ def to_json(self: Issue) -> Union[str, Dict[Any, Any]]: parser = BinaryParser(str(self)) currency: Union[str, Dict[Any, Any]] = Currency.from_parser(parser).to_json() if currency == "XRP": - return currency + return {"currency": currency} issuer = AccountID.from_parser(parser) return {"currency": currency, "issuer": issuer.to_json()} From 1c96853f8097ce4950a244c2255bc405b414cf8c Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Wed, 16 Nov 2022 17:14:40 -0500 Subject: [PATCH 053/111] fix models --- xrpl/models/xchain_bridge.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/xrpl/models/xchain_bridge.py b/xrpl/models/xchain_bridge.py index 2b3484b5a..fd1d158d9 100644 --- a/xrpl/models/xchain_bridge.py +++ b/xrpl/models/xchain_bridge.py @@ -3,12 +3,9 @@ from __future__ import annotations from dataclasses import dataclass -from typing import Union - -from typing_extensions import Literal from xrpl.models.base_model import BaseModel -from xrpl.models.currencies import IssuedCurrency +from xrpl.models.currencies import Currency from xrpl.models.utils import require_kwargs_on_init @@ -18,6 +15,6 @@ class XChainBridge(BaseModel): """A XChainBridge represents a cross-chain bridge.""" locking_chain_door: str - locking_chain_issue: Union[Literal["XRP"], IssuedCurrency] + locking_chain_issue: Currency issuing_chain_door: str - issuing_chain_issue: Union[Literal["XRP"], IssuedCurrency] + issuing_chain_issue: Currency From 9eb38c1b124210c9d89c1bd9b5979d63d6d3a861 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Wed, 16 Nov 2022 17:29:35 -0500 Subject: [PATCH 054/111] fix test --- tests/unit/models/test_base_model.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/unit/models/test_base_model.py b/tests/unit/models/test_base_model.py index 3b6cd5077..a58359722 100644 --- a/tests/unit/models/test_base_model.py +++ b/tests/unit/models/test_base_model.py @@ -4,6 +4,7 @@ from xrpl.models import XRPLModelException from xrpl.models.amounts import IssuedCurrencyAmount +from xrpl.models.currencies import XRP from xrpl.models.requests import ( AccountChannels, BookOffers, @@ -606,9 +607,9 @@ def test_to_from_xrpl_xchain(self): "Amount": value, "XChainBridge": { "LockingChainDoor": "rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", - "LockingChainIssue": "XRP", + "LockingChainIssue": {"currency": "XRP"}, "IssuingChainDoor": "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", - "IssuingChainIssue": "XRP", + "IssuingChainIssue": {"currency": "XRP"}, }, "Destination": destination, "TransactionType": "XChainClaim", @@ -621,9 +622,9 @@ def test_to_from_xrpl_xchain(self): amount=value, xchain_bridge=XChainBridge( locking_chain_door="rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", - locking_chain_issue="XRP", + locking_chain_issue=XRP(), issuing_chain_door="r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", - issuing_chain_issue="XRP", + issuing_chain_issue=XRP(), ), destination=destination, xchain_claim_id=1, From 6a3d08931bf75b86ca65f1b67f6d8c73e4a603ce Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Mon, 12 Dec 2022 12:03:12 -0500 Subject: [PATCH 055/111] add validations for XChainCreateBridge --- .../transactions/test_xchain_create_bridge.py | 132 ++++++++++++++++++ .../transactions/xchain_create_bridge.py | 35 ++++- 2 files changed, 166 insertions(+), 1 deletion(-) create mode 100644 tests/unit/models/transactions/test_xchain_create_bridge.py diff --git a/tests/unit/models/transactions/test_xchain_create_bridge.py b/tests/unit/models/transactions/test_xchain_create_bridge.py new file mode 100644 index 000000000..8e34d2a09 --- /dev/null +++ b/tests/unit/models/transactions/test_xchain_create_bridge.py @@ -0,0 +1,132 @@ +from unittest import TestCase + +from xrpl.models import ( + XRP, + IssuedCurrency, + XChainBridge, + XChainCreateBridge, + XRPLModelException, +) + +_ACCOUNT = "r9LqNeG6qHxjeUocjvVki2XR35weJ9mZgQ" +_ACCOUNT2 = "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo" +_FEE = "0.00001" +_SEQUENCE = 19048 + +_ISSUER = "rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf" + +_GENESIS = "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh" + + +class TestXChainCreateBridge(TestCase): + def test_successful_xrp_xrp_bridge(self): + bridge = XChainBridge( + locking_chain_door=_ACCOUNT, + locking_chain_issue=XRP(), + issuing_chain_door=_GENESIS, + issuing_chain_issue=XRP(), + ) + XChainCreateBridge( + account=_ACCOUNT, + fee=_FEE, + sequence=_SEQUENCE, + xchain_bridge=bridge, + signature_reward="200", + min_account_create_amount="1000000", + ) + + def test_successful_iou_iou_bridge(self): + bridge = XChainBridge( + locking_chain_door=_ACCOUNT, + locking_chain_issue=IssuedCurrency(currency="USD", issuer=_ISSUER), + issuing_chain_door=_ACCOUNT2, + issuing_chain_issue=IssuedCurrency(currency="USD", issuer=_ACCOUNT2), + ) + XChainCreateBridge( + account=_ACCOUNT, + fee=_FEE, + sequence=_SEQUENCE, + xchain_bridge=bridge, + signature_reward="200", + ) + + def test_same_door_accounts(self): + bridge = XChainBridge( + locking_chain_door=_ACCOUNT, + locking_chain_issue=IssuedCurrency(currency="USD", issuer=_ISSUER), + issuing_chain_door=_ACCOUNT, + issuing_chain_issue=IssuedCurrency(currency="USD", issuer=_ACCOUNT), + ) + with self.assertRaises(XRPLModelException): + XChainCreateBridge( + account=_ACCOUNT, + fee=_FEE, + sequence=_SEQUENCE, + xchain_bridge=bridge, + signature_reward="200", + ) + + def test_xrp_iou_bridge(self): + bridge = XChainBridge( + locking_chain_door=_ACCOUNT, + locking_chain_issue=XRP(), + issuing_chain_door=_ACCOUNT, + issuing_chain_issue=IssuedCurrency(currency="USD", issuer=_ACCOUNT), + ) + with self.assertRaises(XRPLModelException): + XChainCreateBridge( + account=_ACCOUNT, + fee=_FEE, + sequence=_SEQUENCE, + xchain_bridge=bridge, + signature_reward="200", + ) + + def test_iou_xrp_bridge(self): + bridge = XChainBridge( + locking_chain_door=_ACCOUNT, + locking_chain_issue=IssuedCurrency(currency="USD", issuer=_ISSUER), + issuing_chain_door=_ACCOUNT, + issuing_chain_issue=XRP(), + ) + with self.assertRaises(XRPLModelException): + XChainCreateBridge( + account=_ACCOUNT, + fee=_FEE, + sequence=_SEQUENCE, + xchain_bridge=bridge, + signature_reward="200", + ) + + def test_account_not_in_bridge(self): + bridge = XChainBridge( + locking_chain_door=_ACCOUNT, + locking_chain_issue=XRP(), + issuing_chain_door=_ACCOUNT2, + issuing_chain_issue=XRP(), + ) + with self.assertRaises(XRPLModelException): + XChainCreateBridge( + account=_GENESIS, + fee=_FEE, + sequence=_SEQUENCE, + xchain_bridge=bridge, + signature_reward="200", + ) + + def test_successful_iou_iou_min_account_create_amount(self): + bridge = XChainBridge( + locking_chain_door=_ACCOUNT, + locking_chain_issue=IssuedCurrency(currency="USD", issuer=_ISSUER), + issuing_chain_door=_ACCOUNT2, + issuing_chain_issue=IssuedCurrency(currency="USD", issuer=_ACCOUNT2), + ) + with self.assertRaises(XRPLModelException): + XChainCreateBridge( + account=_ACCOUNT, + fee=_FEE, + sequence=_SEQUENCE, + xchain_bridge=bridge, + signature_reward="200", + min_account_create_amount="1000000", + ) diff --git a/xrpl/models/transactions/xchain_create_bridge.py b/xrpl/models/transactions/xchain_create_bridge.py index b82a06314..1195fee9e 100644 --- a/xrpl/models/transactions/xchain_create_bridge.py +++ b/xrpl/models/transactions/xchain_create_bridge.py @@ -1,9 +1,12 @@ """Model for a XChainCreateBridge transaction type.""" +from __future__ import annotations + from dataclasses import dataclass, field -from typing import Optional +from typing import Dict, Optional from xrpl.models.amounts import Amount +from xrpl.models.currencies import XRP from xrpl.models.required import REQUIRED from xrpl.models.transactions.transaction import Transaction from xrpl.models.transactions.types import TransactionType @@ -26,3 +29,33 @@ class XChainCreateBridge(Transaction): default=TransactionType.XCHAIN_CREATE_BRIDGE, init=False, ) + + def _get_errors(self: XChainCreateBridge) -> Dict[str, str]: + errors = super()._get_errors() + + bridge = self.xchain_bridge + + if bridge.locking_chain_door == bridge.issuing_chain_door: + errors[ + "xchain_bridge" + ] = "Cannot have the same door accounts on the locking and issuing chain." + + if self.account not in [bridge.locking_chain_door, bridge.issuing_chain_door]: + errors[ + "account" + ] = "Account must be either locking chain door or issuing chain door." + + if (bridge.locking_chain_issue == XRP()) != ( + bridge.issuing_chain_issue == XRP() + ): + errors["issue"] = "Bridge must be XRP-XRP or IOU-IOU." + + if ( + self.min_account_create_amount is not None + and bridge.locking_chain_issue != XRP() + ): + errors[ + "min_account_create_amount" + ] = "Cannot have MinAccountCreateAmount if bridge is IOU-IOU." + + return errors From aa1a09e0132a8ed159d064eef17e64be276a4a58 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Mon, 12 Dec 2022 14:10:42 -0500 Subject: [PATCH 056/111] add validations for XChainModifyBridge --- .vscode/settings.json | 1 + .../transactions/test_xchain_create_bridge.py | 36 +++++- .../transactions/test_xchain_modify_bridge.py | 113 ++++++++++++++++++ .../transactions/xchain_create_bridge.py | 16 ++- .../transactions/xchain_modify_bridge.py | 38 +++++- 5 files changed, 196 insertions(+), 8 deletions(-) create mode 100644 tests/unit/models/transactions/test_xchain_modify_bridge.py diff --git a/.vscode/settings.json b/.vscode/settings.json index b8be05d5b..d33c0bbf0 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -12,6 +12,7 @@ "altnet", "asyncio", "binarycodec", + "isnumeric", "nftoken", "rippletest", "ripplex", diff --git a/tests/unit/models/transactions/test_xchain_create_bridge.py b/tests/unit/models/transactions/test_xchain_create_bridge.py index 8e34d2a09..47e3f49c7 100644 --- a/tests/unit/models/transactions/test_xchain_create_bridge.py +++ b/tests/unit/models/transactions/test_xchain_create_bridge.py @@ -114,7 +114,7 @@ def test_account_not_in_bridge(self): signature_reward="200", ) - def test_successful_iou_iou_min_account_create_amount(self): + def test_iou_iou_min_account_create_amount(self): bridge = XChainBridge( locking_chain_door=_ACCOUNT, locking_chain_issue=IssuedCurrency(currency="USD", issuer=_ISSUER), @@ -130,3 +130,37 @@ def test_successful_iou_iou_min_account_create_amount(self): signature_reward="200", min_account_create_amount="1000000", ) + + def test_invalid_signature_reward(self): + bridge = XChainBridge( + locking_chain_door=_ACCOUNT, + locking_chain_issue=XRP(), + issuing_chain_door=_GENESIS, + issuing_chain_issue=XRP(), + ) + with self.assertRaises(XRPLModelException): + XChainCreateBridge( + account=_ACCOUNT, + fee=_FEE, + sequence=_SEQUENCE, + xchain_bridge=bridge, + signature_reward="hello", + min_account_create_amount="1000000", + ) + + def test_invalid_min_account_create_amount(self): + bridge = XChainBridge( + locking_chain_door=_ACCOUNT, + locking_chain_issue=XRP(), + issuing_chain_door=_GENESIS, + issuing_chain_issue=XRP(), + ) + with self.assertRaises(XRPLModelException): + XChainCreateBridge( + account=_ACCOUNT, + fee=_FEE, + sequence=_SEQUENCE, + xchain_bridge=bridge, + signature_reward="-200", + min_account_create_amount="hello", + ) diff --git a/tests/unit/models/transactions/test_xchain_modify_bridge.py b/tests/unit/models/transactions/test_xchain_modify_bridge.py new file mode 100644 index 000000000..5b42bee48 --- /dev/null +++ b/tests/unit/models/transactions/test_xchain_modify_bridge.py @@ -0,0 +1,113 @@ +from unittest import TestCase + +from xrpl.models import ( + XRP, + IssuedCurrency, + XChainBridge, + XChainModifyBridge, + XRPLModelException, +) + +_ACCOUNT = "r9LqNeG6qHxjeUocjvVki2XR35weJ9mZgQ" +_ACCOUNT2 = "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo" +_FEE = "0.00001" +_SEQUENCE = 19048 + +_ISSUER = "rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf" + +_GENESIS = "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh" + +_XRP_BRIDGE = XChainBridge( + locking_chain_door=_ACCOUNT, + locking_chain_issue=XRP(), + issuing_chain_door=_GENESIS, + issuing_chain_issue=XRP(), +) + +_IOU_BRIDGE = XChainBridge( + locking_chain_door=_ACCOUNT, + locking_chain_issue=IssuedCurrency(currency="USD", issuer=_ISSUER), + issuing_chain_door=_ACCOUNT2, + issuing_chain_issue=IssuedCurrency(currency="USD", issuer=_ACCOUNT2), +) + + +class TestXChainModifyBridge(TestCase): + def test_successful_modify_bridge(self): + XChainModifyBridge( + account=_ACCOUNT, + fee=_FEE, + sequence=_SEQUENCE, + xchain_bridge=_XRP_BRIDGE, + signature_reward="200", + min_account_create_amount="1000000", + ) + + def test_successful_modify_bridge_only_signature_reward(self): + XChainModifyBridge( + account=_ACCOUNT, + fee=_FEE, + sequence=_SEQUENCE, + xchain_bridge=_IOU_BRIDGE, + signature_reward="200", + ) + + def test_successful_modify_bridge_only_min_account_create_amount(self): + XChainModifyBridge( + account=_ACCOUNT, + fee=_FEE, + sequence=_SEQUENCE, + xchain_bridge=_XRP_BRIDGE, + min_account_create_amount="1000000", + ) + + def test_modify_bridge_empty(self): + with self.assertRaises(XRPLModelException): + XChainModifyBridge( + account=_ACCOUNT, + fee=_FEE, + sequence=_SEQUENCE, + xchain_bridge=_IOU_BRIDGE, + ) + + def test_account_not_in_bridge(self): + with self.assertRaises(XRPLModelException): + XChainModifyBridge( + account=_GENESIS, + fee=_FEE, + sequence=_SEQUENCE, + xchain_bridge=_XRP_BRIDGE, + signature_reward="200", + ) + + def test_iou_iou_min_account_create_amount(self): + with self.assertRaises(XRPLModelException): + XChainModifyBridge( + account=_ACCOUNT, + fee=_FEE, + sequence=_SEQUENCE, + xchain_bridge=_IOU_BRIDGE, + min_account_create_amount="1000000", + ) + + def test_invalid_signature_reward(self): + with self.assertRaises(XRPLModelException): + XChainModifyBridge( + account=_ACCOUNT, + fee=_FEE, + sequence=_SEQUENCE, + xchain_bridge=_XRP_BRIDGE, + signature_reward="hello", + min_account_create_amount="1000000", + ) + + def test_invalid_min_account_create_amount(self): + with self.assertRaises(XRPLModelException): + XChainModifyBridge( + account=_ACCOUNT, + fee=_FEE, + sequence=_SEQUENCE, + xchain_bridge=_XRP_BRIDGE, + signature_reward="200", + min_account_create_amount="hello", + ) diff --git a/xrpl/models/transactions/xchain_create_bridge.py b/xrpl/models/transactions/xchain_create_bridge.py index 1195fee9e..c89d668d9 100644 --- a/xrpl/models/transactions/xchain_create_bridge.py +++ b/xrpl/models/transactions/xchain_create_bridge.py @@ -5,7 +5,6 @@ from dataclasses import dataclass, field from typing import Dict, Optional -from xrpl.models.amounts import Amount from xrpl.models.currencies import XRP from xrpl.models.required import REQUIRED from xrpl.models.transactions.transaction import Transaction @@ -21,9 +20,9 @@ class XChainCreateBridge(Transaction): xchain_bridge: XChainBridge = REQUIRED # type: ignore - signature_reward: Amount = REQUIRED # type: ignore + signature_reward: str = REQUIRED # type: ignore - min_account_create_amount: Optional[Amount] = None + min_account_create_amount: Optional[str] = None transaction_type: TransactionType = field( default=TransactionType.XCHAIN_CREATE_BRIDGE, @@ -58,4 +57,15 @@ def _get_errors(self: XChainCreateBridge) -> Dict[str, str]: "min_account_create_amount" ] = "Cannot have MinAccountCreateAmount if bridge is IOU-IOU." + if self.signature_reward is not None and not self.signature_reward.isnumeric(): + errors["signature_reward"] = "signature_reward must be numeric." + + if ( + self.min_account_create_amount is not None + and not self.min_account_create_amount.isnumeric() + ): + errors[ + "min_account_create_amount_value" + ] = "min_account_create_amount must be numeric." + return errors diff --git a/xrpl/models/transactions/xchain_modify_bridge.py b/xrpl/models/transactions/xchain_modify_bridge.py index 5710487de..a4c865100 100644 --- a/xrpl/models/transactions/xchain_modify_bridge.py +++ b/xrpl/models/transactions/xchain_modify_bridge.py @@ -1,9 +1,11 @@ """Model for a XChainModifyBridge transaction type.""" +from __future__ import annotations + from dataclasses import dataclass, field -from typing import Optional +from typing import Dict, Optional -from xrpl.models.amounts import Amount +from xrpl.models.currencies import XRP from xrpl.models.required import REQUIRED from xrpl.models.transactions.transaction import Transaction from xrpl.models.transactions.types import TransactionType @@ -18,11 +20,39 @@ class XChainModifyBridge(Transaction): xchain_bridge: XChainBridge = REQUIRED # type: ignore - signature_reward: Optional[Amount] = None + signature_reward: Optional[str] = None - min_account_create_amount: Optional[Amount] = None + min_account_create_amount: Optional[str] = None transaction_type: TransactionType = field( default=TransactionType.XCHAIN_MODIFY_BRIDGE, init=False, ) + + def _get_errors(self: XChainModifyBridge) -> Dict[str, str]: + errors = super()._get_errors() + + bridge = self.xchain_bridge + + if self.signature_reward is None and self.min_account_create_amount is None: + errors[ + "xchain_modify_bridge" + ] = "Must either change signature_reward or min_account_create_amount." + + if self.account not in [bridge.locking_chain_door, bridge.issuing_chain_door]: + errors[ + "account" + ] = "Account must be either locking chain door or issuing chain door." + + if self.signature_reward is not None and not self.signature_reward.isnumeric(): + errors["signature_reward"] = "signature_reward must be numeric." + + if ( + self.min_account_create_amount is not None + and bridge.locking_chain_issue != XRP() + ): + errors[ + "min_account_create_amount" + ] = "Cannot have MinAccountCreateAmount if bridge is IOU-IOU." + + return errors From 02404e90038fbe9d3b2e57c60f9b7bc54ea72a63 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Mon, 12 Dec 2022 14:31:18 -0500 Subject: [PATCH 057/111] validate XChainClaim --- .../models/transactions/test_xchain_claim.py | 108 ++++++++++++++++++ xrpl/models/transactions/xchain_claim.py | 20 +++- 2 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 tests/unit/models/transactions/test_xchain_claim.py diff --git a/tests/unit/models/transactions/test_xchain_claim.py b/tests/unit/models/transactions/test_xchain_claim.py new file mode 100644 index 000000000..82f9e690d --- /dev/null +++ b/tests/unit/models/transactions/test_xchain_claim.py @@ -0,0 +1,108 @@ +from unittest import TestCase + +from xrpl.models import ( + XRP, + IssuedCurrency, + IssuedCurrencyAmount, + XChainBridge, + XChainClaim, + XRPLModelException, +) + +_ACCOUNT = "r9LqNeG6qHxjeUocjvVki2XR35weJ9mZgQ" +_ACCOUNT2 = "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo" +_FEE = "0.00001" +_SEQUENCE = 19048 + +_ISSUER = "rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf" +_GENESIS = "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh" + +_DESTINATION = "rJrRMgiRgrU6hDF4pgu5DXQdWyPbY35ErN" +_CLAIM_ID = 3 +_XRP_AMOUNT = "123456789" +_IOU_AMOUNT = IssuedCurrencyAmount(currency="USD", issuer=_ISSUER, value="123") + +_XRP_BRIDGE = XChainBridge( + locking_chain_door=_ACCOUNT, + locking_chain_issue=XRP(), + issuing_chain_door=_GENESIS, + issuing_chain_issue=XRP(), +) + +_IOU_BRIDGE = XChainBridge( + locking_chain_door=_ACCOUNT, + locking_chain_issue=IssuedCurrency(currency="USD", issuer=_ISSUER), + issuing_chain_door=_ACCOUNT2, + issuing_chain_issue=IssuedCurrency(currency="USD", issuer=_ACCOUNT2), +) + + +class TestXChainClaim(TestCase): + def test_successful_claim_xrp(self): + XChainClaim( + account=_ACCOUNT, + fee=_FEE, + sequence=_SEQUENCE, + xchain_bridge=_XRP_BRIDGE, + xchain_claim_id=_CLAIM_ID, + destination=_DESTINATION, + amount=_XRP_AMOUNT, + ) + + def test_successful_claim_iou(self): + XChainClaim( + account=_ACCOUNT, + fee=_FEE, + sequence=_SEQUENCE, + xchain_bridge=_IOU_BRIDGE, + xchain_claim_id=_CLAIM_ID, + destination=_DESTINATION, + amount=_IOU_AMOUNT, + ) + + def test_successful_claim_destination_tag(self): + XChainClaim( + account=_ACCOUNT, + fee=_FEE, + sequence=_SEQUENCE, + xchain_bridge=_XRP_BRIDGE, + xchain_claim_id=_CLAIM_ID, + destination=_DESTINATION, + destination_tag="12345", + amount=_XRP_AMOUNT, + ) + + def test_successful_claim_str_claim_id(self): + XChainClaim( + account=_ACCOUNT, + fee=_FEE, + sequence=_SEQUENCE, + xchain_bridge=_XRP_BRIDGE, + xchain_claim_id=str(_CLAIM_ID), + destination=_DESTINATION, + amount=_XRP_AMOUNT, + ) + + def test_xrp_bridge_iou_amount(self): + with self.assertRaises(XRPLModelException): + XChainClaim( + account=_ACCOUNT, + fee=_FEE, + sequence=_SEQUENCE, + xchain_bridge=_XRP_BRIDGE, + xchain_claim_id=_CLAIM_ID, + destination=_DESTINATION, + amount=_IOU_AMOUNT, + ) + + def test_iou_bridge_xrp_amount(self): + with self.assertRaises(XRPLModelException): + XChainClaim( + account=_ACCOUNT, + fee=_FEE, + sequence=_SEQUENCE, + xchain_bridge=_IOU_BRIDGE, + xchain_claim_id=_CLAIM_ID, + destination=_DESTINATION, + amount=_XRP_AMOUNT, + ) diff --git a/xrpl/models/transactions/xchain_claim.py b/xrpl/models/transactions/xchain_claim.py index 5a7c86ad2..ff8808a6d 100644 --- a/xrpl/models/transactions/xchain_claim.py +++ b/xrpl/models/transactions/xchain_claim.py @@ -1,9 +1,12 @@ """Model for a XChainClaim transaction type.""" +from __future__ import annotations + from dataclasses import dataclass, field -from typing import Optional, Union +from typing import Dict, Optional, Union from xrpl.models.amounts import Amount +from xrpl.models.currencies import XRP from xrpl.models.required import REQUIRED from xrpl.models.transactions.transaction import Transaction from xrpl.models.transactions.types import TransactionType @@ -30,3 +33,18 @@ class XChainClaim(Transaction): default=TransactionType.XCHAIN_CLAIM, init=False, ) + + def _get_errors(self: XChainClaim) -> Dict[str, str]: + errors = super()._get_errors() + + bridge = self.xchain_bridge + currency = XRP() if isinstance(self.amount, str) else self.amount.to_currency() + if ( + currency != bridge.locking_chain_issue + and currency != bridge.issuing_chain_issue + ): + errors[ + "amount" + ] = "Amount must match either locking chain issue or issuing chain issue." + + return errors From 75dfc28f7b67f6069baf40fcf682fbf485b90274 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Mon, 12 Dec 2022 14:49:22 -0500 Subject: [PATCH 058/111] add validations for XChainCreateClaimID --- .../test_xchain_create_claim_id.py | 47 +++++++++++++++++++ .../transactions/xchain_create_claim_id.py | 20 +++++++- 2 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 tests/unit/models/transactions/test_xchain_create_claim_id.py diff --git a/tests/unit/models/transactions/test_xchain_create_claim_id.py b/tests/unit/models/transactions/test_xchain_create_claim_id.py new file mode 100644 index 000000000..589646b23 --- /dev/null +++ b/tests/unit/models/transactions/test_xchain_create_claim_id.py @@ -0,0 +1,47 @@ +from unittest import TestCase + +from xrpl.models import XRP, XChainBridge, XChainCreateClaimID, XRPLModelException + +_ACCOUNT = "r9LqNeG6qHxjeUocjvVki2XR35weJ9mZgQ" +_ACCOUNT2 = "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo" + +_ISSUER = "rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf" +_GENESIS = "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh" + +_SOURCE = "rJrRMgiRgrU6hDF4pgu5DXQdWyPbY35ErN" +_SIGNATURE_REWARD = "200" + +_XRP_BRIDGE = XChainBridge( + locking_chain_door=_ACCOUNT, + locking_chain_issue=XRP(), + issuing_chain_door=_GENESIS, + issuing_chain_issue=XRP(), +) + + +class TestXChainCreateClaimID(TestCase): + def test_successful(self): + XChainCreateClaimID( + account=_ACCOUNT, + xchain_bridge=_XRP_BRIDGE, + signature_reward=_SIGNATURE_REWARD, + other_chain_source=_SOURCE, + ) + + def test_bad_signature_reward(self): + with self.assertRaises(XRPLModelException): + XChainCreateClaimID( + account=_ACCOUNT, + xchain_bridge=_XRP_BRIDGE, + signature_reward="hello", + other_chain_source=_SOURCE, + ) + + def test_bad_other_chain_source(self): + with self.assertRaises(XRPLModelException): + XChainCreateClaimID( + account=_ACCOUNT, + xchain_bridge=_XRP_BRIDGE, + signature_reward=_SIGNATURE_REWARD, + other_chain_source="hello", + ) diff --git a/xrpl/models/transactions/xchain_create_claim_id.py b/xrpl/models/transactions/xchain_create_claim_id.py index eb0ce5aaa..859b3947c 100644 --- a/xrpl/models/transactions/xchain_create_claim_id.py +++ b/xrpl/models/transactions/xchain_create_claim_id.py @@ -1,8 +1,11 @@ """Model for a XChainCreateClaimID transaction type.""" +from __future__ import annotations + from dataclasses import dataclass, field +from typing import Dict -from xrpl.models.amounts import Amount +from xrpl.core.addresscodec import is_valid_classic_address from xrpl.models.required import REQUIRED from xrpl.models.transactions.transaction import Transaction from xrpl.models.transactions.types import TransactionType @@ -17,7 +20,7 @@ class XChainCreateClaimID(Transaction): xchain_bridge: XChainBridge = REQUIRED # type: ignore - signature_reward: Amount = REQUIRED # type: ignore + signature_reward: str = REQUIRED # type: ignore other_chain_source: str = REQUIRED # type: ignore @@ -25,3 +28,16 @@ class XChainCreateClaimID(Transaction): default=TransactionType.XCHAIN_CREATE_CLAIM_ID, init=False, ) + + def _get_errors(self: XChainCreateClaimID) -> Dict[str, str]: + errors = super()._get_errors() + + if self.signature_reward is not None and not self.signature_reward.isnumeric(): + errors["signature_reward"] = "`signature_reward` must be numeric." + + if not is_valid_classic_address(self.other_chain_source): + errors[ + "other_chain_source" + ] = "`other_chain_source` must be a valid XRPL address." + + return errors From a351c923a1ca71a208a74afc3fc6430375fc9503 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Mon, 12 Dec 2022 17:42:45 -0500 Subject: [PATCH 059/111] add validations for XChainAddAttestation --- .../test_xchain_add_attestation.py | 71 +++++++++++++++++++ .../transactions/xchain_add_attestation.py | 14 +++- 2 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 tests/unit/models/transactions/test_xchain_add_attestation.py diff --git a/tests/unit/models/transactions/test_xchain_add_attestation.py b/tests/unit/models/transactions/test_xchain_add_attestation.py new file mode 100644 index 000000000..d56ad4cfb --- /dev/null +++ b/tests/unit/models/transactions/test_xchain_add_attestation.py @@ -0,0 +1,71 @@ +from unittest import TestCase + +from xrpl.models import XRP, XChainAddAttestation, XChainBridge, XRPLModelException +from xrpl.models.transactions.xchain_add_attestation import ( + XChainAttestationBatch, + XChainClaimAttestationBatchElement, + XChainCreateAccountAttestationBatchElement, +) + +_ACCOUNT = "r9LqNeG6qHxjeUocjvVki2XR35weJ9mZgQ" +_ACCOUNT2 = "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo" +_ACCOUNT3 = "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59" + +_REWARD_ACCOUNT = "rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf" + +_GENESIS = "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh" + +_XRP_BRIDGE = XChainBridge( + locking_chain_door=_ACCOUNT, + locking_chain_issue=XRP(), + issuing_chain_door=_GENESIS, + issuing_chain_issue=XRP(), +) + +_CLAIM_ATTESTATION = XChainClaimAttestationBatchElement( + account=_ACCOUNT2, + amount="10000000", + attestation_reward_account=_REWARD_ACCOUNT, + public_key="ED3CC1BBD0952A60088E89FA502921895FC81FBD79CAE9109A8FE2D23659AD5D56", + signature="616263", + was_locking_chain_send=0, + xchain_claim_id="2", +) + +_ACCOUNT_CREATE_ATTESTATION = XChainCreateAccountAttestationBatchElement( + account=_ACCOUNT2, + amount="10000000", + attestation_reward_account=_REWARD_ACCOUNT, + destination=_ACCOUNT3, + signature_reward="200", + public_key="ED3CC1BBD0952A60088E89FA502921895FC81FBD79CAE9109A8FE2D23659AD5D56", + signature="616263", + was_locking_chain_send=0, + xchain_account_create_count="2", +) + + +class TestXChainAddAttestation(TestCase): + def test_successful(self): + XChainAddAttestation( + account=_ACCOUNT, + xchain_attestation_batch=XChainAttestationBatch( + xchain_bridge=_XRP_BRIDGE, + xchain_claim_attestation_batch=[_CLAIM_ATTESTATION], + xchain_create_account_attestation_batch=[_ACCOUNT_CREATE_ATTESTATION], + ), + ) + + def test_too_many_attestations(self): + with self.assertRaises(XRPLModelException): + XChainAddAttestation( + account=_ACCOUNT, + xchain_attestation_batch=XChainAttestationBatch( + xchain_bridge=_XRP_BRIDGE, + xchain_claim_attestation_batch=[_CLAIM_ATTESTATION] * 4, + xchain_create_account_attestation_batch=[ + _ACCOUNT_CREATE_ATTESTATION + ] + * 5, + ), + ) diff --git a/xrpl/models/transactions/xchain_add_attestation.py b/xrpl/models/transactions/xchain_add_attestation.py index 5bbab956e..555aade94 100644 --- a/xrpl/models/transactions/xchain_add_attestation.py +++ b/xrpl/models/transactions/xchain_add_attestation.py @@ -3,7 +3,7 @@ from __future__ import annotations from dataclasses import dataclass, field -from typing import List, Optional, Union +from typing import Dict, List, Optional, Union from typing_extensions import Literal @@ -90,3 +90,15 @@ class XChainAddAttestation(Transaction): default=TransactionType.XCHAIN_ADD_ATTESTATION, init=False, ) + + def _get_errors(self: XChainAddAttestation) -> Dict[str, str]: + errors = super()._get_errors() + + batch = self.xchain_attestation_batch + claim_batch = batch.xchain_claim_attestation_batch + account_create_batch = batch.xchain_create_account_attestation_batch + + if len(claim_batch) + len(account_create_batch) > 8: + errors["num_attestations"] = "Cannot have more than 8 attestations." + + return errors From 6373441d7079f29d396debbf08d72a096fb3e949 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Mon, 12 Dec 2022 17:50:27 -0500 Subject: [PATCH 060/111] fix tests --- .../unit/models/transactions/test_xchain_modify_bridge.py | 2 +- xrpl/models/transactions/xchain_modify_bridge.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/unit/models/transactions/test_xchain_modify_bridge.py b/tests/unit/models/transactions/test_xchain_modify_bridge.py index 5b42bee48..63177024b 100644 --- a/tests/unit/models/transactions/test_xchain_modify_bridge.py +++ b/tests/unit/models/transactions/test_xchain_modify_bridge.py @@ -73,7 +73,7 @@ def test_modify_bridge_empty(self): def test_account_not_in_bridge(self): with self.assertRaises(XRPLModelException): XChainModifyBridge( - account=_GENESIS, + account=_ACCOUNT2, fee=_FEE, sequence=_SEQUENCE, xchain_bridge=_XRP_BRIDGE, diff --git a/xrpl/models/transactions/xchain_modify_bridge.py b/xrpl/models/transactions/xchain_modify_bridge.py index a4c865100..6c4bd1022 100644 --- a/xrpl/models/transactions/xchain_modify_bridge.py +++ b/xrpl/models/transactions/xchain_modify_bridge.py @@ -55,4 +55,12 @@ def _get_errors(self: XChainModifyBridge) -> Dict[str, str]: "min_account_create_amount" ] = "Cannot have MinAccountCreateAmount if bridge is IOU-IOU." + if ( + self.min_account_create_amount is not None + and not self.min_account_create_amount.isnumeric() + ): + errors[ + "min_account_create_amount_value" + ] = "min_account_create_amount must be numeric." + return errors From 783c2e246b1867b5edaffff8dc33c4eecdf7c78e Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Mon, 12 Dec 2022 17:57:02 -0500 Subject: [PATCH 061/111] add validations for XChainAccountCreateCommit --- .../test_xchain_account_create_commit.py | 61 +++++++++++++++++++ .../xchain_account_create_commit.py | 19 +++++- .../transactions/xchain_modify_bridge.py | 4 +- 3 files changed, 79 insertions(+), 5 deletions(-) create mode 100644 tests/unit/models/transactions/test_xchain_account_create_commit.py diff --git a/tests/unit/models/transactions/test_xchain_account_create_commit.py b/tests/unit/models/transactions/test_xchain_account_create_commit.py new file mode 100644 index 000000000..26651610c --- /dev/null +++ b/tests/unit/models/transactions/test_xchain_account_create_commit.py @@ -0,0 +1,61 @@ +from unittest import TestCase + +from xrpl.models import ( + XRP, + IssuedCurrency, + XChainAccountCreateCommit, + XChainBridge, + XRPLModelException, +) + +_ACCOUNT = "r9LqNeG6qHxjeUocjvVki2XR35weJ9mZgQ" +_ACCOUNT2 = "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo" + +_ISSUER = "rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf" + +_GENESIS = "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh" + +_XRP_BRIDGE = XChainBridge( + locking_chain_door=_ACCOUNT, + locking_chain_issue=XRP(), + issuing_chain_door=_GENESIS, + issuing_chain_issue=XRP(), +) + +_IOU_BRIDGE = XChainBridge( + locking_chain_door=_ACCOUNT, + locking_chain_issue=IssuedCurrency(currency="USD", issuer=_ISSUER), + issuing_chain_door=_ACCOUNT2, + issuing_chain_issue=IssuedCurrency(currency="USD", issuer=_ACCOUNT2), +) + + +class TestXChainAccountCreateCommit(TestCase): + def test_successful(self): + XChainAccountCreateCommit( + account=_ACCOUNT, + xchain_bridge=_XRP_BRIDGE, + signature_reward="200", + destination=_ACCOUNT2, + amount="1000000", + ) + + def test_bad_signature_reward(self): + with self.assertRaises(XRPLModelException): + XChainAccountCreateCommit( + account=_ACCOUNT, + xchain_bridge=_XRP_BRIDGE, + signature_reward="hello", + destination=_ACCOUNT2, + amount="1000000", + ) + + def test_bad_amount(self): + with self.assertRaises(XRPLModelException): + XChainAccountCreateCommit( + account=_ACCOUNT, + xchain_bridge=_XRP_BRIDGE, + signature_reward="200", + destination=_ACCOUNT2, + amount="hello", + ) diff --git a/xrpl/models/transactions/xchain_account_create_commit.py b/xrpl/models/transactions/xchain_account_create_commit.py index cebc36b3b..865adc383 100644 --- a/xrpl/models/transactions/xchain_account_create_commit.py +++ b/xrpl/models/transactions/xchain_account_create_commit.py @@ -1,8 +1,10 @@ """Model for a XChainAccountCreateCommit transaction type.""" +from __future__ import annotations + from dataclasses import dataclass, field +from typing import Dict -from xrpl.models.amounts import Amount from xrpl.models.required import REQUIRED from xrpl.models.transactions.transaction import Transaction from xrpl.models.transactions.types import TransactionType @@ -17,13 +19,24 @@ class XChainAccountCreateCommit(Transaction): xchain_bridge: XChainBridge = REQUIRED # type: ignore - signature_reward: Amount = REQUIRED # type: ignore + signature_reward: str = REQUIRED # type: ignore destination: str = REQUIRED # type: ignore - amount: Amount = REQUIRED # type: ignore + amount: str = REQUIRED # type: ignore transaction_type: TransactionType = field( default=TransactionType.XCHAIN_ACCOUNT_CREATE_COMMIT, init=False, ) + + def _get_errors(self: XChainAccountCreateCommit) -> Dict[str, str]: + errors = super()._get_errors() + + if self.signature_reward is not None and not self.signature_reward.isnumeric(): + errors["signature_reward"] = "`signature_reward` must be numeric." + + if self.amount is not None and not self.amount.isnumeric(): + errors["amount"] = "`amount` must be numeric." + + return errors diff --git a/xrpl/models/transactions/xchain_modify_bridge.py b/xrpl/models/transactions/xchain_modify_bridge.py index 6c4bd1022..4fd251675 100644 --- a/xrpl/models/transactions/xchain_modify_bridge.py +++ b/xrpl/models/transactions/xchain_modify_bridge.py @@ -45,7 +45,7 @@ def _get_errors(self: XChainModifyBridge) -> Dict[str, str]: ] = "Account must be either locking chain door or issuing chain door." if self.signature_reward is not None and not self.signature_reward.isnumeric(): - errors["signature_reward"] = "signature_reward must be numeric." + errors["signature_reward"] = "`signature_reward` must be numeric." if ( self.min_account_create_amount is not None @@ -61,6 +61,6 @@ def _get_errors(self: XChainModifyBridge) -> Dict[str, str]: ): errors[ "min_account_create_amount_value" - ] = "min_account_create_amount must be numeric." + ] = "`min_account_create_amount` must be numeric." return errors From 3f03f2779dad22b273cc0ea546354ff3750ca744 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Tue, 13 Dec 2022 09:53:08 -0500 Subject: [PATCH 062/111] fix more Literal["XRP"] issues --- xrpl/models/requests/ledger_entry.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/xrpl/models/requests/ledger_entry.py b/xrpl/models/requests/ledger_entry.py index 62175442c..9837fbb52 100644 --- a/xrpl/models/requests/ledger_entry.py +++ b/xrpl/models/requests/ledger_entry.py @@ -10,10 +10,8 @@ from dataclasses import dataclass, field from typing import Dict, List, Optional, Union -from typing_extensions import Literal - from xrpl.models.base_model import BaseModel -from xrpl.models.currencies import IssuedCurrency +from xrpl.models.currencies import Currency from xrpl.models.requests.request import Request, RequestMethod from xrpl.models.required import REQUIRED from xrpl.models.utils import require_kwargs_on_init @@ -159,9 +157,9 @@ class XChainClaimID(BaseModel): """Required fields for requesting an XChainClaimID if not querying by object ID.""" locking_chain_door: str - locking_chain_issue: Union[Literal["XRP"], IssuedCurrency] + locking_chain_issue: Currency issuing_chain_door: str - issuing_chain_issue: Union[Literal["XRP"], IssuedCurrency] + issuing_chain_issue: Currency xchain_claim_id: Union[int, str] @@ -174,9 +172,9 @@ class XChainCreateAccountClaimID(BaseModel): """ locking_chain_door: str - locking_chain_issue: Union[Literal["XRP"], IssuedCurrency] + locking_chain_issue: Currency issuing_chain_door: str - issuing_chain_issue: Union[Literal["XRP"], IssuedCurrency] + issuing_chain_issue: Currency xchain_create_account_claim_id: Union[int, str] From c113cfb17a2aa8d4f373456f70a8d1cf09a62b77 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Thu, 5 Jan 2023 14:22:15 -0500 Subject: [PATCH 063/111] simplify initializing attestation lists --- xrpl/models/transactions/xchain_add_attestation.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/xrpl/models/transactions/xchain_add_attestation.py b/xrpl/models/transactions/xchain_add_attestation.py index 555aade94..796b7f3fb 100644 --- a/xrpl/models/transactions/xchain_add_attestation.py +++ b/xrpl/models/transactions/xchain_add_attestation.py @@ -3,7 +3,7 @@ from __future__ import annotations from dataclasses import dataclass, field -from typing import Dict, List, Optional, Union +from typing import Any, Dict, List, Optional, Union from typing_extensions import Literal @@ -17,6 +17,10 @@ from xrpl.models.xchain_bridge import XChainBridge +def _get_new_list() -> List[Any]: + return [] + + @require_kwargs_on_init @dataclass(frozen=True) class XChainClaimAttestationBatchElement(NestedModel): @@ -72,11 +76,11 @@ class XChainAttestationBatch(BaseModel): xchain_claim_attestation_batch: List[ XChainClaimAttestationBatchElement - ] = REQUIRED # type: ignore + ] = _get_new_list() xchain_create_account_attestation_batch: List[ XChainCreateAccountAttestationBatchElement - ] = REQUIRED # type: ignore + ] = _get_new_list() @require_kwargs_on_init From 6a0ab4af5015e261dcbf19a77a15915a21d8c04b Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Mon, 9 Jan 2023 12:46:18 -0500 Subject: [PATCH 064/111] fix attestation list creation --- xrpl/models/transactions/xchain_add_attestation.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/xrpl/models/transactions/xchain_add_attestation.py b/xrpl/models/transactions/xchain_add_attestation.py index 796b7f3fb..e7c219525 100644 --- a/xrpl/models/transactions/xchain_add_attestation.py +++ b/xrpl/models/transactions/xchain_add_attestation.py @@ -3,7 +3,7 @@ from __future__ import annotations from dataclasses import dataclass, field -from typing import Any, Dict, List, Optional, Union +from typing import Dict, List, Optional, Union from typing_extensions import Literal @@ -17,10 +17,6 @@ from xrpl.models.xchain_bridge import XChainBridge -def _get_new_list() -> List[Any]: - return [] - - @require_kwargs_on_init @dataclass(frozen=True) class XChainClaimAttestationBatchElement(NestedModel): @@ -74,13 +70,13 @@ class XChainAttestationBatch(BaseModel): xchain_bridge: XChainBridge = REQUIRED # type: ignore - xchain_claim_attestation_batch: List[ - XChainClaimAttestationBatchElement - ] = _get_new_list() + xchain_claim_attestation_batch: List[XChainClaimAttestationBatchElement] = field( + default_factory=list + ) xchain_create_account_attestation_batch: List[ XChainCreateAccountAttestationBatchElement - ] = _get_new_list() + ] = field(default_factory=list) @require_kwargs_on_init From 1694f8126fb3ca0cef277578696950ed2ccfe50a Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Mon, 30 Jan 2023 11:38:12 -0500 Subject: [PATCH 065/111] Update definitions.json --- xrpl/core/binarycodec/definitions/definitions.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xrpl/core/binarycodec/definitions/definitions.json b/xrpl/core/binarycodec/definitions/definitions.json index c90297ff7..89d50f99e 100644 --- a/xrpl/core/binarycodec/definitions/definitions.json +++ b/xrpl/core/binarycodec/definitions/definitions.json @@ -2665,8 +2665,10 @@ "XChainCommit": 42, "XChainClaim": 43, "XChainAccountCreateCommit": 44, - "XChainAddAttestation": 45, - "XChainModifyBridge": 46, + "XChainAddAttestationBatch": 45, + "XChainAddClaimAttestation": 46, + "XChainAddAccountCreateAttestation": 47, + "XChainModifyBridge": 48, "EnableAmendment": 100, "SetFee": 101, "UNLModify": 102 From 32152d6e8ed9434269ceea746c0828d248758f45 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Mon, 30 Jan 2023 11:42:45 -0500 Subject: [PATCH 066/111] fix tests --- .../unit/core/binarycodec/fixtures/data/codec-fixtures.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json b/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json index dae22f7ec..4d88f6dac 100644 --- a/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json +++ b/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json @@ -4471,7 +4471,7 @@ } }, { - "binary": "12002E2200000000240000000168400000000000000A601D40000000000003E8601E400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02074473045022100D2CABC1B0E0635A8EE2E6554F6D474C49BC292C995C5C9F83179F4A60634B04C02205D1DB569D9593136F2FBEA7140010C8F46794D653AFDBEA8D30B8750BA4805E58114B5F762798A53D543A014CAF8B297CFF8F2F937E8011914AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", + "binary": "1200302200000000240000000168400000000000000A601D40000000000003E8601E400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02074473045022100D2CABC1B0E0635A8EE2E6554F6D474C49BC292C995C5C9F83179F4A60634B04C02205D1DB569D9593136F2FBEA7140010C8F46794D653AFDBEA8D30B8750BA4805E58114B5F762798A53D543A014CAF8B297CFF8F2F937E8011914AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", "json": { "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "XChainBridge": { @@ -4559,7 +4559,7 @@ "Flags" : 2147483648, "Sequence" : 4, "SigningPubKey" : "0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020", - "TransactionType" : "XChainAddAttestation", + "TransactionType" : "XChainAddAttestationBatch", "TxnSignature" : "3045022100A6A8CA05B2B6CB60E0FD645A4DA0314D46D79D9FA3D63307FC997357366151B202202266CC23E2CA827905F37F78F54AD435F73A3B704EDD634B89201E23625CE2E2", "XChainAttestationBatch" : { "XChainBridge" : { @@ -4615,7 +4615,7 @@ "Flags": 2147483648, "Sequence": 1, "SigningPubKey": "0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020", - "TransactionType": "XChainAddAttestation", + "TransactionType": "XChainAddAttestationBatch", "TxnSignature": "304502210098F47661D8EF89CC2DFF3EAA92AF3843CEFD398EAD1E7496FAEAC269DE688FB80220143EBE519FC1936E884B1AFA047D4CB7CD2E2A28F0B27EC982D1BB3E63FC9535", "XChainAttestationBatch": { "XChainBridge": { From 1a6487b2ce5ad93f1c39c75aa86adf0b61362b5a Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Mon, 30 Jan 2023 11:53:41 -0500 Subject: [PATCH 067/111] rename XChainAddAttestation -> XChainAddAttestationBatch --- ...station.py => test_xchain_add_attestation_batch.py} | 10 +++++----- xrpl/models/transactions/__init__.py | 6 ++++-- xrpl/models/transactions/types/transaction_type.py | 2 +- ..._attestation.py => xchain_add_attestation_batch.py} | 10 +++++----- 4 files changed, 15 insertions(+), 13 deletions(-) rename tests/unit/models/transactions/{test_xchain_add_attestation.py => test_xchain_add_attestation_batch.py} (88%) rename xrpl/models/transactions/{xchain_add_attestation.py => xchain_add_attestation_batch.py} (90%) diff --git a/tests/unit/models/transactions/test_xchain_add_attestation.py b/tests/unit/models/transactions/test_xchain_add_attestation_batch.py similarity index 88% rename from tests/unit/models/transactions/test_xchain_add_attestation.py rename to tests/unit/models/transactions/test_xchain_add_attestation_batch.py index d56ad4cfb..bf52c368a 100644 --- a/tests/unit/models/transactions/test_xchain_add_attestation.py +++ b/tests/unit/models/transactions/test_xchain_add_attestation_batch.py @@ -1,7 +1,7 @@ from unittest import TestCase -from xrpl.models import XRP, XChainAddAttestation, XChainBridge, XRPLModelException -from xrpl.models.transactions.xchain_add_attestation import ( +from xrpl.models import XRP, XChainAddAttestationBatch, XChainBridge, XRPLModelException +from xrpl.models.transactions.xchain_add_attestation_batch import ( XChainAttestationBatch, XChainClaimAttestationBatchElement, XChainCreateAccountAttestationBatchElement, @@ -45,9 +45,9 @@ ) -class TestXChainAddAttestation(TestCase): +class TestXChainAddAttestationBatch(TestCase): def test_successful(self): - XChainAddAttestation( + XChainAddAttestationBatch( account=_ACCOUNT, xchain_attestation_batch=XChainAttestationBatch( xchain_bridge=_XRP_BRIDGE, @@ -58,7 +58,7 @@ def test_successful(self): def test_too_many_attestations(self): with self.assertRaises(XRPLModelException): - XChainAddAttestation( + XChainAddAttestationBatch( account=_ACCOUNT, xchain_attestation_batch=XChainAttestationBatch( xchain_bridge=_XRP_BRIDGE, diff --git a/xrpl/models/transactions/__init__.py b/xrpl/models/transactions/__init__.py index 01fe949f2..7423746e1 100644 --- a/xrpl/models/transactions/__init__.py +++ b/xrpl/models/transactions/__init__.py @@ -56,7 +56,9 @@ from xrpl.models.transactions.xchain_account_create_commit import ( XChainAccountCreateCommit, ) -from xrpl.models.transactions.xchain_add_attestation import XChainAddAttestation +from xrpl.models.transactions.xchain_add_attestation_batch import ( + XChainAddAttestationBatch, +) from xrpl.models.transactions.xchain_claim import XChainClaim from xrpl.models.transactions.xchain_commit import XChainCommit from xrpl.models.transactions.xchain_create_bridge import XChainCreateBridge @@ -107,7 +109,7 @@ "TrustSet", "TrustSetFlag", "TrustSetFlagInterface", - "XChainAddAttestation", + "XChainAddAttestationBatch", "XChainClaim", "XChainCommit", "XChainCreateBridge", diff --git a/xrpl/models/transactions/types/transaction_type.py b/xrpl/models/transactions/types/transaction_type.py index 9b926e525..f35dec960 100644 --- a/xrpl/models/transactions/types/transaction_type.py +++ b/xrpl/models/transactions/types/transaction_type.py @@ -30,7 +30,7 @@ class TransactionType(str, Enum): SIGNER_LIST_SET = "SignerListSet" TICKET_CREATE = "TicketCreate" TRUST_SET = "TrustSet" - XCHAIN_ADD_ATTESTATION = "XChainAddAttestation" + XCHAIN_ADD_ATTESTATION_BATCH = "XChainAddAttestationBatch" XCHAIN_CLAIM = "XChainClaim" XCHAIN_COMMIT = "XChainCommit" XCHAIN_ACCOUNT_CREATE_COMMIT = "XChainAccountCreateCommit" diff --git a/xrpl/models/transactions/xchain_add_attestation.py b/xrpl/models/transactions/xchain_add_attestation_batch.py similarity index 90% rename from xrpl/models/transactions/xchain_add_attestation.py rename to xrpl/models/transactions/xchain_add_attestation_batch.py index e7c219525..2cf2195ac 100644 --- a/xrpl/models/transactions/xchain_add_attestation.py +++ b/xrpl/models/transactions/xchain_add_attestation_batch.py @@ -1,4 +1,4 @@ -"""Model for a XChainAddAttestation transaction type.""" +"""Model for a XChainAddAttestationBatch transaction type.""" from __future__ import annotations @@ -81,17 +81,17 @@ class XChainAttestationBatch(BaseModel): @require_kwargs_on_init @dataclass(frozen=True) -class XChainAddAttestation(Transaction): - """Represents a XChainAddAttestation transaction.""" +class XChainAddAttestationBatch(Transaction): + """Represents a XChainAddAttestationBatch transaction.""" xchain_attestation_batch: XChainAttestationBatch = REQUIRED # type: ignore transaction_type: TransactionType = field( - default=TransactionType.XCHAIN_ADD_ATTESTATION, + default=TransactionType.XCHAIN_ADD_ATTESTATION_BATCH, init=False, ) - def _get_errors(self: XChainAddAttestation) -> Dict[str, str]: + def _get_errors(self: XChainAddAttestationBatch) -> Dict[str, str]: errors = super()._get_errors() batch = self.xchain_attestation_batch From cdd474b33ffee7331b0f8e053bbd9fb64aad5921 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Mon, 30 Jan 2023 12:04:59 -0500 Subject: [PATCH 068/111] add XChainAddClaimAttestation tx --- .../transactions/types/transaction_type.py | 1 + .../xchain_add_claim_attestation.py | 44 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 xrpl/models/transactions/xchain_add_claim_attestation.py diff --git a/xrpl/models/transactions/types/transaction_type.py b/xrpl/models/transactions/types/transaction_type.py index f35dec960..53ff89a1e 100644 --- a/xrpl/models/transactions/types/transaction_type.py +++ b/xrpl/models/transactions/types/transaction_type.py @@ -31,6 +31,7 @@ class TransactionType(str, Enum): TICKET_CREATE = "TicketCreate" TRUST_SET = "TrustSet" XCHAIN_ADD_ATTESTATION_BATCH = "XChainAddAttestationBatch" + XCHAIN_ADD_CLAIM_ATTESTATION_BATCH = "XChainAddClaimAttestation" XCHAIN_CLAIM = "XChainClaim" XCHAIN_COMMIT = "XChainCommit" XCHAIN_ACCOUNT_CREATE_COMMIT = "XChainAccountCreateCommit" diff --git a/xrpl/models/transactions/xchain_add_claim_attestation.py b/xrpl/models/transactions/xchain_add_claim_attestation.py new file mode 100644 index 000000000..72ec30bfa --- /dev/null +++ b/xrpl/models/transactions/xchain_add_claim_attestation.py @@ -0,0 +1,44 @@ +"""Model for a XChainAddClaimAttestation transaction type.""" + +from __future__ import annotations + +from dataclasses import dataclass, field +from typing import Optional, Union + +from typing_extensions import Literal + +from xrpl.models.amounts import Amount +from xrpl.models.required import REQUIRED +from xrpl.models.transactions.transaction import Transaction +from xrpl.models.transactions.types import TransactionType +from xrpl.models.utils import require_kwargs_on_init +from xrpl.models.xchain_bridge import XChainBridge + + +@require_kwargs_on_init +@dataclass(frozen=True) +class XChainAddClaimAttestation(Transaction): + """Represents a XChainAddAttestationBatch transaction.""" + + xchain_bridge: XChainBridge = REQUIRED # type: ignore + + public_key: str = REQUIRED # type: ignore + + signature: str = REQUIRED # type: ignore + + other_chain_source: str = REQUIRED # type: ignore + + amount: Amount = REQUIRED # type: ignore + + attestation_reward_account: str = REQUIRED # type: ignore + + was_locking_chain_send: Union[Literal[0, 1]] = REQUIRED # type: ignore + + xchain_claim_id: str = REQUIRED # type: ignore + + destination: Optional[str] = None + + transaction_type: TransactionType = field( + default=TransactionType.XCHAIN_ADD_ATTESTATION_BATCH, + init=False, + ) From ca369d23755bc5d66bf6643be1deb757f68aa2e7 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Mon, 30 Jan 2023 12:15:50 -0500 Subject: [PATCH 069/111] add XChainAddAccountCreateAttestation tx --- .../transactions/types/transaction_type.py | 3 +- .../xchain_add_account_create_attestation.py | 46 +++++++++++++++++++ .../xchain_add_claim_attestation.py | 2 +- 3 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 xrpl/models/transactions/xchain_add_account_create_attestation.py diff --git a/xrpl/models/transactions/types/transaction_type.py b/xrpl/models/transactions/types/transaction_type.py index 53ff89a1e..3723988f2 100644 --- a/xrpl/models/transactions/types/transaction_type.py +++ b/xrpl/models/transactions/types/transaction_type.py @@ -31,7 +31,8 @@ class TransactionType(str, Enum): TICKET_CREATE = "TicketCreate" TRUST_SET = "TrustSet" XCHAIN_ADD_ATTESTATION_BATCH = "XChainAddAttestationBatch" - XCHAIN_ADD_CLAIM_ATTESTATION_BATCH = "XChainAddClaimAttestation" + XCHAIN_ADD_CLAIM_ATTESTATION = "XChainAddClaimAttestation" + XCHAIN_ADD_ACCOUNT_CREATE_ATTESTATION = "XChainAddAccountCreateAttestation" XCHAIN_CLAIM = "XChainClaim" XCHAIN_COMMIT = "XChainCommit" XCHAIN_ACCOUNT_CREATE_COMMIT = "XChainAccountCreateCommit" diff --git a/xrpl/models/transactions/xchain_add_account_create_attestation.py b/xrpl/models/transactions/xchain_add_account_create_attestation.py new file mode 100644 index 000000000..56d265b24 --- /dev/null +++ b/xrpl/models/transactions/xchain_add_account_create_attestation.py @@ -0,0 +1,46 @@ +"""Model for a XChainAddAccountCreateAttestation transaction type.""" + +from __future__ import annotations + +from dataclasses import dataclass, field +from typing import Union + +from typing_extensions import Literal + +from xrpl.models.amounts import Amount +from xrpl.models.required import REQUIRED +from xrpl.models.transactions.transaction import Transaction +from xrpl.models.transactions.types import TransactionType +from xrpl.models.utils import require_kwargs_on_init +from xrpl.models.xchain_bridge import XChainBridge + + +@require_kwargs_on_init +@dataclass(frozen=True) +class XChainAddAccountCreateAttestation(Transaction): + """Represents a XChainAddAccountCreateAttestation transaction.""" + + xchain_bridge: XChainBridge = REQUIRED # type: ignore + + public_key: str = REQUIRED # type: ignore + + signature: str = REQUIRED # type: ignore + + other_chain_source: str = REQUIRED # type: ignore + + amount: Amount = REQUIRED # type: ignore + + attestation_reward_account: str = REQUIRED # type: ignore + + was_locking_chain_send: Union[Literal[0, 1]] = REQUIRED # type: ignore + + xchain_account_create_count: str = REQUIRED # type: ignore + + destination: str = REQUIRED # type: ignore + + signature_reward: Amount = REQUIRED # type: ignore + + transaction_type: TransactionType = field( + default=TransactionType.XCHAIN_ADD_ACCOUNT_CREATE_ATTESTATION, + init=False, + ) diff --git a/xrpl/models/transactions/xchain_add_claim_attestation.py b/xrpl/models/transactions/xchain_add_claim_attestation.py index 72ec30bfa..f136b99cd 100644 --- a/xrpl/models/transactions/xchain_add_claim_attestation.py +++ b/xrpl/models/transactions/xchain_add_claim_attestation.py @@ -39,6 +39,6 @@ class XChainAddClaimAttestation(Transaction): destination: Optional[str] = None transaction_type: TransactionType = field( - default=TransactionType.XCHAIN_ADD_ATTESTATION_BATCH, + default=TransactionType.XCHAIN_ADD_CLAIM_ATTESTATION, init=False, ) From d663b302ec8d774521a26882e0e62ef97c3c1788 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Mon, 30 Jan 2023 14:04:15 -0500 Subject: [PATCH 070/111] export new txs --- xrpl/models/transactions/__init__.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/xrpl/models/transactions/__init__.py b/xrpl/models/transactions/__init__.py index 7423746e1..0b1227225 100644 --- a/xrpl/models/transactions/__init__.py +++ b/xrpl/models/transactions/__init__.py @@ -56,9 +56,15 @@ from xrpl.models.transactions.xchain_account_create_commit import ( XChainAccountCreateCommit, ) +from xrpl.models.transactions.xchain_add_account_create_attestation import ( + XChainAddAccountCreateAttestation, +) from xrpl.models.transactions.xchain_add_attestation_batch import ( XChainAddAttestationBatch, ) +from xrpl.models.transactions.xchain_add_claim_attestation import ( + XChainAddClaimAttestation, +) from xrpl.models.transactions.xchain_claim import XChainClaim from xrpl.models.transactions.xchain_commit import XChainCommit from xrpl.models.transactions.xchain_create_bridge import XChainCreateBridge @@ -109,11 +115,13 @@ "TrustSet", "TrustSetFlag", "TrustSetFlagInterface", + "XChainAccountCreateCommit", + "XChainAddAccountCreateAttestation", "XChainAddAttestationBatch", + "XChainAddClaimAttestation", "XChainClaim", "XChainCommit", "XChainCreateBridge", "XChainCreateClaimID", "XChainModifyBridge", - "XChainAccountCreateCommit", ] From b6f19bf1872a612307d54f84b9a21daf98b3c303 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Thu, 2 Feb 2023 08:58:16 -0500 Subject: [PATCH 071/111] fix types in WasLockingChainSend --- .../transactions/xchain_add_account_create_attestation.py | 2 +- xrpl/models/transactions/xchain_add_attestation_batch.py | 4 ++-- xrpl/models/transactions/xchain_add_claim_attestation.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/xrpl/models/transactions/xchain_add_account_create_attestation.py b/xrpl/models/transactions/xchain_add_account_create_attestation.py index 56d265b24..572bdda21 100644 --- a/xrpl/models/transactions/xchain_add_account_create_attestation.py +++ b/xrpl/models/transactions/xchain_add_account_create_attestation.py @@ -32,7 +32,7 @@ class XChainAddAccountCreateAttestation(Transaction): attestation_reward_account: str = REQUIRED # type: ignore - was_locking_chain_send: Union[Literal[0, 1]] = REQUIRED # type: ignore + was_locking_chain_send: Union[Literal[0], Literal[1]] = REQUIRED # type: ignore xchain_account_create_count: str = REQUIRED # type: ignore diff --git a/xrpl/models/transactions/xchain_add_attestation_batch.py b/xrpl/models/transactions/xchain_add_attestation_batch.py index 2cf2195ac..149f6a10c 100644 --- a/xrpl/models/transactions/xchain_add_attestation_batch.py +++ b/xrpl/models/transactions/xchain_add_attestation_batch.py @@ -34,7 +34,7 @@ class XChainClaimAttestationBatchElement(NestedModel): signature: str = REQUIRED # type: ignore - was_locking_chain_send: Union[Literal[0, 1]] = REQUIRED # type: ignore + was_locking_chain_send: Union[Literal[0], Literal[1]] = REQUIRED # type: ignore xchain_claim_id: str = REQUIRED # type: ignore @@ -58,7 +58,7 @@ class XChainCreateAccountAttestationBatchElement(NestedModel): signature_reward: Amount = REQUIRED # type: ignore - was_locking_chain_send: Union[Literal[0, 1]] = REQUIRED # type: ignore + was_locking_chain_send: Union[Literal[0], Literal[1]] = REQUIRED # type: ignore xchain_account_create_count: str = REQUIRED # type: ignore diff --git a/xrpl/models/transactions/xchain_add_claim_attestation.py b/xrpl/models/transactions/xchain_add_claim_attestation.py index f136b99cd..eb4225af0 100644 --- a/xrpl/models/transactions/xchain_add_claim_attestation.py +++ b/xrpl/models/transactions/xchain_add_claim_attestation.py @@ -32,7 +32,7 @@ class XChainAddClaimAttestation(Transaction): attestation_reward_account: str = REQUIRED # type: ignore - was_locking_chain_send: Union[Literal[0, 1]] = REQUIRED # type: ignore + was_locking_chain_send: Union[Literal[0], Literal[1]] = REQUIRED # type: ignore xchain_claim_id: str = REQUIRED # type: ignore From cfdf7dbe03dc137579c5a390cfadcd85b77cbd25 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Mon, 6 Feb 2023 09:57:46 -0500 Subject: [PATCH 072/111] fix typo --- xrpl/models/transactions/xchain_add_claim_attestation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xrpl/models/transactions/xchain_add_claim_attestation.py b/xrpl/models/transactions/xchain_add_claim_attestation.py index eb4225af0..034cfc8d0 100644 --- a/xrpl/models/transactions/xchain_add_claim_attestation.py +++ b/xrpl/models/transactions/xchain_add_claim_attestation.py @@ -18,7 +18,7 @@ @require_kwargs_on_init @dataclass(frozen=True) class XChainAddClaimAttestation(Transaction): - """Represents a XChainAddAttestationBatch transaction.""" + """Represents a XChainAddClaimAttestation transaction.""" xchain_bridge: XChainBridge = REQUIRED # type: ignore From 71d5d6c7e2d94702820aaa1a53124727e8114cbe Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Mon, 6 Feb 2023 12:17:43 -0500 Subject: [PATCH 073/111] remove XChainAddAttestationBatch --- .../fixtures/data/codec-fixtures.json | 123 ------------------ .../test_xchain_add_attestation_batch.py | 71 ---------- .../binarycodec/definitions/definitions.json | 88 +++---------- xrpl/models/transactions/__init__.py | 4 - .../transactions/types/transaction_type.py | 5 +- .../xchain_add_attestation_batch.py | 104 --------------- 6 files changed, 20 insertions(+), 375 deletions(-) delete mode 100644 tests/unit/models/transactions/test_xchain_add_attestation_batch.py delete mode 100644 xrpl/models/transactions/xchain_add_attestation_batch.py diff --git a/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json b/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json index 4d88f6dac..d0925fa4f 100644 --- a/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json +++ b/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json @@ -4551,41 +4551,6 @@ "XChainClaimID": "0000000000000001" } }, - { - "binary": "12002D2280000000240000000468400000000000000A73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02074473045022100A6A8CA05B2B6CB60E0FD645A4DA0314D46D79D9FA3D63307FC997357366151B202202266CC23E2CA827905F37F78F54AD435F73A3B704EDD634B89201E23625CE2E28114B5F762798A53D543A014CAF8B297CFF8F2F937E8011A14C48CAD01682D7A86296EF14523074D4852C02EA9000000000000000000000000000000000000000014CC86E58C9B58D4CF71CB8C1B41F21BB290CE13D40000000000000000000000000000000000000000E02330140000000000000000614000000005F5E100712103DAB289CA36FF377F3F4304C7A7203FDE5EDCBFC209F430F6A4355361425526D0760361626381142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314621D345F8F094A085132431C69C89EC05D212CC28015142F3CC37C1D5616B3BBF1AABC49F6BFF46A92008700101301E1F1F1", - "json": { - "Account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", - "Fee" : "10", - "Flags" : 2147483648, - "Sequence" : 4, - "SigningPubKey" : "0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020", - "TransactionType" : "XChainAddAttestationBatch", - "TxnSignature" : "3045022100A6A8CA05B2B6CB60E0FD645A4DA0314D46D79D9FA3D63307FC997357366151B202202266CC23E2CA827905F37F78F54AD435F73A3B704EDD634B89201E23625CE2E2", - "XChainAttestationBatch" : { - "XChainBridge" : { - "IssuingChainDoor" : "rKeSSvHvaMZJp9ykaxutVwkhZgWuWMLnQt", - "IssuingChainIssue" : {"currency": "XRP"}, - "LockingChainDoor" : "rJvExveLEL4jNDEeLKCVdxaSCN9cEBnEQC", - "LockingChainIssue" : {"currency": "XRP"} - }, - "XChainClaimAttestationBatch" : [ - { - "XChainClaimAttestationBatchElement" : { - "Account" : "rnJmYAiqEVngtnb5ckRroXLtCbWC7CRUBx", - "Amount" : "100000000", - "AttestationRewardAccount" : "rnJmYAiqEVngtnb5ckRroXLtCbWC7CRUBx", - "Destination" : "r9A8UyNpW3X46FUc6P7JZqgn6WgAPjBwPg", - "PublicKey" : "03DAB289CA36FF377F3F4304C7A7203FDE5EDCBFC209F430F6A4355361425526D0", - "Signature" : "616263", - "WasLockingChainSend" : 1, - "XChainClaimID" : "0000000000000000" - } - } - ], - "XChainCreateAccountAttestationBatch" : [] - } - } - }, { "binary": "12002C228000000024000000016140000000000F424068400000000000000A601D400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD0207446304402202984DDE7F0B566F081F7953D7212BF031ACBF8860FE114102E9512C4C8768C77022070113F4630B1DC3045E4A98DDD648CEBC31B12774F7B44A1B8123CD2C9F5CF188114B5F762798A53D543A014CAF8B297CFF8F2F937E88314AF80285F637EE4AF3C20378F9DFB12511ACB8D27011914AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", "json": { @@ -4606,94 +4571,6 @@ "TransactionType": "XChainAccountCreateCommit", "TxnSignature": "304402202984DDE7F0B566F081F7953D7212BF031ACBF8860FE114102E9512C4C8768C77022070113F4630B1DC3045E4A98DDD648CEBC31B12774F7B44A1B8123CD2C9F5CF18" } - }, - { - "binary": "12002D2280000000240000000168400000000000000A73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD0207447304502210098F47661D8EF89CC2DFF3EAA92AF3843CEFD398EAD1E7496FAEAC269DE688FB80220143EBE519FC1936E884B1AFA047D4CB7CD2E2A28F0B27EC982D1BB3E63FC95358114B5F762798A53D543A014CAF8B297CFF8F2F937E8011A14C48CAD01682D7A86296EF14523074D4852C02EA9000000000000000000000000000000000000000014CC86E58C9B58D4CF71CB8C1B41F21BB290CE13D40000000000000000000000000000000000000000F1E0243015000000000000000161400000003B9ACA00601D40000000000F4240712103ADB44CA8E56F78A0096825E5667C450ABD5C24C34E027BC1AAF7E5BD114CB5B576463044022036C8B90F85E8073C465F00625248A72D4714600F98EBBADBAD3B7ED226109A3A02204C5A0AE12D169CF790F66541F3DB59C289E0D99CA7511FDFE352BB601F667A2681142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801514A482A071D77722C2B683FFE01DC30134035E8E7200101301E1E0243015000000000000000161400000003B9ACA00601D40000000000F4240712102A14E886B3C3579FBAE3139F29728B903E6F4295AEE92160C8480695524D66A157646304402200C3F5EEE2D7DCB609EE8558258E6AAF1EF823133C2B7C716E0DC9AAD2110F08D0220180E9F285CB2F78E362D37E947C000A8ED60A4BD8EFF21F74C5E529E1A8870ED81142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801514A482A071D77722C2B683FFE01DC30134035E8E7200101301E1E0243015000000000000000161400000003B9ACA00601D40000000000F4240712102F7390DCF3352060847B81666EBAC79D52DEA2443BDF58439F75397C45334E2DC764730450221008E31CFF0198F09CBA8610A946C23E170A3F11BCB8FC95D0D56C7B79A126D97D102203F4E952C449F2F01C4AF67FC37772A0D4459D770387CC11DBD5464FAB218542881142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801514A482A071D77722C2B683FFE01DC30134035E8E7200101301E1E0243015000000000000000161400000003B9ACA00601D40000000000F4240712102498BD8CD9CA6A4BA567A2ECFA163F118AFD30511CBBA71429C2EC2F74D76059276473045022100F4E2D672F456CB9929EF01766AB72B42C71314A181232098563B8666E4EEA49C02203F936877E9DCC8FF5F7713579233985DF3DADB155F2BDA78FE3A4321373F370E81142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801514A482A071D77722C2B683FFE01DC30134035E8E7200101301E1E0243015000000000000000161400000003B9ACA00601D40000000000F4240712103219642288DEE8A3AA8FEA1F7DAE9ED4D9A9F0EADA1E2DE3DB56DD9598D9AD81776473045022100D1BAFA57F40E16485310698B7B0BD0D4650E18782C4D65787A393CBB6D659EB802204EA28303089CCCD1463866A1BA0493A9B135AEA1EDFC8DD69A1A247DD9FEDB2181142F3CC37C1D5616B3BBF1AABC49F6BFF46A9200878314CA64525733C3BEED910CFE2AE280D3C078DABB4B801514A482A071D77722C2B683FFE01DC30134035E8E7200101301E1F1", - "json": { - "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", - "Fee": "10", - "Flags": 2147483648, - "Sequence": 1, - "SigningPubKey": "0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020", - "TransactionType": "XChainAddAttestationBatch", - "TxnSignature": "304502210098F47661D8EF89CC2DFF3EAA92AF3843CEFD398EAD1E7496FAEAC269DE688FB80220143EBE519FC1936E884B1AFA047D4CB7CD2E2A28F0B27EC982D1BB3E63FC9535", - "XChainAttestationBatch": { - "XChainBridge": { - "IssuingChainDoor": "rKeSSvHvaMZJp9ykaxutVwkhZgWuWMLnQt", - "IssuingChainIssue": {"currency": "XRP"}, - "LockingChainDoor": "rJvExveLEL4jNDEeLKCVdxaSCN9cEBnEQC", - "LockingChainIssue": {"currency": "XRP"} - }, - "XChainClaimAttestationBatch": [], - "XChainCreateAccountAttestationBatch": [ - { - "XChainCreateAccountAttestationBatchElement": { - "Account": "rnJmYAiqEVngtnb5ckRroXLtCbWC7CRUBx", - "Amount": "1000000000", - "AttestationRewardAccount": "rEziJZmeZzsJvGVUmpUTey7qxQLKYxaK9f", - "Destination": "rKT9gDkaedAosiHyHZTjyZs2HvXpzuiGmC", - "PublicKey": "03ADB44CA8E56F78A0096825E5667C450ABD5C24C34E027BC1AAF7E5BD114CB5B5", - "Signature": "3044022036C8B90F85E8073C465F00625248A72D4714600F98EBBADBAD3B7ED226109A3A02204C5A0AE12D169CF790F66541F3DB59C289E0D99CA7511FDFE352BB601F667A26", - "SignatureReward": "1000000", - "WasLockingChainSend": 1, - "XChainAccountCreateCount": "0000000000000001" - } - }, - { - "XChainCreateAccountAttestationBatchElement": { - "Account": "rnJmYAiqEVngtnb5ckRroXLtCbWC7CRUBx", - "Amount": "1000000000", - "AttestationRewardAccount": "rEziJZmeZzsJvGVUmpUTey7qxQLKYxaK9f", - "Destination": "rKT9gDkaedAosiHyHZTjyZs2HvXpzuiGmC", - "PublicKey": "02A14E886B3C3579FBAE3139F29728B903E6F4295AEE92160C8480695524D66A15", - "Signature": "304402200C3F5EEE2D7DCB609EE8558258E6AAF1EF823133C2B7C716E0DC9AAD2110F08D0220180E9F285CB2F78E362D37E947C000A8ED60A4BD8EFF21F74C5E529E1A8870ED", - "SignatureReward": "1000000", - "WasLockingChainSend": 1, - "XChainAccountCreateCount": "0000000000000001" - } - }, - { - "XChainCreateAccountAttestationBatchElement": { - "Account": "rnJmYAiqEVngtnb5ckRroXLtCbWC7CRUBx", - "Amount": "1000000000", - "AttestationRewardAccount": "rEziJZmeZzsJvGVUmpUTey7qxQLKYxaK9f", - "Destination": "rKT9gDkaedAosiHyHZTjyZs2HvXpzuiGmC", - "PublicKey": "02F7390DCF3352060847B81666EBAC79D52DEA2443BDF58439F75397C45334E2DC", - "Signature": "30450221008E31CFF0198F09CBA8610A946C23E170A3F11BCB8FC95D0D56C7B79A126D97D102203F4E952C449F2F01C4AF67FC37772A0D4459D770387CC11DBD5464FAB2185428", - "SignatureReward": "1000000", - "WasLockingChainSend": 1, - "XChainAccountCreateCount": "0000000000000001" - } - }, - { - "XChainCreateAccountAttestationBatchElement": { - "Account": "rnJmYAiqEVngtnb5ckRroXLtCbWC7CRUBx", - "Amount": "1000000000", - "AttestationRewardAccount": "rEziJZmeZzsJvGVUmpUTey7qxQLKYxaK9f", - "Destination": "rKT9gDkaedAosiHyHZTjyZs2HvXpzuiGmC", - "PublicKey": "02498BD8CD9CA6A4BA567A2ECFA163F118AFD30511CBBA71429C2EC2F74D760592", - "Signature": "3045022100F4E2D672F456CB9929EF01766AB72B42C71314A181232098563B8666E4EEA49C02203F936877E9DCC8FF5F7713579233985DF3DADB155F2BDA78FE3A4321373F370E", - "SignatureReward": "1000000", - "WasLockingChainSend": 1, - "XChainAccountCreateCount": "0000000000000001" - } - }, - { - "XChainCreateAccountAttestationBatchElement": { - "Account": "rnJmYAiqEVngtnb5ckRroXLtCbWC7CRUBx", - "Amount": "1000000000", - "AttestationRewardAccount": "rEziJZmeZzsJvGVUmpUTey7qxQLKYxaK9f", - "Destination": "rKT9gDkaedAosiHyHZTjyZs2HvXpzuiGmC", - "PublicKey": "03219642288DEE8A3AA8FEA1F7DAE9ED4D9A9F0EADA1E2DE3DB56DD9598D9AD817", - "Signature": "3045022100D1BAFA57F40E16485310698B7B0BD0D4650E18782C4D65787A393CBB6D659EB802204EA28303089CCCD1463866A1BA0493A9B135AEA1EDFC8DD69A1A247DD9FEDB21", - "SignatureReward": "1000000", - "WasLockingChainSend": 1, - "XChainAccountCreateCount": "0000000000000001" - } - } - ] - } - } } ], "ledgerData": [{ diff --git a/tests/unit/models/transactions/test_xchain_add_attestation_batch.py b/tests/unit/models/transactions/test_xchain_add_attestation_batch.py deleted file mode 100644 index bf52c368a..000000000 --- a/tests/unit/models/transactions/test_xchain_add_attestation_batch.py +++ /dev/null @@ -1,71 +0,0 @@ -from unittest import TestCase - -from xrpl.models import XRP, XChainAddAttestationBatch, XChainBridge, XRPLModelException -from xrpl.models.transactions.xchain_add_attestation_batch import ( - XChainAttestationBatch, - XChainClaimAttestationBatchElement, - XChainCreateAccountAttestationBatchElement, -) - -_ACCOUNT = "r9LqNeG6qHxjeUocjvVki2XR35weJ9mZgQ" -_ACCOUNT2 = "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo" -_ACCOUNT3 = "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59" - -_REWARD_ACCOUNT = "rGWrZyQqhTp9Xu7G5Pkayo7bXjH4k4QYpf" - -_GENESIS = "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh" - -_XRP_BRIDGE = XChainBridge( - locking_chain_door=_ACCOUNT, - locking_chain_issue=XRP(), - issuing_chain_door=_GENESIS, - issuing_chain_issue=XRP(), -) - -_CLAIM_ATTESTATION = XChainClaimAttestationBatchElement( - account=_ACCOUNT2, - amount="10000000", - attestation_reward_account=_REWARD_ACCOUNT, - public_key="ED3CC1BBD0952A60088E89FA502921895FC81FBD79CAE9109A8FE2D23659AD5D56", - signature="616263", - was_locking_chain_send=0, - xchain_claim_id="2", -) - -_ACCOUNT_CREATE_ATTESTATION = XChainCreateAccountAttestationBatchElement( - account=_ACCOUNT2, - amount="10000000", - attestation_reward_account=_REWARD_ACCOUNT, - destination=_ACCOUNT3, - signature_reward="200", - public_key="ED3CC1BBD0952A60088E89FA502921895FC81FBD79CAE9109A8FE2D23659AD5D56", - signature="616263", - was_locking_chain_send=0, - xchain_account_create_count="2", -) - - -class TestXChainAddAttestationBatch(TestCase): - def test_successful(self): - XChainAddAttestationBatch( - account=_ACCOUNT, - xchain_attestation_batch=XChainAttestationBatch( - xchain_bridge=_XRP_BRIDGE, - xchain_claim_attestation_batch=[_CLAIM_ATTESTATION], - xchain_create_account_attestation_batch=[_ACCOUNT_CREATE_ATTESTATION], - ), - ) - - def test_too_many_attestations(self): - with self.assertRaises(XRPLModelException): - XChainAddAttestationBatch( - account=_ACCOUNT, - xchain_attestation_batch=XChainAttestationBatch( - xchain_bridge=_XRP_BRIDGE, - xchain_claim_attestation_batch=[_CLAIM_ATTESTATION] * 4, - xchain_create_account_attestation_batch=[ - _ACCOUNT_CREATE_ATTESTATION - ] - * 5, - ), - ) diff --git a/xrpl/core/binarycodec/definitions/definitions.json b/xrpl/core/binarycodec/definitions/definitions.json index 89d50f99e..2c1e55db4 100644 --- a/xrpl/core/binarycodec/definitions/definitions.json +++ b/xrpl/core/binarycodec/definitions/definitions.json @@ -1467,16 +1467,6 @@ "type": "Amount" } ], - [ - "XChainFee", - { - "nth": 28, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "Amount" - } - ], [ "SignatureReward", { @@ -1837,16 +1827,6 @@ "type": "AccountID" } ], - [ - "ThisChainAccount", - { - "nth": 17, - "isVLEncoded": true, - "isSerialized": true, - "isSigningField": true, - "type": "AccountID" - } - ], [ "OtherChainSource", { @@ -2227,20 +2207,10 @@ "type": "STObject" } ], - [ - "XChainAttestationBatchElement", - { - "nth": 34, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "STObject" - } - ], [ "XChainClaimAttestationBatchElement", { - "nth": 35, + "nth": 34, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -2250,17 +2220,7 @@ [ "XChainCreateAccountAttestationBatchElement", { - "nth": 36, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "STObject" - } - ], - [ - "XChainAttestationBatchInner", - { - "nth": 37, + "nth": 35, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -2407,20 +2367,10 @@ "type": "STArray" } ], - [ - "XChainProofSigs", - { - "nth": 21, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "STArray" - } - ], [ "XChainClaimAttestationBatch", { - "nth": 22, + "nth": 21, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -2430,7 +2380,7 @@ [ "XChainCreateAccountAttestationBatch", { - "nth": 23, + "nth": 22, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -2440,7 +2390,7 @@ [ "XChainClaimAttestations", { - "nth": 24, + "nth": 23, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -2450,7 +2400,7 @@ [ "XChainCreateAccountAttestations", { - "nth": 25, + "nth": 24, "isVLEncoded": false, "isSerialized": true, "isSigningField": true, @@ -2619,16 +2569,15 @@ "tecXCHAIN_CLAIM_NO_QUORUM": 174, "tecXCHAIN_PROOF_UNKNOWN_KEY": 175, "tecXCHAIN_CREATE_ACCOUNT_NONXRP_ISSUE": 176, - "tecXCHAIN_CLAIM_ACCOUNT_DST_EXISTS": 177, - "tecXCHAIN_WRONG_CHAIN": 178, - "tecXCHAIN_REWARD_MISMATCH": 179, - "tecXCHAIN_NO_SIGNERS_LIST": 180, - "tecXCHAIN_SENDING_ACCOUNT_MISMATCH": 181, - "tecXCHAIN_INSUFF_CREATE_AMOUNT": 182, - "tecXCHAIN_ACCOUNT_CREATE_PAST": 183, - "tecXCHAIN_ACCOUNT_CREATE_TOO_MANY": 184, - "tecXCHAIN_PAYMENT_FAILED": 185, - "tecXCHAIN_SELF_COMMIT": 186 + "tecXCHAIN_WRONG_CHAIN": 177, + "tecXCHAIN_REWARD_MISMATCH": 178, + "tecXCHAIN_NO_SIGNERS_LIST": 179, + "tecXCHAIN_SENDING_ACCOUNT_MISMATCH": 180, + "tecXCHAIN_INSUFF_CREATE_AMOUNT": 181, + "tecXCHAIN_ACCOUNT_CREATE_PAST": 182, + "tecXCHAIN_ACCOUNT_CREATE_TOO_MANY": 183, + "tecXCHAIN_PAYMENT_FAILED": 184, + "tecXCHAIN_SELF_COMMIT": 185 }, "TRANSACTION_TYPES": { "Invalid": -1, @@ -2665,10 +2614,9 @@ "XChainCommit": 42, "XChainClaim": 43, "XChainAccountCreateCommit": 44, - "XChainAddAttestationBatch": 45, - "XChainAddClaimAttestation": 46, - "XChainAddAccountCreateAttestation": 47, - "XChainModifyBridge": 48, + "XChainAddClaimAttestation": 45, + "XChainAddAccountCreateAttestation": 46, + "XChainModifyBridge": 47, "EnableAmendment": 100, "SetFee": 101, "UNLModify": 102 diff --git a/xrpl/models/transactions/__init__.py b/xrpl/models/transactions/__init__.py index 0b1227225..056e7a680 100644 --- a/xrpl/models/transactions/__init__.py +++ b/xrpl/models/transactions/__init__.py @@ -59,9 +59,6 @@ from xrpl.models.transactions.xchain_add_account_create_attestation import ( XChainAddAccountCreateAttestation, ) -from xrpl.models.transactions.xchain_add_attestation_batch import ( - XChainAddAttestationBatch, -) from xrpl.models.transactions.xchain_add_claim_attestation import ( XChainAddClaimAttestation, ) @@ -117,7 +114,6 @@ "TrustSetFlagInterface", "XChainAccountCreateCommit", "XChainAddAccountCreateAttestation", - "XChainAddAttestationBatch", "XChainAddClaimAttestation", "XChainClaim", "XChainCommit", diff --git a/xrpl/models/transactions/types/transaction_type.py b/xrpl/models/transactions/types/transaction_type.py index 3723988f2..f2e7be32e 100644 --- a/xrpl/models/transactions/types/transaction_type.py +++ b/xrpl/models/transactions/types/transaction_type.py @@ -30,12 +30,11 @@ class TransactionType(str, Enum): SIGNER_LIST_SET = "SignerListSet" TICKET_CREATE = "TicketCreate" TRUST_SET = "TrustSet" - XCHAIN_ADD_ATTESTATION_BATCH = "XChainAddAttestationBatch" - XCHAIN_ADD_CLAIM_ATTESTATION = "XChainAddClaimAttestation" + XCHAIN_ACCOUNT_CREATE_COMMIT = "XChainAccountCreateCommit" XCHAIN_ADD_ACCOUNT_CREATE_ATTESTATION = "XChainAddAccountCreateAttestation" + XCHAIN_ADD_CLAIM_ATTESTATION = "XChainAddClaimAttestation" XCHAIN_CLAIM = "XChainClaim" XCHAIN_COMMIT = "XChainCommit" - XCHAIN_ACCOUNT_CREATE_COMMIT = "XChainAccountCreateCommit" XCHAIN_CREATE_BRIDGE = "XChainCreateBridge" XCHAIN_CREATE_CLAIM_ID = "XChainCreateClaimID" XCHAIN_MODIFY_BRIDGE = "XChainModifyBridge" diff --git a/xrpl/models/transactions/xchain_add_attestation_batch.py b/xrpl/models/transactions/xchain_add_attestation_batch.py deleted file mode 100644 index 149f6a10c..000000000 --- a/xrpl/models/transactions/xchain_add_attestation_batch.py +++ /dev/null @@ -1,104 +0,0 @@ -"""Model for a XChainAddAttestationBatch transaction type.""" - -from __future__ import annotations - -from dataclasses import dataclass, field -from typing import Dict, List, Optional, Union - -from typing_extensions import Literal - -from xrpl.models.amounts import Amount -from xrpl.models.base_model import BaseModel -from xrpl.models.nested_model import NestedModel -from xrpl.models.required import REQUIRED -from xrpl.models.transactions.transaction import Transaction -from xrpl.models.transactions.types import TransactionType -from xrpl.models.utils import require_kwargs_on_init -from xrpl.models.xchain_bridge import XChainBridge - - -@require_kwargs_on_init -@dataclass(frozen=True) -class XChainClaimAttestationBatchElement(NestedModel): - """Represents a single claim attestation.""" - - account: str = REQUIRED # type: ignore - - amount: Amount = REQUIRED # type: ignore - - attestation_reward_account: str = REQUIRED # type: ignore - - destination: Optional[str] = None - - public_key: str = REQUIRED # type: ignore - - signature: str = REQUIRED # type: ignore - - was_locking_chain_send: Union[Literal[0], Literal[1]] = REQUIRED # type: ignore - - xchain_claim_id: str = REQUIRED # type: ignore - - -@require_kwargs_on_init -@dataclass(frozen=True) -class XChainCreateAccountAttestationBatchElement(NestedModel): - """Represents a single account creation attestation.""" - - account: str = REQUIRED # type: ignore - - amount: Amount = REQUIRED # type: ignore - - attestation_reward_account: str = REQUIRED # type: ignore - - destination: str = REQUIRED # type: ignore - - public_key: str = REQUIRED # type: ignore - - signature: str = REQUIRED # type: ignore - - signature_reward: Amount = REQUIRED # type: ignore - - was_locking_chain_send: Union[Literal[0], Literal[1]] = REQUIRED # type: ignore - - xchain_account_create_count: str = REQUIRED # type: ignore - - -@require_kwargs_on_init -@dataclass(frozen=True) -class XChainAttestationBatch(BaseModel): - """Represents a set of attestations from a single witness server.""" - - xchain_bridge: XChainBridge = REQUIRED # type: ignore - - xchain_claim_attestation_batch: List[XChainClaimAttestationBatchElement] = field( - default_factory=list - ) - - xchain_create_account_attestation_batch: List[ - XChainCreateAccountAttestationBatchElement - ] = field(default_factory=list) - - -@require_kwargs_on_init -@dataclass(frozen=True) -class XChainAddAttestationBatch(Transaction): - """Represents a XChainAddAttestationBatch transaction.""" - - xchain_attestation_batch: XChainAttestationBatch = REQUIRED # type: ignore - - transaction_type: TransactionType = field( - default=TransactionType.XCHAIN_ADD_ATTESTATION_BATCH, - init=False, - ) - - def _get_errors(self: XChainAddAttestationBatch) -> Dict[str, str]: - errors = super()._get_errors() - - batch = self.xchain_attestation_batch - claim_batch = batch.xchain_claim_attestation_batch - account_create_batch = batch.xchain_create_account_attestation_batch - - if len(claim_batch) + len(account_create_batch) > 8: - errors["num_attestations"] = "Cannot have more than 8 attestations." - - return errors From 237711890123425008b5881ef248c09120e10a84 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Mon, 6 Feb 2023 12:18:40 -0500 Subject: [PATCH 074/111] fix tests --- tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json b/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json index d0925fa4f..140f7dec2 100644 --- a/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json +++ b/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json @@ -4471,7 +4471,7 @@ } }, { - "binary": "1200302200000000240000000168400000000000000A601D40000000000003E8601E400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02074473045022100D2CABC1B0E0635A8EE2E6554F6D474C49BC292C995C5C9F83179F4A60634B04C02205D1DB569D9593136F2FBEA7140010C8F46794D653AFDBEA8D30B8750BA4805E58114B5F762798A53D543A014CAF8B297CFF8F2F937E8011914AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", + "binary": "12002F2200000000240000000168400000000000000A601D40000000000003E8601E400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02074473045022100D2CABC1B0E0635A8EE2E6554F6D474C49BC292C995C5C9F83179F4A60634B04C02205D1DB569D9593136F2FBEA7140010C8F46794D653AFDBEA8D30B8750BA4805E58114B5F762798A53D543A014CAF8B297CFF8F2F937E8011914AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", "json": { "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "XChainBridge": { From acb58035d6329bdcb584def4f3737b781d209214 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Tue, 7 Feb 2023 15:12:57 -0500 Subject: [PATCH 075/111] update definitions --- .../binarycodec/definitions/definitions.json | 11 --- xrpl/core/binarycodec/types/__init__.py | 2 - .../types/xchain_attestation_batch.py | 95 ------------------- 3 files changed, 108 deletions(-) delete mode 100644 xrpl/core/binarycodec/types/xchain_attestation_batch.py diff --git a/xrpl/core/binarycodec/definitions/definitions.json b/xrpl/core/binarycodec/definitions/definitions.json index 2c1e55db4..1f0f4ec26 100644 --- a/xrpl/core/binarycodec/definitions/definitions.json +++ b/xrpl/core/binarycodec/definitions/definitions.json @@ -23,7 +23,6 @@ "UInt512": 23, "Issue": 24, "XChainBridge": 25, - "XChainAttestationBatch": 26, "Transaction": 10001, "LedgerEntry": 10002, "Validation": 10003, @@ -1967,16 +1966,6 @@ "type": "XChainBridge" } ], - [ - "XChainAttestationBatch", - { - "nth": 1, - "isVLEncoded": false, - "isSerialized": true, - "isSigningField": true, - "type": "XChainAttestationBatch" - } - ], [ "TransactionMetaData", { diff --git a/xrpl/core/binarycodec/types/__init__.py b/xrpl/core/binarycodec/types/__init__.py index 8536b536c..e9d31a608 100644 --- a/xrpl/core/binarycodec/types/__init__.py +++ b/xrpl/core/binarycodec/types/__init__.py @@ -17,7 +17,6 @@ from xrpl.core.binarycodec.types.uint32 import UInt32 from xrpl.core.binarycodec.types.uint64 import UInt64 from xrpl.core.binarycodec.types.vector256 import Vector256 -from xrpl.core.binarycodec.types.xchain_attestation_batch import XChainAttestationBatch from xrpl.core.binarycodec.types.xchain_bridge import XChainBridge __all__ = [ @@ -40,5 +39,4 @@ "UInt64", "Vector256", "XChainBridge", - "XChainAttestationBatch", ] diff --git a/xrpl/core/binarycodec/types/xchain_attestation_batch.py b/xrpl/core/binarycodec/types/xchain_attestation_batch.py deleted file mode 100644 index dd3882e93..000000000 --- a/xrpl/core/binarycodec/types/xchain_attestation_batch.py +++ /dev/null @@ -1,95 +0,0 @@ -"""Codec for serializing and deserializing bridge fields.""" -from __future__ import annotations - -from typing import Any, Dict, List, Optional, Tuple, Type, Union - -from xrpl.core.binarycodec.binary_wrappers.binary_parser import BinaryParser -from xrpl.core.binarycodec.exceptions import XRPLBinaryCodecException -from xrpl.core.binarycodec.types.serialized_type import SerializedType -from xrpl.core.binarycodec.types.st_array import STArray -from xrpl.core.binarycodec.types.xchain_bridge import XChainBridge - -_TYPE_ORDER: List[Tuple[str, Type[SerializedType]]] = [ - ("XChainBridge", XChainBridge), - ("XChainClaimAttestationBatch", STArray), - ("XChainCreateAccountAttestationBatch", STArray), -] - -_TYPE_KEYS = {type[0] for type in _TYPE_ORDER} - - -class XChainAttestationBatch(SerializedType): - """Codec for serializing and deserializing XChainAttestationBatch fields.""" - - def __init__(self: XChainAttestationBatch, buffer: bytes) -> None: - """Construct a XChainAttestationBatch from given bytes.""" - super().__init__(buffer) - - @classmethod - def from_value( - cls: Type[XChainAttestationBatch], value: Union[str, Dict[str, str]] - ) -> XChainAttestationBatch: - """ - Construct a XChainAttestationBatch object from a dictionary representation of a - XChainAttestationBatch. - - Args: - value: The dictionary to construct a XChainAttestationBatch object from. - - Returns: - A XChainAttestationBatch object constructed from value. - - Raises: - XRPLBinaryCodecException: If the XChainAttestationBatch representation is - invalid. - """ - if isinstance(value, dict) and set(value.keys()) == _TYPE_KEYS: - buffer = b"" - for (name, object_type) in _TYPE_ORDER: - obj = object_type.from_value(value[name]) - buffer += bytes(obj) - return cls(buffer) - - raise XRPLBinaryCodecException( - "Invalid type to construct an XChainAttestationBatch: expected dict," - f" received {value.__class__.__name__}." - ) - - @classmethod - def from_parser( - cls: Type[XChainAttestationBatch], - parser: BinaryParser, - length_hint: Optional[int] = None, - ) -> XChainAttestationBatch: - """ - Construct a XChainAttestationBatch object from an existing BinaryParser. - - Args: - parser: The parser to construct the XChainAttestationBatch object from. - length_hint: The number of bytes to consume from the parser. - - Returns: - The XChainAttestationBatch object constructed from a parser. - """ - buffer = b"" - - for (_, object_type) in _TYPE_ORDER: - obj = object_type.from_parser(parser, length_hint) - buffer += bytes(obj) - - return cls(buffer) - - def to_json(self: XChainAttestationBatch) -> Union[str, Dict[Any, Any]]: - """ - Returns the JSON representation of a XChainAttestationBatch. - - Returns: - The JSON representation of a XChainAttestationBatch. - """ - parser = BinaryParser(str(self)) - return_json = {} - for (name, object_type) in _TYPE_ORDER: - obj = object_type.from_parser(parser, None) - return_json[name] = obj.to_json() - - return return_json From abec1c398cab14e714e32d80214c1c1de717130e Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Tue, 14 Feb 2023 16:28:09 -0500 Subject: [PATCH 076/111] update to latest version of rippled --- xrpl/models/requests/ledger_entry.py | 3 +-- .../transactions/xchain_add_account_create_attestation.py | 2 ++ xrpl/models/transactions/xchain_add_claim_attestation.py | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/xrpl/models/requests/ledger_entry.py b/xrpl/models/requests/ledger_entry.py index 9837fbb52..3c9ba7eed 100644 --- a/xrpl/models/requests/ledger_entry.py +++ b/xrpl/models/requests/ledger_entry.py @@ -15,7 +15,6 @@ from xrpl.models.requests.request import Request, RequestMethod 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 @@ -200,7 +199,7 @@ class LedgerEntry(Request): payment_channel: Optional[str] = None ripple_state: Optional[RippleState] = None ticket: Optional[Union[str, Ticket]] = None - xchain_bridge: Optional[Union[str, XChainBridge]] = None + bridge_account: Optional[str] = None xchain_claim_id: Optional[Union[str, XChainClaimID]] = None xchain_create_account_claim_id: Optional[ Union[str, XChainCreateAccountClaimID] diff --git a/xrpl/models/transactions/xchain_add_account_create_attestation.py b/xrpl/models/transactions/xchain_add_account_create_attestation.py index 572bdda21..6c3196a77 100644 --- a/xrpl/models/transactions/xchain_add_account_create_attestation.py +++ b/xrpl/models/transactions/xchain_add_account_create_attestation.py @@ -32,6 +32,8 @@ class XChainAddAccountCreateAttestation(Transaction): attestation_reward_account: str = REQUIRED # type: ignore + attestation_signer_account: str = REQUIRED # type: ignore + was_locking_chain_send: Union[Literal[0], Literal[1]] = REQUIRED # type: ignore xchain_account_create_count: str = REQUIRED # type: ignore diff --git a/xrpl/models/transactions/xchain_add_claim_attestation.py b/xrpl/models/transactions/xchain_add_claim_attestation.py index 034cfc8d0..bb30700f6 100644 --- a/xrpl/models/transactions/xchain_add_claim_attestation.py +++ b/xrpl/models/transactions/xchain_add_claim_attestation.py @@ -32,6 +32,8 @@ class XChainAddClaimAttestation(Transaction): attestation_reward_account: str = REQUIRED # type: ignore + attestation_signer_account: str = REQUIRED # type: ignore + was_locking_chain_send: Union[Literal[0], Literal[1]] = REQUIRED # type: ignore xchain_claim_id: str = REQUIRED # type: ignore From 167c921299741eb217ff1103d889a97ab7d01f72 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Tue, 14 Feb 2023 17:37:22 -0500 Subject: [PATCH 077/111] add XChainModifyBridge flag --- xrpl/models/transactions/__init__.py | 8 +++++++- .../transactions/xchain_modify_bridge.py | 20 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/xrpl/models/transactions/__init__.py b/xrpl/models/transactions/__init__.py index 056e7a680..789f86571 100644 --- a/xrpl/models/transactions/__init__.py +++ b/xrpl/models/transactions/__init__.py @@ -66,7 +66,11 @@ from xrpl.models.transactions.xchain_commit import XChainCommit from xrpl.models.transactions.xchain_create_bridge import XChainCreateBridge from xrpl.models.transactions.xchain_create_claim_id import XChainCreateClaimID -from xrpl.models.transactions.xchain_modify_bridge import XChainModifyBridge +from xrpl.models.transactions.xchain_modify_bridge import ( + XChainModifyBridge, + XChainModifyBridgeFlag, + XChainModifyBridgeFlagInterface, +) __all__ = [ "AccountDelete", @@ -120,4 +124,6 @@ "XChainCreateBridge", "XChainCreateClaimID", "XChainModifyBridge", + "XChainModifyBridgeFlag", + "XChainModifyBridgeFlagInterface", ] diff --git a/xrpl/models/transactions/xchain_modify_bridge.py b/xrpl/models/transactions/xchain_modify_bridge.py index 4fd251675..ae8decc30 100644 --- a/xrpl/models/transactions/xchain_modify_bridge.py +++ b/xrpl/models/transactions/xchain_modify_bridge.py @@ -3,9 +3,11 @@ from __future__ import annotations from dataclasses import dataclass, field +from enum import Enum from typing import Dict, Optional from xrpl.models.currencies import XRP +from xrpl.models.flags import FlagInterface from xrpl.models.required import REQUIRED from xrpl.models.transactions.transaction import Transaction from xrpl.models.transactions.types import TransactionType @@ -13,6 +15,24 @@ from xrpl.models.xchain_bridge import XChainBridge +class XChainModifyBridgeFlag(int, Enum): + """ + Transactions of the XChainModifyBridge type support additional values in the Flags + field. This enum represents those options. + """ + + TF_CLEAR_ACCOUNT_CREATE_AMOUNT = 0x00010000 + + +class XChainModifyBridgeFlagInterface(FlagInterface): + """ + Transactions of the XChainModifyBridge type support additional values in the Flags + field. This TypedDict represents those options. + """ + + TF_CLEAR_ACCOUNT_CREATE_AMOUNT: bool + + @require_kwargs_on_init @dataclass(frozen=True) class XChainModifyBridge(Transaction): From 8864f3e9c42ca52235dbb638e815607019507d16 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Wed, 15 Feb 2023 09:57:12 -0500 Subject: [PATCH 078/111] Update definitions.json --- xrpl/core/binarycodec/definitions/definitions.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xrpl/core/binarycodec/definitions/definitions.json b/xrpl/core/binarycodec/definitions/definitions.json index 1f0f4ec26..cdf657a62 100644 --- a/xrpl/core/binarycodec/definitions/definitions.json +++ b/xrpl/core/binarycodec/definitions/definitions.json @@ -2566,7 +2566,8 @@ "tecXCHAIN_ACCOUNT_CREATE_PAST": 182, "tecXCHAIN_ACCOUNT_CREATE_TOO_MANY": 183, "tecXCHAIN_PAYMENT_FAILED": 184, - "tecXCHAIN_SELF_COMMIT": 185 + "tecXCHAIN_SELF_COMMIT": 185, + "tecXCHAIN_BAD_PUBLIC_KEY_ACCOUNT_PAIR": 186 }, "TRANSACTION_TYPES": { "Invalid": -1, From 06500b93e364237d72d4c1c418a840210b3a9936 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Wed, 15 Feb 2023 10:58:49 -0500 Subject: [PATCH 079/111] add binary codec tests for new txs --- .../fixtures/data/codec-fixtures.json | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json b/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json index 140f7dec2..2db6d128c 100644 --- a/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json +++ b/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json @@ -4571,6 +4571,68 @@ "TransactionType": "XChainAccountCreateCommit", "TxnSignature": "304402202984DDE7F0B566F081F7953D7212BF031ACBF8860FE114102E9512C4C8768C77022070113F4630B1DC3045E4A98DDD648CEBC31B12774F7B44A1B8123CD2C9F5CF18" } + }, + + { + "binary": "12002E2400000005201B0000000D30150000000000000006614000000000989680684000000000000014601D40000000000000647121ED1F4A024ACFEBDB6C7AA88DEDE3364E060487EA31B14CC9E0D610D152B31AADC27321EDF54108BA2E0A0D3DC2AE3897F8BE0EFE776AE8D0F9FB0D0B9D64233084A8DDD1744003E74AEF1F585F156786429D2FC87A89E5C6B5A56D68BFC9A6A329F3AC67CBF2B6958283C663A4522278CA162C69B23CF75149AF022B410EA0508C16F42058007640EEFCFA3DC2AB4AB7C4D2EBBC168CB621A11B82BABD86534DFC8EFA72439A49662D744073CD848E7A587A95B35162CDF9A69BB237E72C9537A987F5B8C394F30D81145E7A3E3D7200A794FA801C66CE3775B6416EE4128314C15F113E49BCC4B9FFF43CD0366C23ACD82F75638012143FD9ED9A79DEA67CB5D585111FEF0A29203FA0408015145E7A3E3D7200A794FA801C66CE3775B6416EE4120010130101191486F0B1126CE1205E59FDFDD2661A9FB7505CA70F000000000000000000000000000000000000000014B5F762798A53D543A014CAF8B297CFF8F2F937E80000000000000000000000000000000000000000", + "json": { + "Account": "r9cYxdjQsoXAEz3qQJc961SNLaXRkWXCvT", + "Amount": "10000000", + "AttestationRewardAccount": "r9cYxdjQsoXAEz3qQJc961SNLaXRkWXCvT", + "Destination": "rJdTJRJZ6GXCCRaamHJgEqVzB7Zy4557Pi", + "Fee": "20", + "LastLedgerSequence": 13, + "OtherChainSource": "raFcdz1g8LWJDJWJE2ZKLRGdmUmsTyxaym", + "PublicKey": "ED1F4A024ACFEBDB6C7AA88DEDE3364E060487EA31B14CC9E0D610D152B31AADC2", + "Sequence": 5, + "Signature": "EEFCFA3DC2AB4AB7C4D2EBBC168CB621A11B82BABD86534DFC8EFA72439A49662D744073CD848E7A587A95B35162CDF9A69BB237E72C9537A987F5B8C394F30D", + "SignatureReward": "100", + "SigningPubKey": "EDF54108BA2E0A0D3DC2AE3897F8BE0EFE776AE8D0F9FB0D0B9D64233084A8DDD1", + "TransactionType": "XChainAddAccountCreateAttestation", + "TxnSignature": "03E74AEF1F585F156786429D2FC87A89E5C6B5A56D68BFC9A6A329F3AC67CBF2B6958283C663A4522278CA162C69B23CF75149AF022B410EA0508C16F4205800", + "WasLockingChainSend": 1, + "XChainAccountCreateCount": "0000000000000006", + "XChainBridge": { + "IssuingChainDoor": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", + "IssuingChainIssue": { + "currency": "XRP" + }, + "LockingChainDoor": "rDJVtEuDKr4rj1B3qtW7R5TVWdXV2DY7Qg", + "LockingChainIssue": { + "currency": "XRP" + } + } + } + }, + { + "binary": "12002D2400000009201B00000013301400000000000000016140000000009896806840000000000000147121ED7541DEC700470F54276C90C333A13CDBB5D341FD43C60CEA12170F6D6D4E11367321ED0406B134786FE0751717226657F7BF8AFE96442C05D28ACEC66FB64852BA604C7440D0423649E48A44F181262CF5FC08A68E7FA5CD9E55843E4F09014B76E602574741E8553383A4B43CABD194BB96713647FC0B885BE248E4FFA068FA3E6994CF0476407C175050B08000AD35EEB2D87E16CD3F95A0AEEBF2A049474275153D9D4DD44528FE99AA50E71660A15B0B768E1B90E609BBD5DC7AFAFD45D9705D72D40EA10C81141F30A4D728AB98B0950EC3B9815E6C8D43A7D5598314C15F113E49BCC4B9FFF43CD0366C23ACD82F75638012143FD9ED9A79DEA67CB5D585111FEF0A29203FA0408015141F30A4D728AB98B0950EC3B9815E6C8D43A7D5590010130101191486F0B1126CE1205E59FDFDD2661A9FB7505CA70F000000000000000000000000000000000000000014B5F762798A53D543A014CAF8B297CFF8F2F937E80000000000000000000000000000000000000000", + "json": { + "Account": "rsqvD8WFFEBBv4nztpoW9YYXJ7eRzLrtc3", + "Amount": "10000000", + "AttestationRewardAccount": "rsqvD8WFFEBBv4nztpoW9YYXJ7eRzLrtc3", + "Destination": "rJdTJRJZ6GXCCRaamHJgEqVzB7Zy4557Pi", + "Fee": "20", + "LastLedgerSequence": 19, + "OtherChainSource": "raFcdz1g8LWJDJWJE2ZKLRGdmUmsTyxaym", + "PublicKey": "ED7541DEC700470F54276C90C333A13CDBB5D341FD43C60CEA12170F6D6D4E1136", + "Sequence": 9, + "Signature": "7C175050B08000AD35EEB2D87E16CD3F95A0AEEBF2A049474275153D9D4DD44528FE99AA50E71660A15B0B768E1B90E609BBD5DC7AFAFD45D9705D72D40EA10C", + "SigningPubKey": "ED0406B134786FE0751717226657F7BF8AFE96442C05D28ACEC66FB64852BA604C", + "TransactionType": "XChainAddClaimAttestation", + "TxnSignature": "D0423649E48A44F181262CF5FC08A68E7FA5CD9E55843E4F09014B76E602574741E8553383A4B43CABD194BB96713647FC0B885BE248E4FFA068FA3E6994CF04", + "WasLockingChainSend": 1, + "XChainBridge": { + "IssuingChainDoor": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", + "IssuingChainIssue": { + "currency": "XRP" + }, + "LockingChainDoor": "rDJVtEuDKr4rj1B3qtW7R5TVWdXV2DY7Qg", + "LockingChainIssue": { + "currency": "XRP" + } + }, + "XChainClaimID": "0000000000000001" + } } ], "ledgerData": [{ From a2e2e8d0a1d7865f5aaac73f6408709c67ad0499 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Thu, 23 Mar 2023 16:25:50 -0400 Subject: [PATCH 080/111] fix validation for XChainCreateClaimID --- xrpl/models/transactions/xchain_create_claim_id.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xrpl/models/transactions/xchain_create_claim_id.py b/xrpl/models/transactions/xchain_create_claim_id.py index 859b3947c..de9b8b329 100644 --- a/xrpl/models/transactions/xchain_create_claim_id.py +++ b/xrpl/models/transactions/xchain_create_claim_id.py @@ -35,7 +35,9 @@ def _get_errors(self: XChainCreateClaimID) -> Dict[str, str]: if self.signature_reward is not None and not self.signature_reward.isnumeric(): errors["signature_reward"] = "`signature_reward` must be numeric." - if not is_valid_classic_address(self.other_chain_source): + if self.other_chain_source is not None and not is_valid_classic_address( + self.other_chain_source + ): errors[ "other_chain_source" ] = "`other_chain_source` must be a valid XRPL address." From 895058a238254fab19d8247903862329b02e038b Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Wed, 5 Apr 2023 16:27:49 -0400 Subject: [PATCH 081/111] add docs --- .../xchain_account_create_commit.py | 31 +++++++- .../xchain_add_account_create_attestation.py | 72 ++++++++++++++++++- .../xchain_add_claim_attestation.py | 65 ++++++++++++++++- xrpl/models/transactions/xchain_claim.py | 39 +++++++++- xrpl/models/transactions/xchain_commit.py | 37 +++++++++- .../transactions/xchain_create_bridge.py | 26 ++++++- .../transactions/xchain_create_claim_id.py | 25 ++++++- .../transactions/xchain_modify_bridge.py | 24 ++++++- xrpl/models/xchain_bridge.py | 19 +++++ 9 files changed, 330 insertions(+), 8 deletions(-) diff --git a/xrpl/models/transactions/xchain_account_create_commit.py b/xrpl/models/transactions/xchain_account_create_commit.py index 865adc383..7c2fc5f20 100644 --- a/xrpl/models/transactions/xchain_account_create_commit.py +++ b/xrpl/models/transactions/xchain_account_create_commit.py @@ -15,15 +15,44 @@ @require_kwargs_on_init @dataclass(frozen=True) class XChainAccountCreateCommit(Transaction): - """Represents a XChainAccountCreateCommit transaction.""" + """ + Represents a XChainAccountCreateCommit transaction on the XRP Ledger. + The XChainAccountCreateCommit transaction creates a new account on one of + the chains a bridge connects, which serves as the bridge entrance for that + chain. + """ xchain_bridge: XChainBridge = REQUIRED # type: ignore + """ + The bridge to create accounts for. This field is required. + + :meta hide-value: + """ signature_reward: str = REQUIRED # type: ignore + """ + The amount, in XRP, to be used to reward the witness servers for providing + signatures. This must match the amount on the ``Bridge`` ledger object. This + field is required. + + :meta hide-value: + """ destination: str = REQUIRED # type: ignore + """ + The destination account on the destination chain. This field is required. + + :meta hide-value: + """ amount: str = REQUIRED # type: ignore + """ + The amount, in XRP, to use for account creation. This must be greater than + or equal to the ``MinAccountCreateAmount`` specified in the ``Bridge`` + ledger object. This field is required. + + :meta hide-value: + """ transaction_type: TransactionType = field( default=TransactionType.XCHAIN_ACCOUNT_CREATE_COMMIT, diff --git a/xrpl/models/transactions/xchain_add_account_create_attestation.py b/xrpl/models/transactions/xchain_add_account_create_attestation.py index 6c3196a77..28bede888 100644 --- a/xrpl/models/transactions/xchain_add_account_create_attestation.py +++ b/xrpl/models/transactions/xchain_add_account_create_attestation.py @@ -18,29 +18,99 @@ @require_kwargs_on_init @dataclass(frozen=True) class XChainAddAccountCreateAttestation(Transaction): - """Represents a XChainAddAccountCreateAttestation transaction.""" + """ + Represents a XChainAddAccountCreateAttestation transaction. + The XChainAddAccountCreateAttestation transaction provides an attestation + from a witness server that a XChainAccountCreateCommit transaction occurred + on the other chain. + """ xchain_bridge: XChainBridge = REQUIRED # type: ignore + """ + The bridge associated with the attestation. This field is required. + + :meta hide-value: + """ public_key: str = REQUIRED # type: ignore + """ + The public key used to verify the signature. This field is required. + + :meta hide-value: + """ signature: str = REQUIRED # type: ignore + """ + The signature attesting to the event on the other chain. This field is + required. + + :meta hide-value: + """ other_chain_source: str = REQUIRED # type: ignore + """ + The account on the source chain that submitted the + ``XChainAccountCreateCommit`` transaction that triggered the event + associated with the attestation. This field is required. + + :meta hide-value: + """ amount: Amount = REQUIRED # type: ignore + """ + The amount committed by the ``XChainAccountCreateCommit`` transaction on + the source chain. This field is required. + + :meta hide-value: + """ attestation_reward_account: str = REQUIRED # type: ignore + """ + The account that should receive this signer's share of the + ``SignatureReward``. This field is required. + + :meta hide-value: + """ 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. + + :meta hide-value: + """ was_locking_chain_send: Union[Literal[0], Literal[1]] = REQUIRED # type: ignore + """ + A boolean representing the chain where the event occurred. This field is + required. + + :meta hide-value: + """ xchain_account_create_count: str = REQUIRED # type: ignore + """ + The counter that represents the order that the claims must be processed in. + This field is required. + + :meta hide-value: + """ destination: str = REQUIRED # type: ignore + """ + The destination account for the funds on the destination chain. This field + is required. + + :meta hide-value: + """ signature_reward: Amount = REQUIRED # type: ignore + """ + The signature reward paid in the ``XChainAccountCreateCommit`` transaction. + This field is required. + + :meta hide-value: + """ transaction_type: TransactionType = field( default=TransactionType.XCHAIN_ADD_ACCOUNT_CREATE_ATTESTATION, diff --git a/xrpl/models/transactions/xchain_add_claim_attestation.py b/xrpl/models/transactions/xchain_add_claim_attestation.py index bb30700f6..be25d088b 100644 --- a/xrpl/models/transactions/xchain_add_claim_attestation.py +++ b/xrpl/models/transactions/xchain_add_claim_attestation.py @@ -18,27 +18,90 @@ @require_kwargs_on_init @dataclass(frozen=True) class XChainAddClaimAttestation(Transaction): - """Represents a XChainAddClaimAttestation transaction.""" + """ + Represents a XChainAddClaimAttestation transaction. + The ``XChainAddClaimAttestation`` transaction provides proof from a witness + server, attesting to an ``XChainCommit`` transaction. + """ xchain_bridge: XChainBridge = REQUIRED # type: ignore + """ + The bridge to use to transfer funds. This field is required. + + :meta hide-value: + """ public_key: str = REQUIRED # type: ignore + """ + The public key used to verify the signature. This field is required. + + :meta hide-value: + """ signature: str = REQUIRED # type: ignore + """ + The signature attesting to the event on the other chain. This field is + required. + + :meta hide-value: + """ other_chain_source: str = REQUIRED # type: ignore + """ + The account on the source chain that submitted the ``XChainCommit`` + transaction that triggered the event associated with the attestation. This + field is required. + + :meta hide-value: + """ amount: Amount = REQUIRED # type: ignore + """ + The amount committed by the ``XChainCommit`` transaction on the source + chain. This field is required. + + :meta hide-value: + """ attestation_reward_account: str = REQUIRED # type: ignore + """ + The account that should receive this signer's share of the + ``SignatureReward``. This field is required. + + :meta hide-value: + """ 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. + + :meta hide-value: + """ was_locking_chain_send: Union[Literal[0], Literal[1]] = REQUIRED # type: ignore + """ + A boolean representing the chain where the event occurred. This field is + required. + + :meta hide-value: + """ xchain_claim_id: str = REQUIRED # type: ignore + """ + The ``XChainClaimID`` associated with the transfer, which was included in + the ``XChainCommit`` transaction. This field is required. + + :meta hide-value: + """ destination: Optional[str] = None + """ + The destination account for the funds on the destination chain (taken from + the ``XChainCommit`` transaction). + + :meta hide-value: + """ transaction_type: TransactionType = field( default=TransactionType.XCHAIN_ADD_CLAIM_ATTESTATION, diff --git a/xrpl/models/transactions/xchain_claim.py b/xrpl/models/transactions/xchain_claim.py index ff8808a6d..4cbd5922d 100644 --- a/xrpl/models/transactions/xchain_claim.py +++ b/xrpl/models/transactions/xchain_claim.py @@ -17,17 +17,54 @@ @require_kwargs_on_init @dataclass(frozen=True) class XChainClaim(Transaction): - """Represents a XChainClaim transaction.""" + """ + Represents a XChainClaim transaction. + The ``XChainClaim`` transaction completes a cross-chain transfer of value. + It allows a user to claim the value on the destination chain - the + equivalent of the value locked on the source chain. + """ xchain_bridge: XChainBridge = REQUIRED # type: ignore + """ + The bridge to use for the transfer. This field is required. + + :meta hide-value: + """ xchain_claim_id: Union[int, str] = REQUIRED # type: ignore + """ + The unique integer ID for the cross-chain transfer that was referenced in + the corresponding ``XChainCommit`` transaction. This field is required. + + :meta hide-value: + """ destination: str = REQUIRED # type: ignore + """ + The destination account on the destination chain. It must exist or the + transaction will fail. However, if the transaction fails in this case, the + sequence number and collected signatures won't be destroyed, and the + transaction can be rerun with a different destination. This field is + required. + + :meta hide-value: + """ destination_tag: Optional[int] = None + """ + An integer destination tag. + + :meta hide-value: + """ amount: Amount = REQUIRED # type: ignore + """ + The amount to claim on the destination chain. This must match the amount + attested to on the attestations associated with this ``XChainClaimID``. + This field is required. + + :meta hide-value: + """ transaction_type: TransactionType = field( default=TransactionType.XCHAIN_CLAIM, diff --git a/xrpl/models/transactions/xchain_commit.py b/xrpl/models/transactions/xchain_commit.py index 7d23ca870..10e7f7696 100644 --- a/xrpl/models/transactions/xchain_commit.py +++ b/xrpl/models/transactions/xchain_commit.py @@ -14,15 +14,50 @@ @require_kwargs_on_init @dataclass(frozen=True) class XChainCommit(Transaction): - """Represents a XChainCommit transaction.""" + """ + Represents a XChainCommit transaction. + The `XChainCommit` transaction is the second step in a cross-chain + transfer. It puts assets into trust on the locking chain so that they can + be wrapped on the issuing chain, or burns wrapped assets on the issuing + chain so that they can be returned on the locking chain. + """ xchain_bridge: XChainBridge = REQUIRED # type: ignore + """ + The bridge to use to transfer funds. This field is required. + + :meta hide-value: + """ xchain_claim_id: Union[int, str] = REQUIRED # type: ignore + """ + The unique integer ID for a cross-chain transfer. This must be acquired on + the destination chain (via a ``XChainCreateClaimID`` transaction) and + checked from a validated ledger before submitting this transaction. If an + incorrect sequence number is specified, the funds will be lost. This field + is required. + + :meta hide-value: + """ amount: Amount = REQUIRED # type: ignore + """ + The asset to commit, and the quantity. This must match the door account's + ``LockingChainIssue`` (if on the locking chain) or the door account's + ``IssuingChainIssue`` (if on the issuing chain). This field is required. + + :meta hide-value: + """ other_chain_destination: Optional[str] = None + """ + The destination account on the destination chain. If this is not specified, + the account that submitted the ``XChainCreateClaimID`` transaction on the + destination chain will need to submit a ``XChainClaim`` transaction to + claim the funds. + + :meta hide-value: + """ transaction_type: TransactionType = field( default=TransactionType.XCHAIN_COMMIT, diff --git a/xrpl/models/transactions/xchain_create_bridge.py b/xrpl/models/transactions/xchain_create_bridge.py index c89d668d9..f8df908a9 100644 --- a/xrpl/models/transactions/xchain_create_bridge.py +++ b/xrpl/models/transactions/xchain_create_bridge.py @@ -16,13 +16,37 @@ @require_kwargs_on_init @dataclass(frozen=True) class XChainCreateBridge(Transaction): - """Represents a XChainCreateBridge transaction.""" + """ + Represents a XChainCreateBridge transaction. + The XChainCreateBridge transaction creates a new `Bridge` ledger object and + defines a new cross-chain bridge entrance on the chain that the transaction + is submitted on. It includes information about door accounts and assets for + the bridge. + """ xchain_bridge: XChainBridge = REQUIRED # type: ignore + """ + The bridge (door accounts and assets) to create. This field is required. + + :meta hide-value: + """ signature_reward: str = REQUIRED # type: ignore + """ + The total amount to pay the witness servers for their signatures. This + amount will be split among the signers. This field is required. + + :meta hide-value: + """ min_account_create_amount: Optional[str] = None + """ + The minimum amount, in XRP, required for a ``XChainAccountCreateCommit`` + transaction. If this isn't present, the ``XChainAccountCreateCommit`` + transaction will fail. This field can only be present on XRP-XRP bridges. + + :meta hide-value: + """ transaction_type: TransactionType = field( default=TransactionType.XCHAIN_CREATE_BRIDGE, diff --git a/xrpl/models/transactions/xchain_create_claim_id.py b/xrpl/models/transactions/xchain_create_claim_id.py index de9b8b329..724231a26 100644 --- a/xrpl/models/transactions/xchain_create_claim_id.py +++ b/xrpl/models/transactions/xchain_create_claim_id.py @@ -16,13 +16,36 @@ @require_kwargs_on_init @dataclass(frozen=True) class XChainCreateClaimID(Transaction): - """Represents a XChainCreateClaimID transaction.""" + """ + Represents a XChainCreateClaimID transaction. + The XChainCreateClaimID transaction creates a new cross-chain claim ID that + is used for a cross-chain transfer. A cross-chain claim ID represents one + cross-chain transfer of value. + """ xchain_bridge: XChainBridge = REQUIRED # type: ignore + """ + The bridge to create the claim ID for. This field is required. + + :meta hide-value: + """ signature_reward: str = REQUIRED # type: ignore + """ + The amount, in XRP, to reward the witness servers for providing signatures. + This must match the amount on the ``Bridge`` ledger object. This field is + required. + + :meta hide-value: + """ other_chain_source: str = REQUIRED # type: ignore + """ + The account that must send the corresponding ``XChainCommit`` transaction + on the source chain. This field is required. + + :meta hide-value: + """ transaction_type: TransactionType = field( default=TransactionType.XCHAIN_CREATE_CLAIM_ID, diff --git a/xrpl/models/transactions/xchain_modify_bridge.py b/xrpl/models/transactions/xchain_modify_bridge.py index ae8decc30..51b877a07 100644 --- a/xrpl/models/transactions/xchain_modify_bridge.py +++ b/xrpl/models/transactions/xchain_modify_bridge.py @@ -36,13 +36,35 @@ class XChainModifyBridgeFlagInterface(FlagInterface): @require_kwargs_on_init @dataclass(frozen=True) class XChainModifyBridge(Transaction): - """Represents a XChainModifyBridge transaction.""" + """ + Represents a XChainModifyBridge transaction. + The XChainModifyBridge transaction allows bridge managers to modify the + parameters of the bridge. + """ xchain_bridge: XChainBridge = REQUIRED # type: ignore + """ + The bridge to modify. This field is required. + + :meta hide-value: + """ signature_reward: Optional[str] = None + """ + The signature reward split between the witnesses for submitting + attestations. + + :meta hide-value: + """ min_account_create_amount: Optional[str] = None + """ + The minimum amount, in XRP, required for a ``XChainAccountCreateCommit`` + transaction. If this is not present, the ``XChainAccountCreateCommit`` + transaction will fail. This field can only be present on XRP-XRP bridges. + + :meta hide-value: + """ transaction_type: TransactionType = field( default=TransactionType.XCHAIN_MODIFY_BRIDGE, diff --git a/xrpl/models/xchain_bridge.py b/xrpl/models/xchain_bridge.py index fd1d158d9..2bf488ba6 100644 --- a/xrpl/models/xchain_bridge.py +++ b/xrpl/models/xchain_bridge.py @@ -15,6 +15,25 @@ class XChainBridge(BaseModel): """A XChainBridge represents a cross-chain bridge.""" locking_chain_door: str + """ + The door account on the locking chain. + """ + locking_chain_issue: Currency + """ + The asset that is locked and unlocked on the locking chain. + """ + issuing_chain_door: str + """ + The door account on the issuing chain. For an XRP-XRP bridge, this must be + the genesis account (the account that is created when the network is first + started, which contains all of the XRP). + """ + issuing_chain_issue: Currency + """ + The asset that is minted and burned on the issuing chain. For an IOU-IOU + bridge, the issuer of the asset must be the door account on the issuing + chain, to avoid supply issues. + """ From fe805221eb6fdc641a1864846326b1d8c9643a9b Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Fri, 7 Apr 2023 17:14:06 -0400 Subject: [PATCH 082/111] add bridge to account_objects filters --- xrpl/models/requests/account_objects.py | 1 + 1 file changed, 1 insertion(+) diff --git a/xrpl/models/requests/account_objects.py b/xrpl/models/requests/account_objects.py index 1d7b2e7c8..a7c53ad9c 100644 --- a/xrpl/models/requests/account_objects.py +++ b/xrpl/models/requests/account_objects.py @@ -18,6 +18,7 @@ class AccountObjectType(str, Enum): """Represents the object types that an AccountObjectsRequest can ask for.""" + BRIDGE = "bridge" CHECK = "check" DEPOSIT_PREAUTH = "deposit_preauth" ESCROW = "escrow" From 1c22a3b5b03faf832713339e1228207567c37d4f Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Fri, 28 Apr 2023 16:33:19 -0400 Subject: [PATCH 083/111] update account_objects filters --- xrpl/models/requests/account_objects.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xrpl/models/requests/account_objects.py b/xrpl/models/requests/account_objects.py index a7c53ad9c..39097a012 100644 --- a/xrpl/models/requests/account_objects.py +++ b/xrpl/models/requests/account_objects.py @@ -28,8 +28,8 @@ class AccountObjectType(str, Enum): SIGNER_LIST = "signer_list" STATE = "state" TICKET = "ticket" - XCHAIN_CREATE_ACCOUNT_CLAIM_ID = "xchain_create_account_claim_id" - XCHAIN_CLAIM_ID = "xchain_claim_id" + XCHAIN_OWNED_CREATE_ACCOUNT_CLAIM_ID = "xchain_owned_create_account_claim_id" + XCHAIN_OWNED_CLAIM_ID = "xchain_owned_claim_id" @require_kwargs_on_init From 433e9946832f0e66eddec831096001ac41578e74 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Mon, 1 May 2023 11:34:50 -0400 Subject: [PATCH 084/111] fix linter issues --- xrpl/core/binarycodec/types/xchain_bridge.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xrpl/core/binarycodec/types/xchain_bridge.py b/xrpl/core/binarycodec/types/xchain_bridge.py index 227b5d414..bfe312caf 100644 --- a/xrpl/core/binarycodec/types/xchain_bridge.py +++ b/xrpl/core/binarycodec/types/xchain_bridge.py @@ -44,7 +44,7 @@ def from_value( """ if isinstance(value, dict) and set(value.keys()) == _TYPE_KEYS: buffer = b"" - for (name, object_type) in _TYPE_ORDER: + for name, object_type in _TYPE_ORDER: obj = object_type.from_value(value[name]) if object_type == AccountID: buffer += bytes.fromhex("14") # AccountID length (I think) @@ -72,7 +72,7 @@ def from_parser( """ buffer = b"" - for (name, object_type) in _TYPE_ORDER: + for name, object_type in _TYPE_ORDER: if object_type == AccountID: parser.skip(1) buffer += bytes.fromhex("14") @@ -90,7 +90,7 @@ def to_json(self: XChainBridge) -> Union[str, Dict[Any, Any]]: """ parser = BinaryParser(str(self)) return_json = {} - for (name, object_type) in _TYPE_ORDER: + for name, object_type in _TYPE_ORDER: if object_type == AccountID: parser.skip(1) obj = object_type.from_parser(parser, None) From 9eb3441b4c23cbe8483991ea44b62ed4d63df8ef Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Wed, 3 May 2023 13:22:26 -0400 Subject: [PATCH 085/111] fix model validation --- xrpl/models/transactions/xchain_account_create_commit.py | 4 ++-- xrpl/models/transactions/xchain_create_bridge.py | 2 +- xrpl/models/transactions/xchain_create_claim_id.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/xrpl/models/transactions/xchain_account_create_commit.py b/xrpl/models/transactions/xchain_account_create_commit.py index 7c2fc5f20..53994a3a8 100644 --- a/xrpl/models/transactions/xchain_account_create_commit.py +++ b/xrpl/models/transactions/xchain_account_create_commit.py @@ -62,10 +62,10 @@ class XChainAccountCreateCommit(Transaction): def _get_errors(self: XChainAccountCreateCommit) -> Dict[str, str]: errors = super()._get_errors() - if self.signature_reward is not None and not self.signature_reward.isnumeric(): + if self.signature_reward != REQUIRED and not self.signature_reward.isnumeric(): errors["signature_reward"] = "`signature_reward` must be numeric." - if self.amount is not None and not self.amount.isnumeric(): + if self.amount != REQUIRED and not self.amount.isnumeric(): errors["amount"] = "`amount` must be numeric." return errors diff --git a/xrpl/models/transactions/xchain_create_bridge.py b/xrpl/models/transactions/xchain_create_bridge.py index f8df908a9..6b1fa506e 100644 --- a/xrpl/models/transactions/xchain_create_bridge.py +++ b/xrpl/models/transactions/xchain_create_bridge.py @@ -81,7 +81,7 @@ def _get_errors(self: XChainCreateBridge) -> Dict[str, str]: "min_account_create_amount" ] = "Cannot have MinAccountCreateAmount if bridge is IOU-IOU." - if self.signature_reward is not None and not self.signature_reward.isnumeric(): + if self.signature_reward != REQUIRED and not self.signature_reward.isnumeric(): errors["signature_reward"] = "signature_reward must be numeric." if ( diff --git a/xrpl/models/transactions/xchain_create_claim_id.py b/xrpl/models/transactions/xchain_create_claim_id.py index 724231a26..02b31507a 100644 --- a/xrpl/models/transactions/xchain_create_claim_id.py +++ b/xrpl/models/transactions/xchain_create_claim_id.py @@ -55,10 +55,10 @@ class XChainCreateClaimID(Transaction): def _get_errors(self: XChainCreateClaimID) -> Dict[str, str]: errors = super()._get_errors() - if self.signature_reward is not None and not self.signature_reward.isnumeric(): + if self.signature_reward != REQUIRED and not self.signature_reward.isnumeric(): errors["signature_reward"] = "`signature_reward` must be numeric." - if self.other_chain_source is not None and not is_valid_classic_address( + if self.other_chain_source != REQUIRED and not is_valid_classic_address( self.other_chain_source ): errors[ From 3e5159669b141b65816907ec24d96a2dd65cfce7 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Wed, 3 May 2023 15:00:28 -0400 Subject: [PATCH 086/111] improve types --- .../transactions/xchain_add_account_create_attestation.py | 2 +- xrpl/models/transactions/xchain_add_claim_attestation.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/xrpl/models/transactions/xchain_add_account_create_attestation.py b/xrpl/models/transactions/xchain_add_account_create_attestation.py index 28bede888..8b9f78bc4 100644 --- a/xrpl/models/transactions/xchain_add_account_create_attestation.py +++ b/xrpl/models/transactions/xchain_add_account_create_attestation.py @@ -88,7 +88,7 @@ class XChainAddAccountCreateAttestation(Transaction): :meta hide-value: """ - xchain_account_create_count: str = REQUIRED # type: ignore + xchain_account_create_count: Union[str, int] = REQUIRED # type: ignore """ The counter that represents the order that the claims must be processed in. This field is required. diff --git a/xrpl/models/transactions/xchain_add_claim_attestation.py b/xrpl/models/transactions/xchain_add_claim_attestation.py index be25d088b..c54dfa18f 100644 --- a/xrpl/models/transactions/xchain_add_claim_attestation.py +++ b/xrpl/models/transactions/xchain_add_claim_attestation.py @@ -87,7 +87,7 @@ class XChainAddClaimAttestation(Transaction): :meta hide-value: """ - xchain_claim_id: str = REQUIRED # type: ignore + xchain_claim_id: Union[str, int] = REQUIRED # type: ignore """ The ``XChainClaimID`` associated with the transfer, which was included in the ``XChainCommit`` transaction. This field is required. From 21bea2a8b1dba0d5f0a5b33b0297a5085ba6c289 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Jun 2023 14:52:46 -0500 Subject: [PATCH 087/111] chore(deps-dev): bump coverage from 7.2.5 to 7.2.7 (#587) Bumps [coverage](https://github.com/nedbat/coveragepy) from 7.2.5 to 7.2.7. - [Release notes](https://github.com/nedbat/coveragepy/releases) - [Changelog](https://github.com/nedbat/coveragepy/blob/master/CHANGES.rst) - [Commits](https://github.com/nedbat/coveragepy/compare/7.2.5...7.2.7) --- updated-dependencies: - dependency-name: coverage dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- poetry.lock | 115 ++++++++++++++++++++++++++----------------------- pyproject.toml | 2 +- 2 files changed, 63 insertions(+), 54 deletions(-) diff --git a/poetry.lock b/poetry.lock index 30d2f60e4..43da50317 100644 --- a/poetry.lock +++ b/poetry.lock @@ -187,63 +187,72 @@ files = [ [[package]] name = "coverage" -version = "7.2.5" +version = "7.2.7" description = "Code coverage measurement for Python" category = "dev" optional = false python-versions = ">=3.7" files = [ - {file = "coverage-7.2.5-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:883123d0bbe1c136f76b56276074b0c79b5817dd4238097ffa64ac67257f4b6c"}, - {file = "coverage-7.2.5-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:d2fbc2a127e857d2f8898aaabcc34c37771bf78a4d5e17d3e1f5c30cd0cbc62a"}, - {file = "coverage-7.2.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5f3671662dc4b422b15776cdca89c041a6349b4864a43aa2350b6b0b03bbcc7f"}, - {file = "coverage-7.2.5-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:780551e47d62095e088f251f5db428473c26db7829884323e56d9c0c3118791a"}, - {file = "coverage-7.2.5-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:066b44897c493e0dcbc9e6a6d9f8bbb6607ef82367cf6810d387c09f0cd4fe9a"}, - {file = "coverage-7.2.5-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:b9a4ee55174b04f6af539218f9f8083140f61a46eabcaa4234f3c2a452c4ed11"}, - {file = "coverage-7.2.5-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:706ec567267c96717ab9363904d846ec009a48d5f832140b6ad08aad3791b1f5"}, - {file = "coverage-7.2.5-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:ae453f655640157d76209f42c62c64c4d4f2c7f97256d3567e3b439bd5c9b06c"}, - {file = "coverage-7.2.5-cp310-cp310-win32.whl", hash = "sha256:f81c9b4bd8aa747d417407a7f6f0b1469a43b36a85748145e144ac4e8d303cb5"}, - {file = "coverage-7.2.5-cp310-cp310-win_amd64.whl", hash = "sha256:dc945064a8783b86fcce9a0a705abd7db2117d95e340df8a4333f00be5efb64c"}, - {file = "coverage-7.2.5-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:40cc0f91c6cde033da493227797be2826cbf8f388eaa36a0271a97a332bfd7ce"}, - {file = "coverage-7.2.5-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:a66e055254a26c82aead7ff420d9fa8dc2da10c82679ea850d8feebf11074d88"}, - {file = "coverage-7.2.5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c10fbc8a64aa0f3ed136b0b086b6b577bc64d67d5581acd7cc129af52654384e"}, - {file = "coverage-7.2.5-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:9a22cbb5ede6fade0482111fa7f01115ff04039795d7092ed0db43522431b4f2"}, - {file = "coverage-7.2.5-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:292300f76440651529b8ceec283a9370532f4ecba9ad67d120617021bb5ef139"}, - {file = "coverage-7.2.5-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:7ff8f3fb38233035028dbc93715551d81eadc110199e14bbbfa01c5c4a43f8d8"}, - {file = "coverage-7.2.5-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:a08c7401d0b24e8c2982f4e307124b671c6736d40d1c39e09d7a8687bddf83ed"}, - {file = "coverage-7.2.5-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:ef9659d1cda9ce9ac9585c045aaa1e59223b143f2407db0eaee0b61a4f266fb6"}, - {file = "coverage-7.2.5-cp311-cp311-win32.whl", hash = "sha256:30dcaf05adfa69c2a7b9f7dfd9f60bc8e36b282d7ed25c308ef9e114de7fc23b"}, - {file = "coverage-7.2.5-cp311-cp311-win_amd64.whl", hash = "sha256:97072cc90f1009386c8a5b7de9d4fc1a9f91ba5ef2146c55c1f005e7b5c5e068"}, - {file = "coverage-7.2.5-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:bebea5f5ed41f618797ce3ffb4606c64a5de92e9c3f26d26c2e0aae292f015c1"}, - {file = "coverage-7.2.5-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:828189fcdda99aae0d6bf718ea766b2e715eabc1868670a0a07bf8404bf58c33"}, - {file = "coverage-7.2.5-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6e8a95f243d01ba572341c52f89f3acb98a3b6d1d5d830efba86033dd3687ade"}, - {file = "coverage-7.2.5-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e8834e5f17d89e05697c3c043d3e58a8b19682bf365048837383abfe39adaed5"}, - {file = "coverage-7.2.5-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:d1f25ee9de21a39b3a8516f2c5feb8de248f17da7eead089c2e04aa097936b47"}, - {file = "coverage-7.2.5-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:1637253b11a18f453e34013c665d8bf15904c9e3c44fbda34c643fbdc9d452cd"}, - {file = "coverage-7.2.5-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:8e575a59315a91ccd00c7757127f6b2488c2f914096077c745c2f1ba5b8c0969"}, - {file = "coverage-7.2.5-cp37-cp37m-win32.whl", hash = "sha256:509ecd8334c380000d259dc66feb191dd0a93b21f2453faa75f7f9cdcefc0718"}, - {file = "coverage-7.2.5-cp37-cp37m-win_amd64.whl", hash = "sha256:12580845917b1e59f8a1c2ffa6af6d0908cb39220f3019e36c110c943dc875b0"}, - {file = "coverage-7.2.5-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:b5016e331b75310610c2cf955d9f58a9749943ed5f7b8cfc0bb89c6134ab0a84"}, - {file = "coverage-7.2.5-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:373ea34dca98f2fdb3e5cb33d83b6d801007a8074f992b80311fc589d3e6b790"}, - {file = "coverage-7.2.5-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a063aad9f7b4c9f9da7b2550eae0a582ffc7623dca1c925e50c3fbde7a579771"}, - {file = "coverage-7.2.5-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:38c0a497a000d50491055805313ed83ddba069353d102ece8aef5d11b5faf045"}, - {file = "coverage-7.2.5-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a2b3b05e22a77bb0ae1a3125126a4e08535961c946b62f30985535ed40e26614"}, - {file = "coverage-7.2.5-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:0342a28617e63ad15d96dca0f7ae9479a37b7d8a295f749c14f3436ea59fdcb3"}, - {file = "coverage-7.2.5-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:cf97ed82ca986e5c637ea286ba2793c85325b30f869bf64d3009ccc1a31ae3fd"}, - {file = "coverage-7.2.5-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:c2c41c1b1866b670573657d584de413df701f482574bad7e28214a2362cb1fd1"}, - {file = "coverage-7.2.5-cp38-cp38-win32.whl", hash = "sha256:10b15394c13544fce02382360cab54e51a9e0fd1bd61ae9ce012c0d1e103c813"}, - {file = "coverage-7.2.5-cp38-cp38-win_amd64.whl", hash = "sha256:a0b273fe6dc655b110e8dc89b8ec7f1a778d78c9fd9b4bda7c384c8906072212"}, - {file = "coverage-7.2.5-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:5c587f52c81211d4530fa6857884d37f514bcf9453bdeee0ff93eaaf906a5c1b"}, - {file = "coverage-7.2.5-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:4436cc9ba5414c2c998eaedee5343f49c02ca93b21769c5fdfa4f9d799e84200"}, - {file = "coverage-7.2.5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6599bf92f33ab041e36e06d25890afbdf12078aacfe1f1d08c713906e49a3fe5"}, - {file = "coverage-7.2.5-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:857abe2fa6a4973f8663e039ead8d22215d31db613ace76e4a98f52ec919068e"}, - {file = "coverage-7.2.5-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f6f5cab2d7f0c12f8187a376cc6582c477d2df91d63f75341307fcdcb5d60303"}, - {file = "coverage-7.2.5-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:aa387bd7489f3e1787ff82068b295bcaafbf6f79c3dad3cbc82ef88ce3f48ad3"}, - {file = "coverage-7.2.5-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:156192e5fd3dbbcb11cd777cc469cf010a294f4c736a2b2c891c77618cb1379a"}, - {file = "coverage-7.2.5-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:bd3b4b8175c1db502adf209d06136c000df4d245105c8839e9d0be71c94aefe1"}, - {file = "coverage-7.2.5-cp39-cp39-win32.whl", hash = "sha256:ddc5a54edb653e9e215f75de377354e2455376f416c4378e1d43b08ec50acc31"}, - {file = "coverage-7.2.5-cp39-cp39-win_amd64.whl", hash = "sha256:338aa9d9883aaaad53695cb14ccdeb36d4060485bb9388446330bef9c361c252"}, - {file = "coverage-7.2.5-pp37.pp38.pp39-none-any.whl", hash = "sha256:8877d9b437b35a85c18e3c6499b23674684bf690f5d96c1006a1ef61f9fdf0f3"}, - {file = "coverage-7.2.5.tar.gz", hash = "sha256:f99ef080288f09ffc687423b8d60978cf3a465d3f404a18d1a05474bd8575a47"}, + {file = "coverage-7.2.7-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d39b5b4f2a66ccae8b7263ac3c8170994b65266797fb96cbbfd3fb5b23921db8"}, + {file = "coverage-7.2.7-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:6d040ef7c9859bb11dfeb056ff5b3872436e3b5e401817d87a31e1750b9ae2fb"}, + {file = "coverage-7.2.7-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ba90a9563ba44a72fda2e85302c3abc71c5589cea608ca16c22b9804262aaeb6"}, + {file = "coverage-7.2.7-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e7d9405291c6928619403db1d10bd07888888ec1abcbd9748fdaa971d7d661b2"}, + {file = "coverage-7.2.7-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:31563e97dae5598556600466ad9beea39fb04e0229e61c12eaa206e0aa202063"}, + {file = "coverage-7.2.7-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:ebba1cd308ef115925421d3e6a586e655ca5a77b5bf41e02eb0e4562a111f2d1"}, + {file = "coverage-7.2.7-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:cb017fd1b2603ef59e374ba2063f593abe0fc45f2ad9abdde5b4d83bd922a353"}, + {file = "coverage-7.2.7-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:d62a5c7dad11015c66fbb9d881bc4caa5b12f16292f857842d9d1871595f4495"}, + {file = "coverage-7.2.7-cp310-cp310-win32.whl", hash = "sha256:ee57190f24fba796e36bb6d3aa8a8783c643d8fa9760c89f7a98ab5455fbf818"}, + {file = "coverage-7.2.7-cp310-cp310-win_amd64.whl", hash = "sha256:f75f7168ab25dd93110c8a8117a22450c19976afbc44234cbf71481094c1b850"}, + {file = "coverage-7.2.7-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:06a9a2be0b5b576c3f18f1a241f0473575c4a26021b52b2a85263a00f034d51f"}, + {file = "coverage-7.2.7-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:5baa06420f837184130752b7c5ea0808762083bf3487b5038d68b012e5937dbe"}, + {file = "coverage-7.2.7-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:fdec9e8cbf13a5bf63290fc6013d216a4c7232efb51548594ca3631a7f13c3a3"}, + {file = "coverage-7.2.7-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:52edc1a60c0d34afa421c9c37078817b2e67a392cab17d97283b64c5833f427f"}, + {file = "coverage-7.2.7-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:63426706118b7f5cf6bb6c895dc215d8a418d5952544042c8a2d9fe87fcf09cb"}, + {file = "coverage-7.2.7-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:afb17f84d56068a7c29f5fa37bfd38d5aba69e3304af08ee94da8ed5b0865833"}, + {file = "coverage-7.2.7-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:48c19d2159d433ccc99e729ceae7d5293fbffa0bdb94952d3579983d1c8c9d97"}, + {file = "coverage-7.2.7-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:0e1f928eaf5469c11e886fe0885ad2bf1ec606434e79842a879277895a50942a"}, + {file = "coverage-7.2.7-cp311-cp311-win32.whl", hash = "sha256:33d6d3ea29d5b3a1a632b3c4e4f4ecae24ef170b0b9ee493883f2df10039959a"}, + {file = "coverage-7.2.7-cp311-cp311-win_amd64.whl", hash = "sha256:5b7540161790b2f28143191f5f8ec02fb132660ff175b7747b95dcb77ac26562"}, + {file = "coverage-7.2.7-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:f2f67fe12b22cd130d34d0ef79206061bfb5eda52feb6ce0dba0644e20a03cf4"}, + {file = "coverage-7.2.7-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a342242fe22407f3c17f4b499276a02b01e80f861f1682ad1d95b04018e0c0d4"}, + {file = "coverage-7.2.7-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:171717c7cb6b453aebac9a2ef603699da237f341b38eebfee9be75d27dc38e01"}, + {file = "coverage-7.2.7-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:49969a9f7ffa086d973d91cec8d2e31080436ef0fb4a359cae927e742abfaaa6"}, + {file = "coverage-7.2.7-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:b46517c02ccd08092f4fa99f24c3b83d8f92f739b4657b0f146246a0ca6a831d"}, + {file = "coverage-7.2.7-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:a3d33a6b3eae87ceaefa91ffdc130b5e8536182cd6dfdbfc1aa56b46ff8c86de"}, + {file = "coverage-7.2.7-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:976b9c42fb2a43ebf304fa7d4a310e5f16cc99992f33eced91ef6f908bd8f33d"}, + {file = "coverage-7.2.7-cp312-cp312-win32.whl", hash = "sha256:8de8bb0e5ad103888d65abef8bca41ab93721647590a3f740100cd65c3b00511"}, + {file = "coverage-7.2.7-cp312-cp312-win_amd64.whl", hash = "sha256:9e31cb64d7de6b6f09702bb27c02d1904b3aebfca610c12772452c4e6c21a0d3"}, + {file = "coverage-7.2.7-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:58c2ccc2f00ecb51253cbe5d8d7122a34590fac9646a960d1430d5b15321d95f"}, + {file = "coverage-7.2.7-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d22656368f0e6189e24722214ed8d66b8022db19d182927b9a248a2a8a2f67eb"}, + {file = "coverage-7.2.7-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a895fcc7b15c3fc72beb43cdcbdf0ddb7d2ebc959edac9cef390b0d14f39f8a9"}, + {file = "coverage-7.2.7-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e84606b74eb7de6ff581a7915e2dab7a28a0517fbe1c9239eb227e1354064dcd"}, + {file = "coverage-7.2.7-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:0a5f9e1dbd7fbe30196578ca36f3fba75376fb99888c395c5880b355e2875f8a"}, + {file = "coverage-7.2.7-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:419bfd2caae268623dd469eff96d510a920c90928b60f2073d79f8fe2bbc5959"}, + {file = "coverage-7.2.7-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:2aee274c46590717f38ae5e4650988d1af340fe06167546cc32fe2f58ed05b02"}, + {file = "coverage-7.2.7-cp37-cp37m-win32.whl", hash = "sha256:61b9a528fb348373c433e8966535074b802c7a5d7f23c4f421e6c6e2f1697a6f"}, + {file = "coverage-7.2.7-cp37-cp37m-win_amd64.whl", hash = "sha256:b1c546aca0ca4d028901d825015dc8e4d56aac4b541877690eb76490f1dc8ed0"}, + {file = "coverage-7.2.7-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:54b896376ab563bd38453cecb813c295cf347cf5906e8b41d340b0321a5433e5"}, + {file = "coverage-7.2.7-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:3d376df58cc111dc8e21e3b6e24606b5bb5dee6024f46a5abca99124b2229ef5"}, + {file = "coverage-7.2.7-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5e330fc79bd7207e46c7d7fd2bb4af2963f5f635703925543a70b99574b0fea9"}, + {file = "coverage-7.2.7-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1e9d683426464e4a252bf70c3498756055016f99ddaec3774bf368e76bbe02b6"}, + {file = "coverage-7.2.7-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8d13c64ee2d33eccf7437961b6ea7ad8673e2be040b4f7fd4fd4d4d28d9ccb1e"}, + {file = "coverage-7.2.7-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:b7aa5f8a41217360e600da646004f878250a0d6738bcdc11a0a39928d7dc2050"}, + {file = "coverage-7.2.7-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:8fa03bce9bfbeeef9f3b160a8bed39a221d82308b4152b27d82d8daa7041fee5"}, + {file = "coverage-7.2.7-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:245167dd26180ab4c91d5e1496a30be4cd721a5cf2abf52974f965f10f11419f"}, + {file = "coverage-7.2.7-cp38-cp38-win32.whl", hash = "sha256:d2c2db7fd82e9b72937969bceac4d6ca89660db0a0967614ce2481e81a0b771e"}, + {file = "coverage-7.2.7-cp38-cp38-win_amd64.whl", hash = "sha256:2e07b54284e381531c87f785f613b833569c14ecacdcb85d56b25c4622c16c3c"}, + {file = "coverage-7.2.7-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:537891ae8ce59ef63d0123f7ac9e2ae0fc8b72c7ccbe5296fec45fd68967b6c9"}, + {file = "coverage-7.2.7-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:06fb182e69f33f6cd1d39a6c597294cff3143554b64b9825d1dc69d18cc2fff2"}, + {file = "coverage-7.2.7-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:201e7389591af40950a6480bd9edfa8ed04346ff80002cec1a66cac4549c1ad7"}, + {file = "coverage-7.2.7-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f6951407391b639504e3b3be51b7ba5f3528adbf1a8ac3302b687ecababf929e"}, + {file = "coverage-7.2.7-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6f48351d66575f535669306aa7d6d6f71bc43372473b54a832222803eb956fd1"}, + {file = "coverage-7.2.7-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:b29019c76039dc3c0fd815c41392a044ce555d9bcdd38b0fb60fb4cd8e475ba9"}, + {file = "coverage-7.2.7-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:81c13a1fc7468c40f13420732805a4c38a105d89848b7c10af65a90beff25250"}, + {file = "coverage-7.2.7-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:975d70ab7e3c80a3fe86001d8751f6778905ec723f5b110aed1e450da9d4b7f2"}, + {file = "coverage-7.2.7-cp39-cp39-win32.whl", hash = "sha256:7ee7d9d4822c8acc74a5e26c50604dff824710bc8de424904c0982e25c39c6cb"}, + {file = "coverage-7.2.7-cp39-cp39-win_amd64.whl", hash = "sha256:eb393e5ebc85245347950143969b241d08b52b88a3dc39479822e073a1a8eb27"}, + {file = "coverage-7.2.7-pp37.pp38.pp39-none-any.whl", hash = "sha256:b7b4c971f05e6ae490fef852c218b0e79d4e52f79ef0c8475566584a8fb3e01d"}, + {file = "coverage-7.2.7.tar.gz", hash = "sha256:924d94291ca674905fe9481f12294eb11f2d3d3fd1adb20314ba89e94f44ed59"}, ] [package.extras] @@ -1307,4 +1316,4 @@ testing = ["func-timeout", "jaraco.itertools", "pytest (>=6)", "pytest-black (>= [metadata] lock-version = "2.0" python-versions = "^3.7" -content-hash = "88edc35f6ee0fa4506441ffd4ce2313dc24271b07b35f3387fa176c0bc23bae5" +content-hash = "33b43c15dd242127f1d181779293e93446259ec4a0bd00431b4214e20715fa09" diff --git a/pyproject.toml b/pyproject.toml index 04368cf07..adabb2cca 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -56,7 +56,7 @@ flake8-absolute-import = "^1.0" darglint = "^1.5.8" sphinx-rtd-theme = "^1.2.0" aiounittest = "^1.4.0" -coverage = "^7.2.5" +coverage = "^7.2.7" Jinja2 = "^3.1.2" MarkupSafe = "2.1.2" Sphinx = "^5.3.0" From a6f0ae1b296366081365556d8bd1b20b5e52e31b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Jun 2023 15:31:10 -0500 Subject: [PATCH 088/111] chore(deps): bump typing-extensions from 4.5.0 to 4.6.2 (#588) Bumps [typing-extensions](https://github.com/python/typing_extensions) from 4.5.0 to 4.6.2. - [Changelog](https://github.com/python/typing_extensions/blob/main/CHANGELOG.md) - [Commits](https://github.com/python/typing_extensions/compare/4.5.0...4.6.2) --- updated-dependencies: - dependency-name: typing-extensions dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- poetry.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/poetry.lock b/poetry.lock index 43da50317..b83af7a33 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1138,14 +1138,14 @@ files = [ [[package]] name = "typing-extensions" -version = "4.5.0" +version = "4.6.2" description = "Backported and Experimental Type Hints for Python 3.7+" category = "main" optional = false python-versions = ">=3.7" files = [ - {file = "typing_extensions-4.5.0-py3-none-any.whl", hash = "sha256:fb33085c39dd998ac16d1431ebc293a8b3eedd00fd4a32de0ff79002c19511b4"}, - {file = "typing_extensions-4.5.0.tar.gz", hash = "sha256:5cb5f4a79139d699607b3ef622a1dedafa84e115ab0024e0d9c044a9479ca7cb"}, + {file = "typing_extensions-4.6.2-py3-none-any.whl", hash = "sha256:3a8b36f13dd5fdc5d1b16fe317f5668545de77fa0b8e02006381fd49d731ab98"}, + {file = "typing_extensions-4.6.2.tar.gz", hash = "sha256:06006244c70ac8ee83fa8282cb188f697b8db25bc8b4df07be1873c43897060c"}, ] [[package]] From 3675658c0c3e3b277c8573e29724941e14351a9c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Jun 2023 16:47:14 -0700 Subject: [PATCH 089/111] chore(deps-dev): bump mypy from 1.2.0 to 1.3.0 (#586) Bumps [mypy](https://github.com/python/mypy) from 1.2.0 to 1.3.0. - [Commits](https://github.com/python/mypy/compare/v1.2.0...v1.3.0) --- updated-dependencies: - dependency-name: mypy dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: justinr1234 --- poetry.lock | 54 ++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/poetry.lock b/poetry.lock index b83af7a33..af6c6446d 100644 --- a/poetry.lock +++ b/poetry.lock @@ -628,38 +628,38 @@ files = [ [[package]] name = "mypy" -version = "1.2.0" +version = "1.3.0" description = "Optional static typing for Python" category = "dev" optional = false python-versions = ">=3.7" files = [ - {file = "mypy-1.2.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:701189408b460a2ff42b984e6bd45c3f41f0ac9f5f58b8873bbedc511900086d"}, - {file = "mypy-1.2.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:fe91be1c51c90e2afe6827601ca14353bbf3953f343c2129fa1e247d55fd95ba"}, - {file = "mypy-1.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8d26b513225ffd3eacece727f4387bdce6469192ef029ca9dd469940158bc89e"}, - {file = "mypy-1.2.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:3a2d219775a120581a0ae8ca392b31f238d452729adbcb6892fa89688cb8306a"}, - {file = "mypy-1.2.0-cp310-cp310-win_amd64.whl", hash = "sha256:2e93a8a553e0394b26c4ca683923b85a69f7ccdc0139e6acd1354cc884fe0128"}, - {file = "mypy-1.2.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:3efde4af6f2d3ccf58ae825495dbb8d74abd6d176ee686ce2ab19bd025273f41"}, - {file = "mypy-1.2.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:695c45cea7e8abb6f088a34a6034b1d273122e5530aeebb9c09626cea6dca4cb"}, - {file = "mypy-1.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d0e9464a0af6715852267bf29c9553e4555b61f5904a4fc538547a4d67617937"}, - {file = "mypy-1.2.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:8293a216e902ac12779eb7a08f2bc39ec6c878d7c6025aa59464e0c4c16f7eb9"}, - {file = "mypy-1.2.0-cp311-cp311-win_amd64.whl", hash = "sha256:f46af8d162f3d470d8ffc997aaf7a269996d205f9d746124a179d3abe05ac602"}, - {file = "mypy-1.2.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:031fc69c9a7e12bcc5660b74122ed84b3f1c505e762cc4296884096c6d8ee140"}, - {file = "mypy-1.2.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:390bc685ec209ada4e9d35068ac6988c60160b2b703072d2850457b62499e336"}, - {file = "mypy-1.2.0-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:4b41412df69ec06ab141808d12e0bf2823717b1c363bd77b4c0820feaa37249e"}, - {file = "mypy-1.2.0-cp37-cp37m-win_amd64.whl", hash = "sha256:4e4a682b3f2489d218751981639cffc4e281d548f9d517addfd5a2917ac78119"}, - {file = "mypy-1.2.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:a197ad3a774f8e74f21e428f0de7f60ad26a8d23437b69638aac2764d1e06a6a"}, - {file = "mypy-1.2.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:c9a084bce1061e55cdc0493a2ad890375af359c766b8ac311ac8120d3a472950"}, - {file = "mypy-1.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:eaeaa0888b7f3ccb7bcd40b50497ca30923dba14f385bde4af78fac713d6d6f6"}, - {file = "mypy-1.2.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:bea55fc25b96c53affab852ad94bf111a3083bc1d8b0c76a61dd101d8a388cf5"}, - {file = "mypy-1.2.0-cp38-cp38-win_amd64.whl", hash = "sha256:4c8d8c6b80aa4a1689f2a179d31d86ae1367ea4a12855cc13aa3ba24bb36b2d8"}, - {file = "mypy-1.2.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:70894c5345bea98321a2fe84df35f43ee7bb0feec117a71420c60459fc3e1eed"}, - {file = "mypy-1.2.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:4a99fe1768925e4a139aace8f3fb66db3576ee1c30b9c0f70f744ead7e329c9f"}, - {file = "mypy-1.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:023fe9e618182ca6317ae89833ba422c411469156b690fde6a315ad10695a521"}, - {file = "mypy-1.2.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:4d19f1a239d59f10fdc31263d48b7937c585810288376671eaf75380b074f238"}, - {file = "mypy-1.2.0-cp39-cp39-win_amd64.whl", hash = "sha256:2de7babe398cb7a85ac7f1fd5c42f396c215ab3eff731b4d761d68d0f6a80f48"}, - {file = "mypy-1.2.0-py3-none-any.whl", hash = "sha256:d8e9187bfcd5ffedbe87403195e1fc340189a68463903c39e2b63307c9fa0394"}, - {file = "mypy-1.2.0.tar.gz", hash = "sha256:f70a40410d774ae23fcb4afbbeca652905a04de7948eaf0b1789c8d1426b72d1"}, + {file = "mypy-1.3.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:c1eb485cea53f4f5284e5baf92902cd0088b24984f4209e25981cc359d64448d"}, + {file = "mypy-1.3.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:4c99c3ecf223cf2952638da9cd82793d8f3c0c5fa8b6ae2b2d9ed1e1ff51ba85"}, + {file = "mypy-1.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:550a8b3a19bb6589679a7c3c31f64312e7ff482a816c96e0cecec9ad3a7564dd"}, + {file = "mypy-1.3.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:cbc07246253b9e3d7d74c9ff948cd0fd7a71afcc2b77c7f0a59c26e9395cb152"}, + {file = "mypy-1.3.0-cp310-cp310-win_amd64.whl", hash = "sha256:a22435632710a4fcf8acf86cbd0d69f68ac389a3892cb23fbad176d1cddaf228"}, + {file = "mypy-1.3.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:6e33bb8b2613614a33dff70565f4c803f889ebd2f859466e42b46e1df76018dd"}, + {file = "mypy-1.3.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:7d23370d2a6b7a71dc65d1266f9a34e4cde9e8e21511322415db4b26f46f6b8c"}, + {file = "mypy-1.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:658fe7b674769a0770d4b26cb4d6f005e88a442fe82446f020be8e5f5efb2fae"}, + {file = "mypy-1.3.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:6e42d29e324cdda61daaec2336c42512e59c7c375340bd202efa1fe0f7b8f8ca"}, + {file = "mypy-1.3.0-cp311-cp311-win_amd64.whl", hash = "sha256:d0b6c62206e04061e27009481cb0ec966f7d6172b5b936f3ead3d74f29fe3dcf"}, + {file = "mypy-1.3.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:76ec771e2342f1b558c36d49900dfe81d140361dd0d2df6cd71b3db1be155409"}, + {file = "mypy-1.3.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ebc95f8386314272bbc817026f8ce8f4f0d2ef7ae44f947c4664efac9adec929"}, + {file = "mypy-1.3.0-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:faff86aa10c1aa4a10e1a301de160f3d8fc8703b88c7e98de46b531ff1276a9a"}, + {file = "mypy-1.3.0-cp37-cp37m-win_amd64.whl", hash = "sha256:8c5979d0deb27e0f4479bee18ea0f83732a893e81b78e62e2dda3e7e518c92ee"}, + {file = "mypy-1.3.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:c5d2cc54175bab47011b09688b418db71403aefad07cbcd62d44010543fc143f"}, + {file = "mypy-1.3.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:87df44954c31d86df96c8bd6e80dfcd773473e877ac6176a8e29898bfb3501cb"}, + {file = "mypy-1.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:473117e310febe632ddf10e745a355714e771ffe534f06db40702775056614c4"}, + {file = "mypy-1.3.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:74bc9b6e0e79808bf8678d7678b2ae3736ea72d56eede3820bd3849823e7f305"}, + {file = "mypy-1.3.0-cp38-cp38-win_amd64.whl", hash = "sha256:44797d031a41516fcf5cbfa652265bb994e53e51994c1bd649ffcd0c3a7eccbf"}, + {file = "mypy-1.3.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:ddae0f39ca146972ff6bb4399f3b2943884a774b8771ea0a8f50e971f5ea5ba8"}, + {file = "mypy-1.3.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:1c4c42c60a8103ead4c1c060ac3cdd3ff01e18fddce6f1016e08939647a0e703"}, + {file = "mypy-1.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e86c2c6852f62f8f2b24cb7a613ebe8e0c7dc1402c61d36a609174f63e0ff017"}, + {file = "mypy-1.3.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:f9dca1e257d4cc129517779226753dbefb4f2266c4eaad610fc15c6a7e14283e"}, + {file = "mypy-1.3.0-cp39-cp39-win_amd64.whl", hash = "sha256:95d8d31a7713510685b05fbb18d6ac287a56c8f6554d88c19e73f724a445448a"}, + {file = "mypy-1.3.0-py3-none-any.whl", hash = "sha256:a8763e72d5d9574d45ce5881962bc8e9046bf7b375b0abf031f3e6811732a897"}, + {file = "mypy-1.3.0.tar.gz", hash = "sha256:e1f4d16e296f5135624b34e8fb741eb0eadedca90862405b1f1fde2040b9bd11"}, ] [package.dependencies] From 465015bc63ceafb9e2f0021e109299a1223b502c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Jun 2023 19:04:15 -0500 Subject: [PATCH 090/111] chore(deps): bump httpx from 0.24.0 to 0.24.1 (#584) Bumps [httpx](https://github.com/encode/httpx) from 0.24.0 to 0.24.1. - [Release notes](https://github.com/encode/httpx/releases) - [Changelog](https://github.com/encode/httpx/blob/master/CHANGELOG.md) - [Commits](https://github.com/encode/httpx/compare/0.24.0...0.24.1) --- updated-dependencies: - dependency-name: httpx dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: jonathanlei --- poetry.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/poetry.lock b/poetry.lock index af6c6446d..2bfbc9a4e 100644 --- a/poetry.lock +++ b/poetry.lock @@ -451,14 +451,14 @@ socks = ["socksio (>=1.0.0,<2.0.0)"] [[package]] name = "httpx" -version = "0.24.0" +version = "0.24.1" description = "The next generation HTTP client." category = "main" optional = false python-versions = ">=3.7" files = [ - {file = "httpx-0.24.0-py3-none-any.whl", hash = "sha256:447556b50c1921c351ea54b4fe79d91b724ed2b027462ab9a329465d147d5a4e"}, - {file = "httpx-0.24.0.tar.gz", hash = "sha256:507d676fc3e26110d41df7d35ebd8b3b8585052450f4097401c9be59d928c63e"}, + {file = "httpx-0.24.1-py3-none-any.whl", hash = "sha256:06781eb9ac53cde990577af654bd990a4949de37a28bdb4a230d434f3a30b9bd"}, + {file = "httpx-0.24.1.tar.gz", hash = "sha256:5853a43053df830c20f8110c5e69fe44d035d850b2dfe795e196f00fdb774bdd"}, ] [package.dependencies] From 8ba5669174ecbab03057a195329020e3f65b03db Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 2 Jun 2023 16:25:29 +0000 Subject: [PATCH 091/111] chore(deps): bump deprecated from 1.2.13 to 1.2.14 (#583) --- poetry.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/poetry.lock b/poetry.lock index 2bfbc9a4e..1930411e0 100644 --- a/poetry.lock +++ b/poetry.lock @@ -272,21 +272,21 @@ files = [ [[package]] name = "deprecated" -version = "1.2.13" +version = "1.2.14" description = "Python @deprecated decorator to deprecate old python classes, functions or methods." category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" files = [ - {file = "Deprecated-1.2.13-py2.py3-none-any.whl", hash = "sha256:64756e3e14c8c5eea9795d93c524551432a0be75629f8f29e67ab8caf076c76d"}, - {file = "Deprecated-1.2.13.tar.gz", hash = "sha256:43ac5335da90c31c24ba028af536a91d41d53f9e6901ddb021bcc572ce44e38d"}, + {file = "Deprecated-1.2.14-py2.py3-none-any.whl", hash = "sha256:6fac8b097794a90302bdbb17b9b815e732d3c4720583ff1b198499d78470466c"}, + {file = "Deprecated-1.2.14.tar.gz", hash = "sha256:e5323eb936458dccc2582dc6f9c322c852a775a27065ff2b0c4970b9d53d01b3"}, ] [package.dependencies] wrapt = ">=1.10,<2" [package.extras] -dev = ["PyTest", "PyTest (<5)", "PyTest-Cov", "PyTest-Cov (<2.6)", "bump2version (<1)", "configparser (<5)", "importlib-metadata (<3)", "importlib-resources (<4)", "sphinx (<2)", "sphinxcontrib-websupport (<2)", "tox", "zipp (<2)"] +dev = ["PyTest", "PyTest-Cov", "bump2version (<1)", "sphinx (<2)", "tox"] [[package]] name = "docutils" From 65e18228bc085bf5c0cc1fb464cbcfb53ef75cb7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Jun 2023 11:39:11 -0500 Subject: [PATCH 092/111] chore(deps-dev): bump sphinx-rtd-theme from 1.2.0 to 1.2.1 (#582) Bumps [sphinx-rtd-theme](https://github.com/readthedocs/sphinx_rtd_theme) from 1.2.0 to 1.2.1. - [Changelog](https://github.com/readthedocs/sphinx_rtd_theme/blob/master/docs/changelog.rst) - [Commits](https://github.com/readthedocs/sphinx_rtd_theme/compare/1.2.0...1.2.1) --- updated-dependencies: - dependency-name: sphinx-rtd-theme dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: justinr1234 Co-authored-by: jonathanlei --- poetry.lock | 8 ++++---- pyproject.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/poetry.lock b/poetry.lock index 1930411e0..f89b6cc25 100644 --- a/poetry.lock +++ b/poetry.lock @@ -950,14 +950,14 @@ test = ["cython", "html5lib", "pytest (>=4.6)", "typed_ast"] [[package]] name = "sphinx-rtd-theme" -version = "1.2.0" +version = "1.2.1" description = "Read the Docs theme for Sphinx" category = "dev" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,>=2.7" files = [ - {file = "sphinx_rtd_theme-1.2.0-py2.py3-none-any.whl", hash = "sha256:f823f7e71890abe0ac6aaa6013361ea2696fc8d3e1fa798f463e82bdb77eeff2"}, - {file = "sphinx_rtd_theme-1.2.0.tar.gz", hash = "sha256:a0d8bd1a2ed52e0b338cbe19c4b2eef3c5e7a048769753dac6a9f059c7b641b8"}, + {file = "sphinx_rtd_theme-1.2.1-py2.py3-none-any.whl", hash = "sha256:2cc9351176cbf91944ce44cefd4fab6c3b76ac53aa9e15d6db45a3229ad7f866"}, + {file = "sphinx_rtd_theme-1.2.1.tar.gz", hash = "sha256:cf9a7dc0352cf179c538891cb28d6fad6391117d4e21c891776ab41dd6c8ff70"}, ] [package.dependencies] @@ -1316,4 +1316,4 @@ testing = ["func-timeout", "jaraco.itertools", "pytest (>=6)", "pytest-black (>= [metadata] lock-version = "2.0" python-versions = "^3.7" -content-hash = "33b43c15dd242127f1d181779293e93446259ec4a0bd00431b4214e20715fa09" +content-hash = "657adab97a2dd340a128d222ae04da2b96bb41646b25fbd6d54d691ab4f9d27e" diff --git a/pyproject.toml b/pyproject.toml index adabb2cca..588546c27 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,7 +54,7 @@ flake8-isort = "^6.0.0" flake8-annotations = "2.7.0" flake8-absolute-import = "^1.0" darglint = "^1.5.8" -sphinx-rtd-theme = "^1.2.0" +sphinx-rtd-theme = "^1.2.1" aiounittest = "^1.4.0" coverage = "^7.2.7" Jinja2 = "^3.1.2" From 82a8e5b7dc0401b2ed830d9ede228de1228ce6ee Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Mon, 5 Jun 2023 17:26:28 -0400 Subject: [PATCH 093/111] fix: improve error message for `tem` errors in relsub (#590) * include tem code in exception message * update changelog --- CHANGELOG.md | 1 + xrpl/asyncio/transaction/reliable_submission.py | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1999066e0..f81e187d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed: - Refactored `does_account_exist` and `get_balance` to avoid deprecated methods and use `ledger_index` parameter - Fixed crashes in the SignerListSet validation +- Improved error messages in `send_reliable_submission` ### Removed: - RPCs and utils related to the old sidechain design diff --git a/xrpl/asyncio/transaction/reliable_submission.py b/xrpl/asyncio/transaction/reliable_submission.py index 27fb0df23..798ff64f0 100644 --- a/xrpl/asyncio/transaction/reliable_submission.py +++ b/xrpl/asyncio/transaction/reliable_submission.py @@ -107,9 +107,8 @@ async def send_reliable_submission( submit_response = await submit(transaction, client, fail_hard=fail_hard) prelim_result = submit_response.result["engine_result"] if prelim_result[0:3] == "tem": - raise XRPLReliableSubmissionException( - submit_response.result["engine_result_message"] - ) + error_message = submit_response.result["engine_result_message"] + raise XRPLReliableSubmissionException(f"{prelim_result}: {error_message}") return await _wait_for_final_transaction_outcome( transaction_hash, client, prelim_result, transaction.last_ledger_sequence From 697756b2f03117ede1a5d0b354a711131eb8722d Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Thu, 8 Jun 2023 16:20:29 -0400 Subject: [PATCH 094/111] (WIP) bridge transfer snippet --- snippets/bridge_transfer.py | 99 +++++++++++++++++++++++++++++++++++ xrpl/models/currencies/xrp.py | 9 ++++ 2 files changed, 108 insertions(+) create mode 100644 snippets/bridge_transfer.py diff --git a/snippets/bridge_transfer.py b/snippets/bridge_transfer.py new file mode 100644 index 000000000..17a4c5258 --- /dev/null +++ b/snippets/bridge_transfer.py @@ -0,0 +1,99 @@ +"""CLI command for setting up a bridge.""" + +from time import sleep + +from xrpl.account import does_account_exist, get_balance +from xrpl.clients import JsonRpcClient +from xrpl.models import ( + AccountObjects, + XChainAccountCreateCommit, + XChainBridge, + XChainCommit, + XChainCreateClaimID, +) +from xrpl.transaction import submit_and_wait +from xrpl.utils import xrp_to_drops +from xrpl.wallet import Wallet, generate_faucet_wallet + +locking_client = JsonRpcClient("https://sidechain-net1.devnet.rippletest.net:51234") +issuing_client = JsonRpcClient("https://sidechain-net2.devnet.rippletest.net:51234") + +locking_chain_door = "rMAXACCrp3Y8PpswXcg3bKggHX76V3F8M4" +bridge_data = locking_client.request(AccountObjects(account=locking_chain_door)).result[ + "account_objects" +][0] +bridge = XChainBridge.from_xrpl(bridge_data["XChainBridge"]) +print(bridge) + +wallet1 = generate_faucet_wallet(locking_client, debug=True) +wallet2 = Wallet.create() + +print(f"Creating {wallet2.classic_address} on the issuing chain via the bridge...") + +fund_tx = XChainAccountCreateCommit( + account=wallet1.classic_address, + xchain_bridge=bridge, + signature_reward=bridge_data["SignatureReward"], + destination=wallet2.classic_address, + amount=bridge_data["MinAccountCreateAmount"] * 2, +) +fund_response = submit_and_wait(fund_tx, locking_client, wallet1) + + +# wait for the attestation to go through +ledgers_waited = 0 +MAX_LEDGERS_WAITED = 5 +while ledgers_waited < MAX_LEDGERS_WAITED: + sleep(4) + if does_account_exist(wallet2.classic_address, issuing_client): + print( + f"Destination account {wallet2.classic_address} has been created via the " + "bridge" + ) + initial_balance = get_balance(wallet2.classic_address, issuing_client) + break + + ledgers_waited += 1 + if ledgers_waited == MAX_LEDGERS_WAITED: + raise Exception("Destination account creation via the bridge failed.") + +seq_num_tx = XChainCreateClaimID( + account=wallet2.classic_address, + xchain_bridge=bridge, + signature_reward=bridge_data["SignatureReward"], + other_chain_source=wallet1.classic_address, +) +seq_num_result = submit_and_wait(seq_num_tx, issuing_client, wallet2) + +# # extract new sequence number from metadata +nodes = seq_num_result.result["meta"]["AffectedNodes"] +created_nodes = [node["CreatedNode"] for node in nodes if "CreatedNode" in node.keys()] +claim_ids_ledger_entries = [ + node for node in created_nodes if node["LedgerEntryType"] == "XChainOwnedClaimID" +] +assert len(claim_ids_ledger_entries) == 1, len(claim_ids_ledger_entries) +xchain_claim_id = claim_ids_ledger_entries[0]["NewFields"]["XChainClaimID"] + +# # XChainCommit + +commit_tx = XChainCommit( + account=wallet1.classic_address, + amount=xrp_to_drops(1), + xchain_bridge=bridge, + xchain_claim_id=xchain_claim_id, + other_chain_destination=wallet2.classic_address, +) +submit_and_wait(commit_tx, locking_client, wallet1) + +# wait for the attestations to go through +ledgers_waited = 0 +while ledgers_waited < MAX_LEDGERS_WAITED: + sleep(4) + current_balance = get_balance(wallet2.classic_address, issuing_client) + if current_balance != initial_balance: + print("Transfer is complete") + break + + ledgers_waited += 1 + if ledgers_waited == MAX_LEDGERS_WAITED: + raise Exception("Bridge transfer failed.") diff --git a/xrpl/models/currencies/xrp.py b/xrpl/models/currencies/xrp.py index 1f928c860..c1a75d655 100644 --- a/xrpl/models/currencies/xrp.py +++ b/xrpl/models/currencies/xrp.py @@ -72,3 +72,12 @@ def to_amount(self: XRP, value: Union[str, int]) -> str: A string representation of XRP amount. """ return str(value) + + def __repr__(self: XRP) -> str: + """ + Generate string representation of XRP. + + Returns: + A string representation of XRP currency. + """ + return "XRP()" From 4746be2136639223e8a229ef67cceffd2169f8c6 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Fri, 9 Jun 2023 12:28:11 -0400 Subject: [PATCH 095/111] fix snippet --- snippets/bridge_transfer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/bridge_transfer.py b/snippets/bridge_transfer.py index 17a4c5258..d4387aadc 100644 --- a/snippets/bridge_transfer.py +++ b/snippets/bridge_transfer.py @@ -35,7 +35,7 @@ xchain_bridge=bridge, signature_reward=bridge_data["SignatureReward"], destination=wallet2.classic_address, - amount=bridge_data["MinAccountCreateAmount"] * 2, + amount=str(int(bridge_data["MinAccountCreateAmount"]) * 2), ) fund_response = submit_and_wait(fund_tx, locking_client, wallet1) From 29617ac3c14ff79d2ee3b0c7de55779b0810f0aa Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Mon, 12 Jun 2023 16:14:25 -0400 Subject: [PATCH 096/111] Update bridge_transfer.py --- snippets/bridge_transfer.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/snippets/bridge_transfer.py b/snippets/bridge_transfer.py index d4387aadc..8493c9681 100644 --- a/snippets/bridge_transfer.py +++ b/snippets/bridge_transfer.py @@ -6,6 +6,7 @@ from xrpl.clients import JsonRpcClient from xrpl.models import ( AccountObjects, + AccountObjectType, XChainAccountCreateCommit, XChainBridge, XChainCommit, @@ -19,9 +20,9 @@ issuing_client = JsonRpcClient("https://sidechain-net2.devnet.rippletest.net:51234") locking_chain_door = "rMAXACCrp3Y8PpswXcg3bKggHX76V3F8M4" -bridge_data = locking_client.request(AccountObjects(account=locking_chain_door)).result[ - "account_objects" -][0] +bridge_data = locking_client.request( + AccountObjects(account=locking_chain_door, type=AccountObjectType.BRIDGE) +).result["account_objects"][0] bridge = XChainBridge.from_xrpl(bridge_data["XChainBridge"]) print(bridge) From ebfc1077ba5beda1005df2c3f8a7406369277a1f Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Thu, 6 Jul 2023 13:39:37 -0400 Subject: [PATCH 097/111] fix settings.json --- .vscode/settings.json | 54 +++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 6af2a14e5..7de2a60b8 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,29 +1,29 @@ { - "python.formatting.provider": "none", - "python.linting.pylintEnabled": false, - "python.linting.flake8Enabled": true, - "python.linting.enabled": true, - "esbonio.sphinx.confDir": "${workspaceFolder}/docs", - "python.linting.mypyEnabled": true, - "mypy.runUsingActiveInterpreter": true, - "cSpell.words": [ - "addresscodec", - "aiounittest", - "altnet", - "asyncio", - "autofills", - "binarycodec", - "isnumeric", - "keypair", - "keypairs", - "multisign", - "nftoken", - "rippletest", - "ripplex", - "xaddress", - "xchain" - ], - "[python]": { - "editor.defaultFormatter": "ms-python.black-formatter" - } + "python.formatting.provider": "none", + "python.linting.pylintEnabled": false, + "python.linting.flake8Enabled": true, + "python.linting.enabled": true, + "esbonio.sphinx.confDir": "${workspaceFolder}/docs", + "python.linting.mypyEnabled": true, + "mypy.runUsingActiveInterpreter": true, + "cSpell.words": [ + "addresscodec", + "aiounittest", + "altnet", + "asyncio", + "autofills", + "binarycodec", + "isnumeric", + "keypair", + "keypairs", + "multisign", + "nftoken", + "rippletest", + "ripplex", + "xaddress", + "xchain" + ], + "[python]": { + "editor.defaultFormatter": "ms-python.black-formatter" + } } From 7fa96351a0494335ea3dd60f7abff3914bfa363f Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Tue, 15 Aug 2023 21:42:19 +0200 Subject: [PATCH 098/111] update ledger_entry --- xrpl/models/requests/ledger_entry.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/xrpl/models/requests/ledger_entry.py b/xrpl/models/requests/ledger_entry.py index 7db72dee6..78fd16abd 100644 --- a/xrpl/models/requests/ledger_entry.py +++ b/xrpl/models/requests/ledger_entry.py @@ -16,6 +16,7 @@ from xrpl.models.requests.request import LookupByLedgerRequest, Request, RequestMethod from xrpl.models.required import REQUIRED from xrpl.models.utils import require_kwargs_on_init +from xrpl.models.xchain_bridge import XChainBridge class LedgerEntryType(str, Enum): @@ -220,6 +221,7 @@ class LedgerEntry(Request, LookupByLedgerRequest): ripple_state: Optional[RippleState] = None ticket: Optional[Union[str, Ticket]] = None bridge_account: Optional[str] = None + bridge: Optional[XChainBridge] = None xchain_claim_id: Optional[Union[str, XChainClaimID]] = None xchain_create_account_claim_id: Optional[ Union[str, XChainCreateAccountClaimID] @@ -236,17 +238,24 @@ def _get_errors(self: LedgerEntry) -> Dict[str, str]: for param in [ self.index, self.account_root, - self.directory, - self.offer, - self.ripple_state, self.check, + self.deposit_preauth, + self.directory, self.escrow, + self.offer, self.payment_channel, - self.deposit_preauth, + self.ripple_state, self.ticket, + self.xchain_claim_id, + self.xchain_create_account_claim_id, ] if param is not None ] if len(query_params) != 1: errors["LedgerEntry"] = "Must choose exactly one data to query" + + if (self.bridge is not None) == (self.bridge_account is not None): + # assert that you either have both of these or neither + errors["Bridge"] = "Must include both `bridge` and `bridge_account`." + return errors From e1b3b3213ade93135107925797c6d4b1b81138b0 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Tue, 15 Aug 2023 21:47:44 +0200 Subject: [PATCH 099/111] add tests --- .../unit/models/requests/test_ledger_entry.py | 26 ++++++++++++++++++- tests/unit/models/requests/test_sign.py | 4 +-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/tests/unit/models/requests/test_ledger_entry.py b/tests/unit/models/requests/test_ledger_entry.py index 57ec98e4b..fb2de5cd0 100644 --- a/tests/unit/models/requests/test_ledger_entry.py +++ b/tests/unit/models/requests/test_ledger_entry.py @@ -1,7 +1,7 @@ from unittest import TestCase +from xrpl.models import XRP, LedgerEntry, XChainBridge from xrpl.models.exceptions import XRPLModelException -from xrpl.models.requests import LedgerEntry from xrpl.models.requests.ledger_entry import RippleState @@ -69,6 +69,30 @@ def test_has_only_ticket_is_valid(self): ) self.assertTrue(req.is_valid()) + def test_has_only_xchain_claim_id_is_valid(self): + req = LedgerEntry( + xchain_claim_id=1, + ) + self.assertTrue(req.is_valid()) + + def test_has_only_xchain_create_account_claim_id_is_valid(self): + req = LedgerEntry( + xchain_create_account_claim_id=1, + ) + self.assertTrue(req.is_valid()) + + def test_has_both_bridge_fields_is_valid(self): + req = LedgerEntry( + bridge=XChainBridge( + locking_chain_door="rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", + locking_chain_issue=XRP(), + issuing_chain_door="r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", + issuing_chain_issue=XRP(), + ), + bridge_account="rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", + ) + self.assertTrue(req.is_valid()) + def test_has_no_query_param_is_invalid(self): with self.assertRaises(XRPLModelException): LedgerEntry() diff --git a/tests/unit/models/requests/test_sign.py b/tests/unit/models/requests/test_sign.py index 10b9a3cba..abf274967 100644 --- a/tests/unit/models/requests/test_sign.py +++ b/tests/unit/models/requests/test_sign.py @@ -3,7 +3,7 @@ from xrpl.constants import CryptoAlgorithm from xrpl.models.exceptions import XRPLModelException from xrpl.models.requests import Sign -from xrpl.models.transactions import AccountSet +from xrpl.models.transactions import AccountSet, AccountSetAsfFlag _ACCOUNT = "r9LqNeG6qHxjeUocjvVki2XR35weJ9mZgQ" _FEE = "0.00001" @@ -12,7 +12,7 @@ _TRANSACTION = AccountSet( account=_ACCOUNT, fee=_FEE, - set_flag=3, + set_flag=AccountSetAsfFlag.ASF_DISALLOW_XRP, domain=_DOMAIN, sequence=_SEQUENCE, ) From c98a82fd26d907a96c1ea2f0c77b9f5d4bed9d87 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Tue, 15 Aug 2023 22:09:33 +0200 Subject: [PATCH 100/111] fix tests --- xrpl/models/requests/ledger_entry.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/xrpl/models/requests/ledger_entry.py b/xrpl/models/requests/ledger_entry.py index 78fd16abd..9e1efe8dc 100644 --- a/xrpl/models/requests/ledger_entry.py +++ b/xrpl/models/requests/ledger_entry.py @@ -251,10 +251,14 @@ def _get_errors(self: LedgerEntry) -> Dict[str, str]: ] if param is not None ] - if len(query_params) != 1: + if ( + len(query_params) != 1 + and self.bridge is None + and self.bridge_account is None + ): errors["LedgerEntry"] = "Must choose exactly one data to query" - if (self.bridge is not None) == (self.bridge_account is not None): + if (self.bridge is not None) != (self.bridge_account is not None): # assert that you either have both of these or neither errors["Bridge"] = "Must include both `bridge` and `bridge_account`." From 73b79fdbdad12a5020c02d7059a7bc1b207124cd Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Tue, 12 Sep 2023 09:16:06 -0400 Subject: [PATCH 101/111] Update definitions.json --- xrpl/core/binarycodec/definitions/definitions.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xrpl/core/binarycodec/definitions/definitions.json b/xrpl/core/binarycodec/definitions/definitions.json index a54963107..927e426e7 100644 --- a/xrpl/core/binarycodec/definitions/definitions.json +++ b/xrpl/core/binarycodec/definitions/definitions.json @@ -49,7 +49,7 @@ "NegativeUNL": 78, "NFTokenPage": 80, "NFTokenOffer": 55, - "Amm": 121, + "AMM": 121, "Any": -3, "Child": -2, "Nickname": 110, @@ -2758,6 +2758,7 @@ "tecKILLED": 150, "tecHAS_OBLIGATIONS": 151, "tecTOO_SOON": 152, + "tecHOOK_ERROR": 153, "tecMAX_SEQUENCE_REACHED": 154, "tecNO_SUITABLE_NFTOKEN_PAGE": 155, "tecNFTOKEN_BUY_SELL_MISMATCH": 156, From 6979f6792c3b0e968954c5aa2cf22fce2606f1bd Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Thu, 14 Sep 2023 13:41:50 -0400 Subject: [PATCH 102/111] Update definitions.json --- .../binarycodec/definitions/definitions.json | 42 +++++++++++-------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/xrpl/core/binarycodec/definitions/definitions.json b/xrpl/core/binarycodec/definitions/definitions.json index 927e426e7..b6b48f440 100644 --- a/xrpl/core/binarycodec/definitions/definitions.json +++ b/xrpl/core/binarycodec/definitions/definitions.json @@ -2717,6 +2717,7 @@ "terQUEUED": -89, "terPRE_TICKET": -88, "terNO_AMM": -87, + "terSUBMITTED": -86, "tesSUCCESS": 0, @@ -2771,23 +2772,27 @@ "tecAMM_BALANCE": 163, "tecAMM_FAILED": 164, "tecAMM_INVALID_TOKENS": 165, - "tecXCHAIN_BAD_TRANSFER_ISSUE": 166, - "tecXCHAIN_NO_CLAIM_ID": 167, - "tecXCHAIN_BAD_CLAIM_ID": 168, - "tecXCHAIN_CLAIM_NO_QUORUM": 169, - "tecXCHAIN_PROOF_UNKNOWN_KEY": 170, - "tecXCHAIN_CREATE_ACCOUNT_NONXRP_ISSUE": 171, - "tecXCHAIN_WRONG_CHAIN": 172, - "tecXCHAIN_REWARD_MISMATCH": 173, - "tecXCHAIN_NO_SIGNERS_LIST": 174, - "tecXCHAIN_SENDING_ACCOUNT_MISMATCH": 175, - "tecXCHAIN_INSUFF_CREATE_AMOUNT": 176, - "tecXCHAIN_ACCOUNT_CREATE_PAST": 177, - "tecXCHAIN_ACCOUNT_CREATE_TOO_MANY": 178, - "tecXCHAIN_PAYMENT_FAILED": 179, - "tecXCHAIN_SELF_COMMIT": 180, - "tecXCHAIN_BAD_PUBLIC_KEY_ACCOUNT_PAIR": 181, - "tecXCHAIN_CREATE_ACCOUNT_DISABLED": 182 + "tecAMM_EMPTY": 166, + "tecAMM_NOT_EMPTY": 167, + "tecAMM_ACCOUNT": 168, + "tecINCOMPLETE": 169, + "tecXCHAIN_BAD_TRANSFER_ISSUE": 170, + "tecXCHAIN_NO_CLAIM_ID": 171, + "tecXCHAIN_BAD_CLAIM_ID": 172, + "tecXCHAIN_CLAIM_NO_QUORUM": 173, + "tecXCHAIN_PROOF_UNKNOWN_KEY": 174, + "tecXCHAIN_CREATE_ACCOUNT_NONXRP_ISSUE": 175, + "tecXCHAIN_WRONG_CHAIN": 176, + "tecXCHAIN_REWARD_MISMATCH": 177, + "tecXCHAIN_NO_SIGNERS_LIST": 178, + "tecXCHAIN_SENDING_ACCOUNT_MISMATCH": 179, + "tecXCHAIN_INSUFF_CREATE_AMOUNT": 180, + "tecXCHAIN_ACCOUNT_CREATE_PAST": 181, + "tecXCHAIN_ACCOUNT_CREATE_TOO_MANY": 182, + "tecXCHAIN_PAYMENT_FAILED": 183, + "tecXCHAIN_SELF_COMMIT": 184, + "tecXCHAIN_BAD_PUBLIC_KEY_ACCOUNT_PAIR": 185, + "tecXCHAIN_CREATE_ACCOUNT_DISABLED": 186 }, "TRANSACTION_TYPES": { "Invalid": -1, @@ -2825,7 +2830,7 @@ "AMMWithdraw": 37, "AMMVote": 38, "AMMBid": 39, - "XChainCreateBridge": 40, + "AMMDelete": 40, "XChainCreateClaimID": 41, "XChainCommit": 42, "XChainClaim": 43, @@ -2833,6 +2838,7 @@ "XChainAddClaimAttestation": 45, "XChainAddAccountCreateAttestation": 46, "XChainModifyBridge": 47, + "XChainCreateBridge": 48, "EnableAmendment": 100, "SetFee": 101, "UNLModify": 102 From b199c1495c7930e8dd33e0dd98d226bd8fc16df9 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Thu, 14 Sep 2023 14:38:09 -0400 Subject: [PATCH 103/111] fix unit tests --- tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json b/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json index 5027dabf9..fa30a927e 100644 --- a/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json +++ b/tests/unit/core/binarycodec/fixtures/data/codec-fixtures.json @@ -4451,7 +4451,7 @@ } }, { - "binary": "1200282200000000240000000168400000000000000A601D40000000000003E8601E400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020744630440220101BCA4B5B5A37C6F44480F9A34752C9AA8B2CDF5AD47E3CB424DEDC21C06DB702206EEB257E82A89B1F46A0A2C7F070B0BD181D980FF86FE4269E369F6FC7A270918114B5F762798A53D543A014CAF8B297CFF8F2F937E8011914AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", + "binary": "1200302200000000240000000168400000000000000A601D40000000000003E8601E400000000000271073210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020744630440220101BCA4B5B5A37C6F44480F9A34752C9AA8B2CDF5AD47E3CB424DEDC21C06DB702206EEB257E82A89B1F46A0A2C7F070B0BD181D980FF86FE4269E369F6FC7A270918114B5F762798A53D543A014CAF8B297CFF8F2F937E8011914AF80285F637EE4AF3C20378F9DFB12511ACB8D27000000000000000000000000000000000000000014550FC62003E785DC231A1058A05E56E3F09CF4E60000000000000000000000000000000000000000", "json": { "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "XChainBridge": { From 45a9301180bdb8a30fe8d5f96468fc07e33cd6a8 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Mon, 18 Sep 2023 16:17:42 -0400 Subject: [PATCH 104/111] respond to comments --- .vscode/settings.json | 2 +- CHANGELOG.md | 49 ++++++++++++++++++- snippets/bridge_transfer.py | 22 ++++++--- snippets/paths.py | 2 +- .../unit/models/requests/test_ledger_entry.py | 16 ++++++ xrpl/core/binarycodec/types/xchain_bridge.py | 2 +- xrpl/models/base_model.py | 2 + xrpl/models/requests/ledger_entry.py | 2 +- 8 files changed, 85 insertions(+), 12 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 3c7ef8c3b..c2e7b30b3 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,5 @@ { - "python.formatting.provider": "none", + "python.formatting.provider": "black", "python.linting.pylintEnabled": false, "python.linting.flake8Enabled": true, "python.linting.enabled": true, diff --git a/CHANGELOG.md b/CHANGELOG.md index 164c32319..31c0a678a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,24 +8,34 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [[Unreleased]] ### Added -- Added new syntax for `SetFee` psuedo transaction sent after the [XRPFees](https://xrpl.org/known-amendments.html#xrpfees) amendment. (Backwards compatible) + +- Added new syntax for `SetFee` pseudo transaction sent after the [XRPFees](https://xrpl.org/known-amendments.html#xrpfees) amendment. (Backwards compatible) - Update request models related to AMM +- Support for [XLS-38d (XChainBridge)](https://github.com/XRPLF/XRPL-Standards/tree/master/XLS-38d-XChainBridge) ## [2.3.0] - 2023-08-24 + ### Added + - Add AMM support [XLS-30](https://github.com/XRPLF/XRPL-Standards/discussions/78) ## [2.2.0] - 2023-08-07 + ### Added + - Added new `Clawback` transaction as per [XLS-39](https://github.com/XRPLF/XRPL-Standards/discussions/94) ## [2.1.0] - 2023-07-24 + ### Fixed + - Replaced alias for `classic_address` with separate property to work around this mypy issue: https://github.com/python/mypy/issues/6700 ## [2.0.0] - 2023-07-05 + ### Added: + - Wallet support for regular key compatibility - Added new ways of wallet generation: `from_seed`, `from_secret`, `from_entropy`, `from_secret_numbers` - Added `address` alias to `Wallet.classic_address` @@ -33,6 +43,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added `network_id` to clients in order to use the `Client` with networks beyond mainnet ### Changed: + - Updated params for `Wallet` class constructor - `Wallet.address` is now readonly - Removed `sequence` from `Wallet` class @@ -45,11 +56,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `XRP.to_amount` now converts from XRP to drops, instead of expecting a drops amount ### Fixed: + - Added a sort of the account IDs in `multisign`, so that the `multisign` always works. - Add `ledger_hash` and `ledger_index` to `account_nfts`, `nft_buy_offers`, and `nft_sell_offers` requests. - Add `nft_page` to `ledger_entry` request. ### Removed: + - `send_reliable_submission` has been replaced by `submit_and_wait` - Longer aliases for signing/submitting functions have been removed. Specifically - `submit_transaction` is now `submit` @@ -65,26 +78,33 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `get_transaction_from_hash` ## [1.9.0] - 2023-06-13 + ### Added: + - Added `submit_and_wait` to sign (if needed), autofill, submit a transaction and wait for its final outcome - `submit` and `send_reliable_submission` now accept an optional boolean param `fail_hard` (if `True` halt the submission if it's not immediately validated) - Added sidechain devnet support to faucet generation - Added `user_agent` and `usage_context` to `generate_faucet_wallet` ### Changed: + - Allowed keypairs.sign to take a hex string in addition to bytes ### Fixed: + - Refactored `does_account_exist` and `get_balance` to avoid deprecated methods and use `ledger_index` parameter - Fixed crashes in the `SignerListSet` validation - Improved error messages in `send_reliable_submission` - Better error handling in reliable submission ### Removed: + - RPCs and utils related to the old sidechain design ## [1.8.0] - 2023-04-10 + ### Added: + - Created function alias to `safe_sign_transaction` called `sign` - safe originally used to indicate local offline signing (keys aren't exposed) - Created function alias to `safe_sign_and_autofill_transaction` called `autofill_and_sign` to reflect order of operations - Created function alias to `submit_transaction` called `submit` @@ -93,9 +113,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added `getNFTokenID` to get the NFTokenID after minting a token. - Added `LedgerEntryType` enum and added `type` field to `Ledger` and `LedgerData` requests - Added the algorithm used to encode a wallet's seed to the wallet. -- Support for cross-chain bridge proposal ### Changed: + - `check_fee` now has a higher limit that is less likely to be hit - When connected hooks v2 testnet generate_faucet_wallet now defaults to using the faucet instead of requiring specification - Deprecated `get_account_info`, `get_transaction_from_hash`, `get_account_payment_transactions` for direct requests @@ -103,6 +123,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Removed nft-devnet faucet support as it has been decommissioned ([Blog Post](https://xrpl.org/blog/2023/nft-devnet-decommission.html)) ### Fixed: + - Properly type the instance functions of NestedModel - Add additional check to `txnNotFound` error from `reliable_submission` due to race condition - Add `nft_offer` type in `AccountObjects` @@ -110,7 +131,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Made `send_reliable_submission` wait the full duration until `LastLedgerSequence` passes by ## [1.7.0] - 2022-10-12 + ### Added: + - Support for ExpandedSignerList amendment that expands the maximum signer list to 32 entries - Function to parse the final account balances from a transaction's metadata - Function to parse order book changes from a transaction's metadata @@ -120,42 +143,53 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Common field `ticket_sequence` to Transaction class ### Fixed: + - Typing for factory classmethods on models - Use properly encoded transactions in `Sign`, `SignFor`, and `SignAndSubmit` - Fix Sphinx build errors due to incompatible version bumps ## [1.6.0] - 2022-06-02 + ### Added: + - Support for dynamic fee calculation - Function to parse account balances from a transaction's metadata - Better error handling for invalid client URL - Exported SubscribeBook ### Fixed + - Resolve `txnNotFound` error with `send_reliable_submission` when waiting for a submitted malformed transaction - Small typing mistake in GenericRequest - Fix bug in GenericRequest.to_dict() ## [1.5.0] - 2022-04-25 + ### Added + - Support setting flags with booleans. For each transaction type supporting flags there is a `FlagInterface` to set the flags with booleans. - `federator_info` RPC support - Helper method for creating a cross-chain payment to/from a sidechain - Helper method for parsing an NFTokenID ### Fixed + - Updated NFT names to match new 1.9.0 rippled names - `xrpl.asyncio.clients` exports (now includes `request_to_websocket`, `websocket_to_response`) - Adds optional `owner` field to NFTokenBurn - Allows lower-case currency codes ## [1.4.0] - 2022-02-24 + ### Added + - Sync and async `generate_faucet_wallet` functions now support a custom faucet host ## [1.3.0] - 2021-12-17 + ### Added + - Support for the [XLS-20 NFT proposal](https://github.com/XRPLF/XRPL-Standards/discussions/46) - `xrpl.models.amounts.get_amount_value` helper function - `xrpl.utils.str_to_hex` and `xrpl.utils.hex_to_str` helpers @@ -169,6 +203,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Exports `Transaction`, `Response`, pseudo-transactions at the `xrpl.models` level ### Fixed + - Improves typing of `Response.result` - Makes the default ledger version for `get_next_valid_seq_number` `current` instead of `validated` - Stops erroring on non-`tesSUCCESS` responses in reliable transaction submission @@ -182,21 +217,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixes bug where autofilling using an `xAddress` with `None` in the Destination Tag threw a KeyError ## [1.2.0] - 2021-11-09 + ### Added + - Support for Python 3.10 ### Fixed + - Improves documentation on using websocket clients. - Fixes an issue sending NoRippleCheck requests - Allows projects that use xrpl-py as a dependency to use typing ## [1.1.1] - 2021-07-02 + ### Fixed + - Fixes an issue encoding some non-standard currency values - Corrects installation instructions in documentation ## [1.1.0] - 2021-06-16 + ### Added + - Option for `Transaction.flags` to be a `List` of `int`s instead of just an `int` - Instance method in `Transaction` objects to calculate their hashes locally - Additional reliability to `send_reliable_submission` by getting the hash before submitting @@ -212,6 +254,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - A general `from_dict` method for `Request` models, analogous to `Transaction.from_dict` ### Fixed + - Typos in docs/tests - Improved readability of the README/documentation - Expose `xrpl.utils` at the top level @@ -222,6 +265,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Better error message reporting ## [1.0.0] - 2021-03-31 + ### Added + - Initial release! Please open up an issue in our repo if you have any feedback or issues to report. diff --git a/snippets/bridge_transfer.py b/snippets/bridge_transfer.py index 8493c9681..ae0b1f045 100644 --- a/snippets/bridge_transfer.py +++ b/snippets/bridge_transfer.py @@ -1,5 +1,6 @@ """CLI command for setting up a bridge.""" +from pprint import pprint from time import sleep from xrpl.account import does_account_exist, get_balance @@ -26,6 +27,7 @@ bridge = XChainBridge.from_xrpl(bridge_data["XChainBridge"]) print(bridge) +print("Funding a wallet via the faucet on the locking chain...") wallet1 = generate_faucet_wallet(locking_client, debug=True) wallet2 = Wallet.create() @@ -39,9 +41,10 @@ amount=str(int(bridge_data["MinAccountCreateAmount"]) * 2), ) fund_response = submit_and_wait(fund_tx, locking_client, wallet1) +pprint(fund_response.result) -# wait for the attestation to go through +print("Waiting for the attestation to go through on the issuing chain...") ledgers_waited = 0 MAX_LEDGERS_WAITED = 5 while ledgers_waited < MAX_LEDGERS_WAITED: @@ -58,6 +61,10 @@ if ledgers_waited == MAX_LEDGERS_WAITED: raise Exception("Destination account creation via the bridge failed.") +print( + "Submitting XChainCreateClaimID transaction on the issuing chain to get an " + "XChainOwnedClaimID for the transfer..." +) seq_num_tx = XChainCreateClaimID( account=wallet2.classic_address, xchain_bridge=bridge, @@ -65,8 +72,9 @@ other_chain_source=wallet1.classic_address, ) seq_num_result = submit_and_wait(seq_num_tx, issuing_client, wallet2) +pprint(seq_num_result.result) -# # extract new sequence number from metadata +# Extract new sequence number from metadata nodes = seq_num_result.result["meta"]["AffectedNodes"] created_nodes = [node["CreatedNode"] for node in nodes if "CreatedNode" in node.keys()] claim_ids_ledger_entries = [ @@ -75,8 +83,9 @@ assert len(claim_ids_ledger_entries) == 1, len(claim_ids_ledger_entries) xchain_claim_id = claim_ids_ledger_entries[0]["NewFields"]["XChainClaimID"] -# # XChainCommit +# XChainCommit +print("Sending XChainCommit tx to lock the funds for transfer...") commit_tx = XChainCommit( account=wallet1.classic_address, amount=xrp_to_drops(1), @@ -84,15 +93,16 @@ xchain_claim_id=xchain_claim_id, other_chain_destination=wallet2.classic_address, ) -submit_and_wait(commit_tx, locking_client, wallet1) +commit_result = submit_and_wait(commit_tx, locking_client, wallet1) +pprint(commit_result.result) -# wait for the attestations to go through +print("Waiting for the attestation to go through on the issuing chain...") ledgers_waited = 0 while ledgers_waited < MAX_LEDGERS_WAITED: sleep(4) current_balance = get_balance(wallet2.classic_address, issuing_client) if current_balance != initial_balance: - print("Transfer is complete") + print("Transfer is complete!") break ledgers_waited += 1 diff --git a/snippets/paths.py b/snippets/paths.py index b26581d6d..4161b6bb3 100644 --- a/snippets/paths.py +++ b/snippets/paths.py @@ -36,7 +36,7 @@ paths = path_response.result["alternatives"][0]["paths_computed"] print(paths) -# # Create a Payment to send money from wallet to destination_account using path +# Create a Payment to send money from wallet to destination_account using path payment_tx = Payment( account=wallet.address, amount=destination_amount, diff --git a/tests/unit/models/requests/test_ledger_entry.py b/tests/unit/models/requests/test_ledger_entry.py index fb2de5cd0..51ab39e51 100644 --- a/tests/unit/models/requests/test_ledger_entry.py +++ b/tests/unit/models/requests/test_ledger_entry.py @@ -93,6 +93,22 @@ def test_has_both_bridge_fields_is_valid(self): ) self.assertTrue(req.is_valid()) + def test_missing_bridge_field_is_valid(self): + with self.assertRaises(XRPLModelException): + LedgerEntry( + bridge=XChainBridge( + locking_chain_door="rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", + locking_chain_issue=XRP(), + issuing_chain_door="r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV", + issuing_chain_issue=XRP(), + ), + ) + + with self.assertRaises(XRPLModelException): + LedgerEntry( + bridge_account="rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL", + ) + def test_has_no_query_param_is_invalid(self): with self.assertRaises(XRPLModelException): LedgerEntry() diff --git a/xrpl/core/binarycodec/types/xchain_bridge.py b/xrpl/core/binarycodec/types/xchain_bridge.py index bfe312caf..73cb5f311 100644 --- a/xrpl/core/binarycodec/types/xchain_bridge.py +++ b/xrpl/core/binarycodec/types/xchain_bridge.py @@ -47,7 +47,7 @@ def from_value( for name, object_type in _TYPE_ORDER: obj = object_type.from_value(value[name]) if object_type == AccountID: - buffer += bytes.fromhex("14") # AccountID length (I think) + buffer += bytes.fromhex("14") # AccountID length buffer += bytes(obj) return cls(buffer) diff --git a/xrpl/models/base_model.py b/xrpl/models/base_model.py index 94a7b1ac8..a4494c2fd 100644 --- a/xrpl/models/base_model.py +++ b/xrpl/models/base_model.py @@ -178,7 +178,9 @@ def _from_dict_single_param( return param_value if get_origin(param_type) == Literal: + # param_type is Literal (has very specific values it will accept) if param_value in get_args(param_type): + # param_value is one of the accepted values return param_value if ( diff --git a/xrpl/models/requests/ledger_entry.py b/xrpl/models/requests/ledger_entry.py index 7640fc820..38e023022 100644 --- a/xrpl/models/requests/ledger_entry.py +++ b/xrpl/models/requests/ledger_entry.py @@ -259,7 +259,7 @@ def _get_errors(self: LedgerEntry) -> Dict[str, str]: ): errors["LedgerEntry"] = "Must choose exactly one data to query" - if (self.bridge is not None) != (self.bridge_account is not None): + if (self.bridge is None) != (self.bridge_account is None): # assert that you either have both of these or neither errors["Bridge"] = "Must include both `bridge` and `bridge_account`." From 3b5ccc9db1bac435d517631704b505501b24f98a Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Thu, 21 Sep 2023 16:56:17 -0400 Subject: [PATCH 105/111] add getXChainClaimID util --- snippets/bridge_transfer.py | 17 +-- tests/unit/utils/test_get_xchain_claim_id.py | 35 ++++++ .../XChainCreateClaimID.json | 118 ++++++++++++++++++ .../XChainCreateClaimID2.json | 118 ++++++++++++++++++ xrpl/models/transactions/metadata.py | 2 + xrpl/utils/__init__.py | 2 + xrpl/utils/get_xchain_claim_id.py | 45 +++++++ 7 files changed, 326 insertions(+), 11 deletions(-) create mode 100644 tests/unit/utils/test_get_xchain_claim_id.py create mode 100644 tests/unit/utils/txn_parser/transaction_jsons/XChainCreateClaimID.json create mode 100644 tests/unit/utils/txn_parser/transaction_jsons/XChainCreateClaimID2.json create mode 100644 xrpl/utils/get_xchain_claim_id.py diff --git a/snippets/bridge_transfer.py b/snippets/bridge_transfer.py index ae0b1f045..4bd01d6a0 100644 --- a/snippets/bridge_transfer.py +++ b/snippets/bridge_transfer.py @@ -14,7 +14,7 @@ XChainCreateClaimID, ) from xrpl.transaction import submit_and_wait -from xrpl.utils import xrp_to_drops +from xrpl.utils import get_xchain_claim_id, xrp_to_drops from xrpl.wallet import Wallet, generate_faucet_wallet locking_client = JsonRpcClient("https://sidechain-net1.devnet.rippletest.net:51234") @@ -29,6 +29,7 @@ print("Funding a wallet via the faucet on the locking chain...") wallet1 = generate_faucet_wallet(locking_client, debug=True) +print(wallet1) wallet2 = Wallet.create() print(f"Creating {wallet2.classic_address} on the issuing chain via the bridge...") @@ -65,23 +66,17 @@ "Submitting XChainCreateClaimID transaction on the issuing chain to get an " "XChainOwnedClaimID for the transfer..." ) -seq_num_tx = XChainCreateClaimID( +create_claim_id_tx = XChainCreateClaimID( account=wallet2.classic_address, xchain_bridge=bridge, signature_reward=bridge_data["SignatureReward"], other_chain_source=wallet1.classic_address, ) -seq_num_result = submit_and_wait(seq_num_tx, issuing_client, wallet2) -pprint(seq_num_result.result) +create_claim_id_result = submit_and_wait(create_claim_id_tx, issuing_client, wallet2) +pprint(create_claim_id_result.result) # Extract new sequence number from metadata -nodes = seq_num_result.result["meta"]["AffectedNodes"] -created_nodes = [node["CreatedNode"] for node in nodes if "CreatedNode" in node.keys()] -claim_ids_ledger_entries = [ - node for node in created_nodes if node["LedgerEntryType"] == "XChainOwnedClaimID" -] -assert len(claim_ids_ledger_entries) == 1, len(claim_ids_ledger_entries) -xchain_claim_id = claim_ids_ledger_entries[0]["NewFields"]["XChainClaimID"] +xchain_claim_id = get_xchain_claim_id(create_claim_id_result["meta"]) # XChainCommit diff --git a/tests/unit/utils/test_get_xchain_claim_id.py b/tests/unit/utils/test_get_xchain_claim_id.py new file mode 100644 index 000000000..e91fb71b0 --- /dev/null +++ b/tests/unit/utils/test_get_xchain_claim_id.py @@ -0,0 +1,35 @@ +"""Test the get_xchain_claim_id util.""" +from __future__ import annotations + +import json +from unittest import TestCase + +from xrpl.utils import get_xchain_claim_id + +path_to_json = "tests/unit/utils/txn_parser/transaction_jsons/" +with open(path_to_json + "XChainCreateClaimID.json", "r") as f: + fixture = json.load(f) +with open(path_to_json + "XChainCreateClaimID2.json", "r") as f: + fixture2 = json.load(f) +with open(path_to_json + "nftokenmint_response1.json", "r") as f: + wrong_fixture = json.load(f) + + +class TestGetXChainClaimID(TestCase): + """Test get_xchain_claim_id.""" + + def test_decoding_a_valid_xchain_claim_id(self: TestGetXChainClaimID): + result = get_xchain_claim_id(fixture["meta"]) + expected_xchain_claim_id = "b0" + self.assertEqual(result, expected_xchain_claim_id) + + def test_a_different_valid_xchain_claim_id(self: TestGetXChainClaimID): + result = get_xchain_claim_id(fixture2["meta"]) + expected_xchain_claim_id = "ac" + self.assertEqual(result, expected_xchain_claim_id) + + def test_error_with_wrong_tx_metadata(self: TestGetXChainClaimID) -> None: + self.assertRaises(TypeError, lambda: get_xchain_claim_id(wrong_fixture["meta"])) + + def test_error_with_raw_instead_of_meta(self: TestGetXChainClaimID) -> None: + self.assertRaises(TypeError, lambda: get_xchain_claim_id(fixture)) diff --git a/tests/unit/utils/txn_parser/transaction_jsons/XChainCreateClaimID.json b/tests/unit/utils/txn_parser/transaction_jsons/XChainCreateClaimID.json new file mode 100644 index 000000000..533f14681 --- /dev/null +++ b/tests/unit/utils/txn_parser/transaction_jsons/XChainCreateClaimID.json @@ -0,0 +1,118 @@ +{ + "tx": { + "Account": "rLVUz66tawieqTPAHuTyFTN6pLbHcXiTzd", + "Fee": "20", + "Flags": 2147483648, + "NetworkID": 2552, + "OtherChainSource": "rL5Zd9m5XEoGPddMwYY5H5C8ARcR47b6oM", + "Sequence": 1007784, + "SignatureReward": "100", + "SigningPubKey": "039E925058C740A5B73E49300FC205D058520DE37F2C63C4EE3A0D1B50C4E44080", + "TransactionType": "XChainCreateClaimID", + "TxnSignature": "304402201C6F95B9997FB63DCD9854664707C58C46AA3207612FE32366B77DA084786CAF02205752C58821D7FAFAE26F77DC10AC0AFDDCBCCF4FCBED90E6B8C4523A0EB3E008", + "XChainBridge": { + "IssuingChainDoor": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", + "IssuingChainIssue": { + "currency": "XRP" + }, + "LockingChainDoor": "rMAXACCrp3Y8PpswXcg3bKggHX76V3F8M4", + "LockingChainIssue": { + "currency": "XRP" + } + }, + "date": 1695324353000 + }, + "meta": { + "AffectedNodes": [ + { + "ModifiedNode": { + "FinalFields": { + "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", + "Flags": 0, + "MinAccountCreateAmount": "10000000", + "OwnerNode": "0", + "SignatureReward": "100", + "XChainAccountClaimCount": "e3", + "XChainAccountCreateCount": "0", + "XChainBridge": { + "IssuingChainDoor": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", + "IssuingChainIssue": { + "currency": "XRP" + }, + "LockingChainDoor": "rMAXACCrp3Y8PpswXcg3bKggHX76V3F8M4", + "LockingChainIssue": { + "currency": "XRP" + } + }, + "XChainClaimID": "b0" + }, + "LedgerEntryType": "Bridge", + "LedgerIndex": "114C0DC89656D1B0FB1F4A3426034C3FCE75BCE65D9574B5D96ABC2B24D6C8F1", + "PreviousFields": { + "XChainClaimID": "af" + }, + "PreviousTxnID": "3F6F3BBE584115D1A575AB24BA32B47184F2323B65DE5C8C8EE144A55115E0B9", + "PreviousTxnLgrSeq": 1027822 + } + }, + { + "ModifiedNode": { + "FinalFields": { + "Flags": 0, + "Owner": "rLVUz66tawieqTPAHuTyFTN6pLbHcXiTzd", + "RootIndex": "6C1EA1A93D590E831CCC0EE2CBE26C146A3A6FD36F5854DC5E5AB5CE78FAE49C" + }, + "LedgerEntryType": "DirectoryNode", + "LedgerIndex": "6C1EA1A93D590E831CCC0EE2CBE26C146A3A6FD36F5854DC5E5AB5CE78FAE49C" + } + }, + { + "CreatedNode": { + "LedgerEntryType": "XChainOwnedClaimID", + "LedgerIndex": "A00BD77AE864509D796B39041AD48E9DEFEC9AF20E5C09CEF2F5DA41D6CFEB1E", + "NewFields": { + "Account": "rLVUz66tawieqTPAHuTyFTN6pLbHcXiTzd", + "OtherChainSource": "rL5Zd9m5XEoGPddMwYY5H5C8ARcR47b6oM", + "SignatureReward": "100", + "XChainBridge": { + "IssuingChainDoor": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", + "IssuingChainIssue": { + "currency": "XRP" + }, + "LockingChainDoor": "rMAXACCrp3Y8PpswXcg3bKggHX76V3F8M4", + "LockingChainIssue": { + "currency": "XRP" + } + }, + "XChainClaimID": "b0" + } + } + }, + { + "ModifiedNode": { + "FinalFields": { + "Account": "rLVUz66tawieqTPAHuTyFTN6pLbHcXiTzd", + "Balance": "39999940", + "Flags": 0, + "OwnerCount": 3, + "Sequence": 1007785 + }, + "LedgerEntryType": "AccountRoot", + "LedgerIndex": "FD919D0BAA90C759DA4C7130AEEF6AE7FA2AF074F5E867D40BCBE1ECD8D8D0EA", + "PreviousFields": { + "Balance": "39999960", + "OwnerCount": 2, + "Sequence": 1007784 + }, + "PreviousTxnID": "3F6F3BBE584115D1A575AB24BA32B47184F2323B65DE5C8C8EE144A55115E0B9", + "PreviousTxnLgrSeq": 1027822 + } + } + ], + "TransactionIndex": 0, + "TransactionResult": "tesSUCCESS" + }, + "hash": "998E76B9840DA5A6009592A2674D0166A9C4862193193AA46EA6B77A64781FB4", + "ledger_index": 1027837, + "date": 1695324353000 + } diff --git a/tests/unit/utils/txn_parser/transaction_jsons/XChainCreateClaimID2.json b/tests/unit/utils/txn_parser/transaction_jsons/XChainCreateClaimID2.json new file mode 100644 index 000000000..b69cacfe9 --- /dev/null +++ b/tests/unit/utils/txn_parser/transaction_jsons/XChainCreateClaimID2.json @@ -0,0 +1,118 @@ +{ + "tx": { + "Account": "rwmUSzi5Xp31AjMTEdbvxgWqLETcVNU6Fv", + "Fee": "12", + "Flags": 0, + "LastLedgerSequence": 1027798, + "NetworkID": 2552, + "OtherChainSource": "rBXdfZ7NVpdjRfYajPMpviGgq7HLDeuBdR", + "Sequence": 1027778, + "SignatureReward": "100", + "SigningPubKey": "EDDDD69DF802B8DB82D644EF92E2C1F06AC128A275CDFF86F013180D104ED39D3B", + "TransactionType": "XChainCreateClaimID", + "TxnSignature": "67BE63527EC8A0C872F23E2C4EB97C1F3E7D3FED6D10C8310B9235D3891B6B9343768A080E258F6C3687BFC4B7C5FD429ABB33654C99DE46471FD6F2A7035303", + "XChainBridge": { + "IssuingChainDoor": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", + "IssuingChainIssue": { + "currency": "XRP" + }, + "LockingChainDoor": "rMAXACCrp3Y8PpswXcg3bKggHX76V3F8M4", + "LockingChainIssue": { + "currency": "XRP" + } + }, + "date": 1695324182000 + }, + "meta": { + "AffectedNodes": [ + { + "ModifiedNode": { + "FinalFields": { + "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", + "Flags": 0, + "MinAccountCreateAmount": "10000000", + "OwnerNode": "0", + "SignatureReward": "100", + "XChainAccountClaimCount": "e2", + "XChainAccountCreateCount": "0", + "XChainBridge": { + "IssuingChainDoor": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", + "IssuingChainIssue": { + "currency": "XRP" + }, + "LockingChainDoor": "rMAXACCrp3Y8PpswXcg3bKggHX76V3F8M4", + "LockingChainIssue": { + "currency": "XRP" + } + }, + "XChainClaimID": "ac" + }, + "LedgerEntryType": "Bridge", + "LedgerIndex": "114C0DC89656D1B0FB1F4A3426034C3FCE75BCE65D9574B5D96ABC2B24D6C8F1", + "PreviousFields": { + "XChainClaimID": "ab" + }, + "PreviousTxnID": "80C33D1FB349D698CFDB1A85E8368557C5B7219B74DFCB2B05E0B10E2667F902", + "PreviousTxnLgrSeq": 1027779 + } + }, + { + "ModifiedNode": { + "FinalFields": { + "Account": "rwmUSzi5Xp31AjMTEdbvxgWqLETcVNU6Fv", + "Balance": "19999988", + "Flags": 0, + "OwnerCount": 1, + "Sequence": 1027779 + }, + "LedgerEntryType": "AccountRoot", + "LedgerIndex": "33442CE111B258424548888D8999F6D064A0866B1300C44AB72E1C5A09765D9D", + "PreviousFields": { + "Balance": "20000000", + "OwnerCount": 0, + "Sequence": 1027778 + }, + "PreviousTxnID": "7C9ACA230488547B4F39EBCE332447FB90AE59B64C1B03BBF474B509B43739EC", + "PreviousTxnLgrSeq": 1027778 + } + }, + { + "CreatedNode": { + "LedgerEntryType": "DirectoryNode", + "LedgerIndex": "439684B06C22596B5B86D2F50903B6AA6F68BD07BED636FC6325704B09DE5D61", + "NewFields": { + "Owner": "rwmUSzi5Xp31AjMTEdbvxgWqLETcVNU6Fv", + "RootIndex": "439684B06C22596B5B86D2F50903B6AA6F68BD07BED636FC6325704B09DE5D61" + } + } + }, + { + "CreatedNode": { + "LedgerEntryType": "XChainOwnedClaimID", + "LedgerIndex": "8097863E1200B0174006541763AA8F604782DA10C1BD37190D753C699D69C678", + "NewFields": { + "Account": "rwmUSzi5Xp31AjMTEdbvxgWqLETcVNU6Fv", + "OtherChainSource": "rBXdfZ7NVpdjRfYajPMpviGgq7HLDeuBdR", + "SignatureReward": "100", + "XChainBridge": { + "IssuingChainDoor": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", + "IssuingChainIssue": { + "currency": "XRP" + }, + "LockingChainDoor": "rMAXACCrp3Y8PpswXcg3bKggHX76V3F8M4", + "LockingChainIssue": { + "currency": "XRP" + } + }, + "XChainClaimID": "ac" + } + } + } + ], + "TransactionIndex": 0, + "TransactionResult": "tesSUCCESS" + }, + "hash": "A42C4E7F5BAF8A9BEB56853114EE686D554F15F400B8DA885A344B13C32D07BC", + "ledger_index": 1027780, + "date": 1695324182000 +} diff --git a/xrpl/models/transactions/metadata.py b/xrpl/models/transactions/metadata.py index bcb225c1d..76e2873dc 100644 --- a/xrpl/models/transactions/metadata.py +++ b/xrpl/models/transactions/metadata.py @@ -34,6 +34,7 @@ class Fields(TypedDict): BookDirectory: NotRequired[str] Expiration: NotRequired[int] NFTokens: NotRequired[List[NFTokenMetadata]] + XChainClaimID: NotRequired[str] class CreatedNodeFields(TypedDict): @@ -96,6 +97,7 @@ class TransactionMetadata(TypedDict): Node: TypeAlias = Union[CreatedNode, ModifiedNode, DeletedNode] +# TODO: make these methods use snake_case def isCreatedNode(node: Node) -> TypeGuard[CreatedNode]: """ Typeguard for CreatedNode diff --git a/xrpl/utils/__init__.py b/xrpl/utils/__init__.py index 5f164f1f5..789fff8f2 100644 --- a/xrpl/utils/__init__.py +++ b/xrpl/utils/__init__.py @@ -1,5 +1,6 @@ """Convenience utilities for the XRP Ledger""" +from xrpl.utils.get_xchain_claim_id import get_xchain_claim_id from xrpl.utils.str_conversions import hex_to_str, str_to_hex from xrpl.utils.time_conversions import ( XRPLTimeRangeException, @@ -29,4 +30,5 @@ "get_balance_changes", "get_final_balances", "get_order_book_changes", + "get_xchain_claim_id", ] diff --git a/xrpl/utils/get_xchain_claim_id.py b/xrpl/utils/get_xchain_claim_id.py new file mode 100644 index 000000000..8da6f8c42 --- /dev/null +++ b/xrpl/utils/get_xchain_claim_id.py @@ -0,0 +1,45 @@ +"""Utils to get an XChainClaimID from metadata.""" +from xrpl.models.transactions.metadata import TransactionMetadata, isCreatedNode + + +def get_xchain_claim_id(meta: TransactionMetadata) -> str: + """ + Gets the XChainClaimID from a recently-submitted XChainCreateClaimID transaction. + + Args: + meta: Metadata from the response to submitting an XChainCreateClaimID + transaction. + + Returns: + The newly created XChainClaimID. + + Raises: + TypeError: if given something other than metadata (e.g. the full + transaction response). + """ + if meta is None or meta.get("AffectedNodes") is None: + raise TypeError( + f"""Unable to parse the parameter given to get_xchain_claim_id. + 'meta' must be the metadata from an XChainCreateClaimID transaction. + Received {meta} instead.""" + ) + + affected_nodes = [ + node + for node in meta["AffectedNodes"] + if isCreatedNode(node) + and node["CreatedNode"]["LedgerEntryType"] == "XChainOwnedClaimID" + ] + + if len(affected_nodes) == 0: + raise TypeError("No XChainOwnedClaimID created.") + + if len(affected_nodes) > 1: + # Sanity check - should never happen + raise TypeError( + "Multiple XChainOwnedClaimIDs were somehow created. Please report this " + "error." + ) + + # Get the NFTokenID which wasn't there before this transaction completed. + return affected_nodes[0]["CreatedNode"]["NewFields"]["XChainClaimID"] From 2317670ed61f1b4a47c73e341091c389b8dc664a Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Thu, 21 Sep 2023 17:24:02 -0400 Subject: [PATCH 106/111] fix error --- snippets/bridge_transfer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/bridge_transfer.py b/snippets/bridge_transfer.py index 4bd01d6a0..4801e000a 100644 --- a/snippets/bridge_transfer.py +++ b/snippets/bridge_transfer.py @@ -76,7 +76,7 @@ pprint(create_claim_id_result.result) # Extract new sequence number from metadata -xchain_claim_id = get_xchain_claim_id(create_claim_id_result["meta"]) +xchain_claim_id = get_xchain_claim_id(create_claim_id_result.result["meta"]) # XChainCommit From e718723487bd09ade6d81796763dbf88ddfbf2ed Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Mon, 25 Sep 2023 17:45:36 -0400 Subject: [PATCH 107/111] fix test name --- tests/unit/models/requests/test_ledger_entry.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/models/requests/test_ledger_entry.py b/tests/unit/models/requests/test_ledger_entry.py index 51ab39e51..513ef9d1e 100644 --- a/tests/unit/models/requests/test_ledger_entry.py +++ b/tests/unit/models/requests/test_ledger_entry.py @@ -93,7 +93,7 @@ def test_has_both_bridge_fields_is_valid(self): ) self.assertTrue(req.is_valid()) - def test_missing_bridge_field_is_valid(self): + def test_missing_bridge_field_is_invalid(self): with self.assertRaises(XRPLModelException): LedgerEntry( bridge=XChainBridge( From 7ea61b1e1885d1da699d7e01131e6c1b241eb72e Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Mon, 25 Sep 2023 17:46:58 -0400 Subject: [PATCH 108/111] add more comments --- xrpl/core/binarycodec/types/xchain_bridge.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xrpl/core/binarycodec/types/xchain_bridge.py b/xrpl/core/binarycodec/types/xchain_bridge.py index 73cb5f311..b71c2bb15 100644 --- a/xrpl/core/binarycodec/types/xchain_bridge.py +++ b/xrpl/core/binarycodec/types/xchain_bridge.py @@ -72,8 +72,9 @@ def from_parser( """ buffer = b"" - for name, object_type in _TYPE_ORDER: + for _, object_type in _TYPE_ORDER: if object_type == AccountID: + # skip the `14` byte and add it by hand parser.skip(1) buffer += bytes.fromhex("14") obj = object_type.from_parser(parser, length_hint) From 0454b4e68f15f714f7403e09b6d7f54b5f4c5c20 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Tue, 26 Sep 2023 09:49:00 -0400 Subject: [PATCH 109/111] fix changelog --- CHANGELOG.md | 46 ---------------------------------------------- 1 file changed, 46 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b35719c4..1bd2f7dba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,38 +8,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [[Unreleased]] ### Added - - Added new syntax for `SetFee` pseudo transaction sent after the [XRPFees](https://xrpl.org/known-amendments.html#xrpfees) amendment. (Backwards compatible) - Support for [XLS-38d (XChainBridge)](https://github.com/XRPLF/XRPL-Standards/tree/master/XLS-38d-XChainBridge) ### Fixed - - Update request models related to AMM - Better error handling for when a `Wallet` is passed into an account or destination field ## [2.3.0] - 2023-08-24 - ### Added - - Add AMM support [XLS-30](https://github.com/XRPLF/XRPL-Standards/discussions/78) ## [2.2.0] - 2023-08-07 - ### Added - - Added new `Clawback` transaction as per [XLS-39](https://github.com/XRPLF/XRPL-Standards/discussions/94) ## [2.1.0] - 2023-07-24 - ### Fixed - - Replaced alias for `classic_address` with separate property to work around this mypy issue: https://github.com/python/mypy/issues/6700 ## [2.0.0] - 2023-07-05 - ### Added: - - Wallet support for regular key compatibility - Added new ways of wallet generation: `from_seed`, `from_secret`, `from_entropy`, `from_secret_numbers` - Added `address` alias to `Wallet.classic_address` @@ -47,7 +37,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added `network_id` to clients in order to use the `Client` with networks beyond mainnet ### Changed: - - Updated params for `Wallet` class constructor - `Wallet.address` is now readonly - Removed `sequence` from `Wallet` class @@ -60,13 +49,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `XRP.to_amount` now converts from XRP to drops, instead of expecting a drops amount ### Fixed: - - Added a sort of the account IDs in `multisign`, so that the `multisign` always works. - Add `ledger_hash` and `ledger_index` to `account_nfts`, `nft_buy_offers`, and `nft_sell_offers` requests. - Add `nft_page` to `ledger_entry` request. ### Removed: - - `send_reliable_submission` has been replaced by `submit_and_wait` - Longer aliases for signing/submitting functions have been removed. Specifically - `submit_transaction` is now `submit` @@ -82,33 +69,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `get_transaction_from_hash` ## [1.9.0] - 2023-06-13 - ### Added: - - Added `submit_and_wait` to sign (if needed), autofill, submit a transaction and wait for its final outcome - `submit` and `send_reliable_submission` now accept an optional boolean param `fail_hard` (if `True` halt the submission if it's not immediately validated) - Added sidechain devnet support to faucet generation - Added `user_agent` and `usage_context` to `generate_faucet_wallet` ### Changed: - - Allowed keypairs.sign to take a hex string in addition to bytes ### Fixed: - - Refactored `does_account_exist` and `get_balance` to avoid deprecated methods and use `ledger_index` parameter - Fixed crashes in the `SignerListSet` validation - Improved error messages in `send_reliable_submission` - Better error handling in reliable submission ### Removed: - - RPCs and utils related to the old sidechain design ## [1.8.0] - 2023-04-10 - ### Added: - - Created function alias to `safe_sign_transaction` called `sign` - safe originally used to indicate local offline signing (keys aren't exposed) - Created function alias to `safe_sign_and_autofill_transaction` called `autofill_and_sign` to reflect order of operations - Created function alias to `submit_transaction` called `submit` @@ -119,7 +99,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added the algorithm used to encode a wallet's seed to the wallet. ### Changed: - - `check_fee` now has a higher limit that is less likely to be hit - When connected hooks v2 testnet generate_faucet_wallet now defaults to using the faucet instead of requiring specification - Deprecated `get_account_info`, `get_transaction_from_hash`, `get_account_payment_transactions` for direct requests @@ -127,7 +106,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Removed nft-devnet faucet support as it has been decommissioned ([Blog Post](https://xrpl.org/blog/2023/nft-devnet-decommission.html)) ### Fixed: - - Properly type the instance functions of NestedModel - Add additional check to `txnNotFound` error from `reliable_submission` due to race condition - Add `nft_offer` type in `AccountObjects` @@ -135,9 +113,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Made `send_reliable_submission` wait the full duration until `LastLedgerSequence` passes by ## [1.7.0] - 2022-10-12 - ### Added: - - Support for ExpandedSignerList amendment that expands the maximum signer list to 32 entries - Function to parse the final account balances from a transaction's metadata - Function to parse order book changes from a transaction's metadata @@ -147,53 +123,42 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Common field `ticket_sequence` to Transaction class ### Fixed: - - Typing for factory classmethods on models - Use properly encoded transactions in `Sign`, `SignFor`, and `SignAndSubmit` - Fix Sphinx build errors due to incompatible version bumps ## [1.6.0] - 2022-06-02 - ### Added: - - Support for dynamic fee calculation - Function to parse account balances from a transaction's metadata - Better error handling for invalid client URL - Exported SubscribeBook ### Fixed - - Resolve `txnNotFound` error with `send_reliable_submission` when waiting for a submitted malformed transaction - Small typing mistake in GenericRequest - Fix bug in GenericRequest.to_dict() ## [1.5.0] - 2022-04-25 - ### Added - - Support setting flags with booleans. For each transaction type supporting flags there is a `FlagInterface` to set the flags with booleans. - `federator_info` RPC support - Helper method for creating a cross-chain payment to/from a sidechain - Helper method for parsing an NFTokenID ### Fixed - - Updated NFT names to match new 1.9.0 rippled names - `xrpl.asyncio.clients` exports (now includes `request_to_websocket`, `websocket_to_response`) - Adds optional `owner` field to NFTokenBurn - Allows lower-case currency codes ## [1.4.0] - 2022-02-24 - ### Added - - Sync and async `generate_faucet_wallet` functions now support a custom faucet host ## [1.3.0] - 2021-12-17 - ### Added - - Support for the [XLS-20 NFT proposal](https://github.com/XRPLF/XRPL-Standards/discussions/46) - `xrpl.models.amounts.get_amount_value` helper function - `xrpl.utils.str_to_hex` and `xrpl.utils.hex_to_str` helpers @@ -207,7 +172,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Exports `Transaction`, `Response`, pseudo-transactions at the `xrpl.models` level ### Fixed - - Improves typing of `Response.result` - Makes the default ledger version for `get_next_valid_seq_number` `current` instead of `validated` - Stops erroring on non-`tesSUCCESS` responses in reliable transaction submission @@ -221,28 +185,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixes bug where autofilling using an `xAddress` with `None` in the Destination Tag threw a KeyError ## [1.2.0] - 2021-11-09 - ### Added - - Support for Python 3.10 ### Fixed - - Improves documentation on using websocket clients. - Fixes an issue sending NoRippleCheck requests - Allows projects that use xrpl-py as a dependency to use typing ## [1.1.1] - 2021-07-02 - ### Fixed - - Fixes an issue encoding some non-standard currency values - Corrects installation instructions in documentation ## [1.1.0] - 2021-06-16 - ### Added - - Option for `Transaction.flags` to be a `List` of `int`s instead of just an `int` - Instance method in `Transaction` objects to calculate their hashes locally - Additional reliability to `send_reliable_submission` by getting the hash before submitting @@ -258,7 +215,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - A general `from_dict` method for `Request` models, analogous to `Transaction.from_dict` ### Fixed - - Typos in docs/tests - Improved readability of the README/documentation - Expose `xrpl.utils` at the top level @@ -269,8 +225,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Better error message reporting ## [1.0.0] - 2021-03-31 - ### Added - - Initial release! Please open up an issue in our repo if you have any feedback or issues to report. From b8c287ee9abd0a28e4774fe7cf65372c4ce423a8 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Wed, 27 Sep 2023 10:03:12 -0400 Subject: [PATCH 110/111] respond to comments --- xrpl/models/requests/ledger_entry.py | 78 ++++++++++++++++--- xrpl/models/transactions/xchain_claim.py | 2 +- .../transactions/xchain_create_bridge.py | 2 +- .../transactions/xchain_modify_bridge.py | 2 +- 4 files changed, 71 insertions(+), 13 deletions(-) diff --git a/xrpl/models/requests/ledger_entry.py b/xrpl/models/requests/ledger_entry.py index 38e023022..bf04571bb 100644 --- a/xrpl/models/requests/ledger_entry.py +++ b/xrpl/models/requests/ledger_entry.py @@ -177,11 +177,40 @@ class Ticket(BaseModel): class XChainClaimID(BaseModel): """Required fields for requesting an XChainClaimID if not querying by object ID.""" - locking_chain_door: str - locking_chain_issue: Currency - issuing_chain_door: str - issuing_chain_issue: Currency - xchain_claim_id: Union[int, str] + locking_chain_door: str = REQUIRED # type: ignore + """ + This field is required. + + :meta hide-value: + """ + + locking_chain_issue: Currency = REQUIRED # type: ignore + """ + This field is required. + + :meta hide-value: + """ + + issuing_chain_door: str = REQUIRED # type: ignore + """ + This field is required. + + :meta hide-value: + """ + + issuing_chain_issue: Currency = REQUIRED # type: ignore + """ + This field is required. + + :meta hide-value: + """ + + xchain_claim_id: Union[int, str] = REQUIRED # type: ignore + """ + This field is required. + + :meta hide-value: + """ @require_kwargs_on_init @@ -192,11 +221,40 @@ class XChainCreateAccountClaimID(BaseModel): object ID. """ - locking_chain_door: str - locking_chain_issue: Currency - issuing_chain_door: str - issuing_chain_issue: Currency - xchain_create_account_claim_id: Union[int, str] + locking_chain_door: str = REQUIRED # type: ignore + """ + This field is required. + + :meta hide-value: + """ + + locking_chain_issue: Currency = REQUIRED # type: ignore + """ + This field is required. + + :meta hide-value: + """ + + issuing_chain_door: str = REQUIRED # type: ignore + """ + This field is required. + + :meta hide-value: + """ + + issuing_chain_issue: Currency = REQUIRED # type: ignore + """ + This field is required. + + :meta hide-value: + """ + + xchain_create_account_claim_id: Union[int, str] = REQUIRED # type: ignore + """ + This field is required. + + :meta hide-value: + """ @require_kwargs_on_init diff --git a/xrpl/models/transactions/xchain_claim.py b/xrpl/models/transactions/xchain_claim.py index 4cbd5922d..7889d35d6 100644 --- a/xrpl/models/transactions/xchain_claim.py +++ b/xrpl/models/transactions/xchain_claim.py @@ -82,6 +82,6 @@ def _get_errors(self: XChainClaim) -> Dict[str, str]: ): errors[ "amount" - ] = "Amount must match either locking chain issue or issuing chain issue." + ] = "amount must match either locking chain issue or issuing chain issue." return errors diff --git a/xrpl/models/transactions/xchain_create_bridge.py b/xrpl/models/transactions/xchain_create_bridge.py index 6b1fa506e..3ebe7caeb 100644 --- a/xrpl/models/transactions/xchain_create_bridge.py +++ b/xrpl/models/transactions/xchain_create_bridge.py @@ -66,7 +66,7 @@ def _get_errors(self: XChainCreateBridge) -> Dict[str, str]: if self.account not in [bridge.locking_chain_door, bridge.issuing_chain_door]: errors[ "account" - ] = "Account must be either locking chain door or issuing chain door." + ] = "account must be either locking chain door or issuing chain door." if (bridge.locking_chain_issue == XRP()) != ( bridge.issuing_chain_issue == XRP() diff --git a/xrpl/models/transactions/xchain_modify_bridge.py b/xrpl/models/transactions/xchain_modify_bridge.py index 51b877a07..bae010301 100644 --- a/xrpl/models/transactions/xchain_modify_bridge.py +++ b/xrpl/models/transactions/xchain_modify_bridge.py @@ -84,7 +84,7 @@ def _get_errors(self: XChainModifyBridge) -> Dict[str, str]: if self.account not in [bridge.locking_chain_door, bridge.issuing_chain_door]: errors[ "account" - ] = "Account must be either locking chain door or issuing chain door." + ] = "account must be either locking chain door or issuing chain door." if self.signature_reward is not None and not self.signature_reward.isnumeric(): errors["signature_reward"] = "`signature_reward` must be numeric." From 1740de7cc821cd7082fa6752f8b3318a06517d8c Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Wed, 27 Sep 2023 11:28:00 -0400 Subject: [PATCH 111/111] improve ledger entry objects --- xrpl/models/requests/ledger_entry.py | 67 +++------------------------- 1 file changed, 6 insertions(+), 61 deletions(-) diff --git a/xrpl/models/requests/ledger_entry.py b/xrpl/models/requests/ledger_entry.py index bf04571bb..f696cf8a9 100644 --- a/xrpl/models/requests/ledger_entry.py +++ b/xrpl/models/requests/ledger_entry.py @@ -12,7 +12,6 @@ from typing import Dict, List, Optional, Union from xrpl.models.base_model import BaseModel -from xrpl.models.currencies import Currency from xrpl.models.requests.request import LookupByLedgerRequest, Request, RequestMethod from xrpl.models.required import REQUIRED from xrpl.models.utils import require_kwargs_on_init @@ -174,40 +173,13 @@ class Ticket(BaseModel): @require_kwargs_on_init @dataclass(frozen=True) -class XChainClaimID(BaseModel): +class XChainClaimID(XChainBridge): """Required fields for requesting an XChainClaimID if not querying by object ID.""" - locking_chain_door: str = REQUIRED # type: ignore - """ - This field is required. - - :meta hide-value: - """ - - locking_chain_issue: Currency = REQUIRED # type: ignore - """ - This field is required. - - :meta hide-value: - """ - - issuing_chain_door: str = REQUIRED # type: ignore - """ - This field is required. - - :meta hide-value: - """ - - issuing_chain_issue: Currency = REQUIRED # type: ignore - """ - This field is required. - - :meta hide-value: - """ - xchain_claim_id: Union[int, str] = REQUIRED # type: ignore """ - This field is required. + The `XChainClaimID` associated with a cross-chain transfer, which was created in an + `XChainCreateClaimID` transaction. This field is required. :meta hide-value: """ @@ -215,43 +187,16 @@ class XChainClaimID(BaseModel): @require_kwargs_on_init @dataclass(frozen=True) -class XChainCreateAccountClaimID(BaseModel): +class XChainCreateAccountClaimID(XChainBridge): """ Required fields for requesting an XChainCreateAccountClaimID if not querying by object ID. """ - locking_chain_door: str = REQUIRED # type: ignore - """ - This field is required. - - :meta hide-value: - """ - - locking_chain_issue: Currency = REQUIRED # type: ignore - """ - This field is required. - - :meta hide-value: - """ - - issuing_chain_door: str = REQUIRED # type: ignore - """ - This field is required. - - :meta hide-value: - """ - - issuing_chain_issue: Currency = REQUIRED # type: ignore - """ - This field is required. - - :meta hide-value: - """ - xchain_create_account_claim_id: Union[int, str] = REQUIRED # type: ignore """ - This field is required. + The `XChainCreateAccountClaimID` associated with a cross-chain account create. This + field is required. :meta hide-value: """