Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pulling set_fee tx updates #9

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion tests/unit/models/transactions/test_pseudo_transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_from_xrpl_enable_amendment(self):
full_dict = {**amendment_dict, "Flags": 0, "TxnSignature": ""}
self.assertEqual(actual.to_xrpl(), full_dict)

def test_from_xrpl_set_fee(self):
def test_from_xrpl_set_fee_pre_amendment(self):
reference_fee_units = 10
reserve_base = 20000000
reserve_increment = 5000000
Expand All @@ -64,6 +64,30 @@ def test_from_xrpl_set_fee(self):
full_dict = {**set_fee_dict, "Flags": 0, "TxnSignature": ""}
self.assertEqual(actual.to_xrpl(), full_dict)

def test_from_xrpl_set_fee_post_amendment(self):
reserve_base_drops = "20000000"
reserve_increment_drops = "5000000"
base_fee_drops = "000000000000000A"
set_fee_dict = {
"Account": "rrrrrrrrrrrrrrrrrrrrrhoLvTp",
"BaseFeeDrops": base_fee_drops,
"Fee": "0",
"ReserveBaseDrops": reserve_base_drops,
"ReserveIncrementDrops": reserve_increment_drops,
"Sequence": 0,
"SigningPubKey": "",
"TransactionType": "SetFee",
}
expected = SetFee(
reserve_base_drops=reserve_base_drops,
reserve_increment_drops=reserve_increment_drops,
base_fee_drops=base_fee_drops,
)
actual = Transaction.from_xrpl(set_fee_dict)
self.assertEqual(actual, expected)
full_dict = {**set_fee_dict, "Flags": 0, "TxnSignature": ""}
self.assertEqual(actual.to_xrpl(), full_dict)

def test_from_xrpl_unl_modify(self):
ledger_sequence = 1600000
validator = "ED6629D456285AE3613B285F65BBFF168D695BA3921F309949AFCD2CA7AFEC16FE"
Expand Down
51 changes: 42 additions & 9 deletions xrpl/models/transactions/pseudo_transactions/set_fee.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"""Model for SetFee pseudo-transaction type."""

from __future__ import annotations

from dataclasses import dataclass, field
from typing import Optional

from xrpl.models.required import REQUIRED
from xrpl.models.transactions.pseudo_transactions.pseudo_transaction import (
PseudoTransaction,
)
Expand All @@ -19,42 +20,74 @@ class SetFee(PseudoTransaction):
<https://xrpl.org/transaction-cost.html>`_ or `reserve requirements
<https://xrpl.org/reserves.html>`_ as a result of `Fee Voting
<https://xrpl.org/fee-voting.html>`_.

The parameters are different depending on if this is before or after the
`XRPFees Amendment<https://xrpl.org/known-amendments.html#xrpfees>`_

Before the XRPFees Amendment which was proposed in rippled 1.10.0
base_fee, reference_fee_units, reserve_base, and reserve_increment
were required fields.

After the XRPFees Amendment, base_fee_drops, reserve_base_drops,
and reserve_increment_drops are required fields.

No SetFee Pseudo Transaction should contain fields from BOTH before
and after the XRPFees amendment.
"""

base_fee: str = REQUIRED # type: ignore
# Required BEFORE the XRPFees Amendment

base_fee: Optional[str] = None
"""
The charge, in drops of XRP, for the reference transaction, as hex. (This is the
transaction cost before scaling for load.) This field is required.

:meta hide-value:
"""

reference_fee_units: int = REQUIRED # type: ignore
reference_fee_units: Optional[int] = None
"""
The cost, in fee units, of the reference transaction. This field is required.

:meta hide-value:
"""

reserve_base: int = REQUIRED # type: ignore
reserve_base: Optional[int] = None
"""
The base reserve, in drops. This field is required.

:meta hide-value:
"""

reserve_increment: int = REQUIRED # type: ignore
reserve_increment: Optional[int] = None
"""
The incremental reserve, in drops. This field is required.

:meta hide-value:
"""

ledger_sequence: Optional[int] = None
# Required AFTER the XRPFees Amendment

base_fee_drops: Optional[str] = None
"""
The charge, in drops of XRP, for the reference transaction, as hex. (This is the
transaction cost before scaling for load.) This field is required.

:meta hide-value:
"""
The index of the ledger version where this pseudo-transaction appears. This
distinguishes the pseudo-transaction from other occurrences of the same change.
This field is omitted for some historical SetFee pseudo-transactions.

reserve_base_drops: Optional[str] = None
"""
The base reserve, in drops. This field is required.

:meta hide-value:
"""

reserve_increment_drops: Optional[str] = None
"""
The incremental reserve, in drops. This field is required.

:meta hide-value:
"""

transaction_type: PseudoTransactionType = field(
Expand Down
Loading