1
+ use crate :: pallas_extra:: BuildParams ;
1
2
use blockfrost:: { BlockfrostAPI , Pagination } ;
2
3
use blockfrost_openapi:: models:: {
3
4
asset_history_inner:: Action , tx_content_output_amount_inner:: TxContentOutputAmountInner ,
4
5
} ;
5
6
use pallas_addresses:: Network ;
6
7
use pallas_codec:: { minicbor as cbor, utils:: NonEmptyKeyValuePairs } ;
7
8
use pallas_primitives:: conway:: {
8
- AssetName , PolicyId , PostAlonzoTransactionOutput , TransactionInput , Tx , Value ,
9
+ AssetName , PolicyId , PostAlonzoTransactionOutput , TransactionInput , TransactionOutput , Tx ,
10
+ Value ,
9
11
} ;
10
12
use std:: { collections:: BTreeMap , env} ;
13
+ use uplc:: tx:: ResolvedInput ;
11
14
12
15
pub struct Cardano {
13
16
api : BlockfrostAPI ,
@@ -37,6 +40,17 @@ pub struct ProtocolParameters {
37
40
pub price_steps : f64 ,
38
41
}
39
42
43
+ impl From < & ProtocolParameters > for BuildParams {
44
+ fn from ( params : & ProtocolParameters ) -> BuildParams {
45
+ BuildParams {
46
+ fee_constant : params. fee_constant ,
47
+ fee_coefficient : params. fee_coefficient ,
48
+ price_mem : params. price_mem ,
49
+ price_steps : params. price_steps ,
50
+ }
51
+ }
52
+ }
53
+
40
54
impl Cardano {
41
55
pub fn new ( ) -> Self {
42
56
let project_id =
@@ -175,7 +189,17 @@ impl Cardano {
175
189
}
176
190
}
177
191
178
- pub async fn resolve ( & self , input : & TransactionInput ) -> Option < PostAlonzoTransactionOutput > {
192
+ pub async fn resolve_many ( & self , inputs : & [ & TransactionInput ] ) -> Vec < ResolvedInput > {
193
+ let mut resolved = vec ! [ ] ;
194
+ for i in inputs {
195
+ if let Some ( r) = self . resolve ( i) . await {
196
+ resolved. push ( r)
197
+ }
198
+ }
199
+ resolved
200
+ }
201
+
202
+ pub async fn resolve ( & self , input : & TransactionInput ) -> Option < ResolvedInput > {
179
203
let utxo = self
180
204
. api
181
205
. transactions_utxos ( hex:: encode ( input. transaction_id ) . as_str ( ) )
@@ -202,11 +226,14 @@ impl Cardano {
202
226
"non-null datum hash about to be ignored"
203
227
) ;
204
228
205
- PostAlonzoTransactionOutput {
206
- address : from_bech32 ( & o. address ) . into ( ) ,
207
- value : from_tx_content_output_amounts ( & o. amount [ ..] ) ,
208
- datum_option : None ,
209
- script_ref : None ,
229
+ ResolvedInput {
230
+ input : input. clone ( ) ,
231
+ output : TransactionOutput :: PostAlonzo ( PostAlonzoTransactionOutput {
232
+ address : from_bech32 ( & o. address ) . into ( ) ,
233
+ value : from_tx_content_output_amounts ( & o. amount [ ..] ) ,
234
+ datum_option : None ,
235
+ script_ref : None ,
236
+ } ) ,
210
237
}
211
238
} )
212
239
}
0 commit comments