xrpld
Loading...
Searching...
No Matches
xrpl::test::IOU Class Reference

Represents an IOU (issued currency) for testing. More...

#include <IOU.h>

Collaboration diagram for xrpl::test::IOU:

Public Member Functions

 IOU (std::string_view currencyCode, Account const &issuer)
 Construct an IOU from a currency code and issuing account.
 IOU (Currency currency, Account const &issuer)
 Construct an IOU from a Currency and issuing account.
Issue issue () const
 Get the Issue (currency + issuer pair).
Asset asset () const
 Get the Asset.
template<typename T>
STAmount amount (T value) const
 Create an STAmount of this IOU.
STAmount amount (Number const &value) const
 Create an STAmount of this IOU from a Number.
Currency const & currency () const
 Get the currency.
AccountID const & issuer () const
 Get the issuer account ID.

Private Attributes

Currency currency_
AccountID issuer_

Detailed Description

Represents an IOU (issued currency) for testing.

Provides a clear, explicit API for creating currencies issued by an account. This replaces the cryptic Account::operator[] from the jtx framework.

Account gw("gateway");
IOU USD("USD", gw);
auto issue = USD.issue(); // Get the Issue
auto asset = USD.asset(); // Get the Asset
auto amt = USD.amount(100); // Get STAmount of 100 USD
Asset asset() const
Get the Asset.
Definition IOU.h:72
IOU(std::string_view currencyCode, Account const &issuer)
Construct an IOU from a currency code and issuing account.
Definition IOU.h:41
Issue issue() const
Get the Issue (currency + issuer pair).
Definition IOU.h:62
Immutable cryptographic account descriptor.
Definition jtx/Account.h:17

Definition at line 33 of file IOU.h.

Constructor & Destructor Documentation

◆ IOU() [1/2]

xrpl::test::IOU::IOU ( std::string_view currencyCode,
Account const & issuer )

Construct an IOU from a currency code and issuing account.

Parameters
currencyCodeA 3-character ISO currency code (e.g., "USD").
issuerThe account that issues this currency.

Definition at line 41 of file IOU.h.

◆ IOU() [2/2]

xrpl::test::IOU::IOU ( Currency currency,
Account const & issuer )

Construct an IOU from a Currency and issuing account.

Parameters
currencyThe Currency object.
issuerThe account that issues this currency.

Definition at line 52 of file IOU.h.

Member Function Documentation

◆ issue()

Issue xrpl::test::IOU::issue ( ) const
nodiscard

Get the Issue (currency + issuer pair).

Returns
An Issue object representing this IOU.

Definition at line 62 of file IOU.h.

◆ asset()

Asset xrpl::test::IOU::asset ( ) const
nodiscard

Get the Asset.

Returns
An Asset object representing this IOU.

Definition at line 72 of file IOU.h.

◆ amount() [1/2]

template<typename T>
STAmount xrpl::test::IOU::amount ( T value) const
nodiscard

Create an STAmount of this IOU.

Works with any arithmetic type (int, double, etc.) by converting to string and parsing. This matches the jtx IOU behaviour.

Template Parameters
TAn arithmetic type.
Parameters
valueThe amount as any arithmetic type.
Returns
An STAmount representing value units of this IOU.

Definition at line 90 of file IOU.h.

◆ amount() [2/2]

STAmount xrpl::test::IOU::amount ( Number const & value) const
nodiscard

Create an STAmount of this IOU from a Number.

Parameters
valueThe amount as a Number.
Returns
An STAmount representing value units of this IOU.

Definition at line 101 of file IOU.h.

◆ currency()

Currency const & xrpl::test::IOU::currency ( ) const
nodiscard

Get the currency.

Returns
The currency.

Definition at line 111 of file IOU.h.

◆ issuer()

AccountID const & xrpl::test::IOU::issuer ( ) const
nodiscard

Get the issuer account ID.

Returns
The issuer's AccountID.

Definition at line 121 of file IOU.h.

Member Data Documentation

◆ currency_

Currency xrpl::test::IOU::currency_
private

Definition at line 127 of file IOU.h.

◆ issuer_

AccountID xrpl::test::IOU::issuer_
private

Definition at line 128 of file IOU.h.