Skip to content

Commit 7a0a46e

Browse files
committed
Implement revoke.
1 parent 0f61aca commit 7a0a46e

File tree

8 files changed

+700
-553
lines changed

8 files changed

+700
-553
lines changed

cli/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[package]
2-
name = "cli"
3-
version = "0.1.0"
2+
name = "zhuli"
3+
version = "1.0.0"
44
edition = "2021"
55

66
[dependencies]
77
bech32 = "0.11.0"
88
blockfrost = "1.0.1"
99
blockfrost-openapi = "0.0.3"
10-
clap = "4.5.17"
10+
clap = { version = "4.5.17", features = ["cargo"] }
1111
color-print = "0.3.6"
1212
hex = "0.4.3"
1313
indoc = "2.0.5"

cli/src/cardano.rs

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1+
use crate::pallas_extra::BuildParams;
12
use blockfrost::{BlockfrostAPI, Pagination};
23
use blockfrost_openapi::models::{
34
asset_history_inner::Action, tx_content_output_amount_inner::TxContentOutputAmountInner,
45
};
56
use pallas_addresses::Network;
67
use pallas_codec::{minicbor as cbor, utils::NonEmptyKeyValuePairs};
78
use pallas_primitives::conway::{
8-
AssetName, PolicyId, PostAlonzoTransactionOutput, TransactionInput, Tx, Value,
9+
AssetName, PolicyId, PostAlonzoTransactionOutput, TransactionInput, TransactionOutput, Tx,
10+
Value,
911
};
1012
use std::{collections::BTreeMap, env};
13+
use uplc::tx::ResolvedInput;
1114

1215
pub struct Cardano {
1316
api: BlockfrostAPI,
@@ -37,6 +40,17 @@ pub struct ProtocolParameters {
3740
pub price_steps: f64,
3841
}
3942

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+
4054
impl Cardano {
4155
pub fn new() -> Self {
4256
let project_id =
@@ -175,7 +189,17 @@ impl Cardano {
175189
}
176190
}
177191

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> {
179203
let utxo = self
180204
.api
181205
.transactions_utxos(hex::encode(input.transaction_id).as_str())
@@ -202,11 +226,14 @@ impl Cardano {
202226
"non-null datum hash about to be ignored"
203227
);
204228

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+
}),
210237
}
211238
})
212239
}

0 commit comments

Comments
 (0)