CurrencyAmount

Enum CurrencyAmount 

Source
pub enum CurrencyAmount {
    XRP(BigInt),
    IssuedCurrency(IssuedCurrencyAmount),
}

Variants§

§

XRP(BigInt)

§

IssuedCurrency(IssuedCurrencyAmount)

Implementations§

Source§

impl CurrencyAmount

Source

pub fn xrp(drops: u64) -> Self

Examples found in repository?
examples/account_submit_payment.rs (line 35)
13async fn main() {
14    // Generate testnet credentials.
15    let creds_one = testnet::get_testnet_credentials()
16        .await
17        .expect("error generating testnet credentials");
18    println!("Created account: {:?}", creds_one);
19
20    // Create a new XRPL client with the HTTP transport pointed at ripple testnet.
21    let xrpl = XRPL::new(
22        HTTP::builder()
23            .with_endpoint("https://s.altnet.rippletest.net:51234/")
24            .unwrap()
25            .build()
26            .unwrap(),
27    );
28
29    // Create wallet from secret
30    let mut wallet =
31        Wallet::from_secret(&creds_one.account.secret).unwrap();
32
33    // Create a payment transaction.
34    let mut payment = Payment::default();
35    payment.amount = CurrencyAmount::xrp(100000000);
36    payment.destination = "rp7pmm4rzTGmtZDuvrG1z9Xrm3KwHRipDw".to_owned(); // Set the destination to the second account.
37
38    // Convert the payment into a transaction.
39    let mut tx = payment.into_transaction();
40
41    let tx_blob = wallet.fill_and_sign(&mut tx, &xrpl).await.unwrap();
42
43    println!("Transaction: {:?}", tx);
44
45    // Create a sign_and_submit request.
46    let mut submit_req = SubmitRequest::default();
47    submit_req.tx_blob = tx_blob;
48
49    // Submit the transaction to the ledger.
50    let submit_res = xrpl
51        .submit(submit_req)
52        .await
53        .expect("failed to make submit request");
54    println!("Got response to submit request: {:?}", submit_res);
55
56    // Create an account info request to see the balance of account two.
57    let mut req = AccountInfoRequest::default();
58    // Set the account to the second set of testnet credentials.
59    req.account = "rp7pmm4rzTGmtZDuvrG1z9Xrm3KwHRipDw".to_owned();
60    // Fetch the account info for an address.
61    let account_info = xrpl
62        .account_info(req)
63        .await
64        .expect("failed to make account_info request");
65    // Print the account and balance
66    println!(
67        "Address {} has balance of {:?}",
68        account_info.account_data.account, account_info.account_data.balance
69    );
70}
Source

pub fn issued_currency(value: Decimal, currency: &str, issuer: &Address) -> Self

Trait Implementations§

Source§

impl Clone for CurrencyAmount

Source§

fn clone(&self) -> CurrencyAmount

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CurrencyAmount

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CurrencyAmount

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for CurrencyAmount

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for CurrencyAmount

Source§

fn eq(&self, other: &CurrencyAmount) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for CurrencyAmount

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for CurrencyAmount

Source§

impl StructuralPartialEq for CurrencyAmount

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,