1
1
use serde:: { Deserialize , Serialize } ;
2
- use xrpl_types:: { Currency , Offer } ;
2
+ use xrpl_types:: { Currency , CurrencySpec , Offer } ;
3
3
4
4
use crate :: Request ;
5
5
6
- #[ derive( Clone , Serialize ) ]
7
- pub struct CurrencyParams {
8
- pub currency : String , // TODO: hm, consider name.
9
- #[ serde( skip_serializing_if = "Option::is_none" ) ]
10
- pub issuer : Option < String > ,
11
- }
12
-
13
- impl Default for CurrencyParams {
14
- fn default ( ) -> Self {
15
- Self {
16
- currency : "XRP" . to_string ( ) ,
17
- issuer : None ,
18
- }
19
- }
20
- }
21
-
22
- impl CurrencyParams {
23
- pub fn from_currency ( c : & Currency ) -> Self {
24
- match c {
25
- Currency :: Xrp => CurrencyParams {
26
- currency : "XRP" . to_owned ( ) ,
27
- issuer : None ,
28
- } ,
29
- Currency :: Issued { name, issuer } => CurrencyParams {
30
- currency : name. clone ( ) ,
31
- issuer : Some ( issuer. clone ( ) ) ,
32
- } ,
33
- }
34
- }
35
- }
36
-
37
6
/// - https://xrpl.org/book_offers.html
38
7
#[ derive( Default , Clone , Serialize ) ]
39
8
pub struct BookOffersRequest {
@@ -45,8 +14,8 @@ pub struct BookOffersRequest {
45
14
limit : Option < u32 > ,
46
15
#[ serde( skip_serializing_if = "Option::is_none" ) ]
47
16
taker : Option < String > ,
48
- taker_gets : CurrencyParams ,
49
- taker_pays : CurrencyParams ,
17
+ taker_gets : CurrencySpec ,
18
+ taker_pays : CurrencySpec ,
50
19
}
51
20
52
21
impl Request for BookOffersRequest {
@@ -60,8 +29,8 @@ impl Request for BookOffersRequest {
60
29
impl BookOffersRequest {
61
30
pub fn new ( taker_gets : & Currency , taker_pays : & Currency ) -> Self {
62
31
Self {
63
- taker_gets : CurrencyParams :: from_currency ( taker_gets) ,
64
- taker_pays : CurrencyParams :: from_currency ( taker_pays) ,
32
+ taker_gets : CurrencySpec :: from_currency ( taker_gets) ,
33
+ taker_pays : CurrencySpec :: from_currency ( taker_pays) ,
65
34
..Default :: default ( )
66
35
}
67
36
}
0 commit comments