Skip to content

Commit 14e22b5

Browse files
Merge pull request #51 from SupernaviX/add-transactions-cbor
Add transactions cbor
2 parents b78a9da + ffb40ae commit 14e22b5

File tree

6 files changed

+107
-60
lines changed

6 files changed

+107
-60
lines changed

Cargo.lock

+33-20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ repository = "https://github.com/blockfrost/blockfrost-rust"
1010
homepage = "https://blockfrost.io"
1111

1212
[dependencies]
13-
blockfrost-openapi = { version = "0.0.3" }
13+
blockfrost-openapi = "0.1.69"
1414
futures = "0.3.30"
1515
reqwest = { version = "0.12.7", default-features = false, features = [
1616
"http2",

src/api/endpoints/accounts.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ mod tests {
123123
"reserves_sum": "319154618165",
124124
"treasury_sum": "12000000",
125125
"withdrawable_amount": "319154618165",
126-
"pool_id": "pool1pu5jlj4q9w9jlxeu370a3c9myx47md5j5m2str0naunn2q3lkdy"
126+
"pool_id": "pool1pu5jlj4q9w9jlxeu370a3c9myx47md5j5m2str0naunn2q3lkdy",
127+
"drep_id": "drep124w9k5ml25kcshqet8r3g2pwk6kqdhj79thg2rphf5u5urve0an"
127128
});
128129

129130
serde_json::from_value::<AccountContent>(json_value).unwrap();

src/api/endpoints/epochs.rs

+61-34
Original file line numberDiff line numberDiff line change
@@ -97,40 +97,67 @@ mod tests {
9797

9898
#[tokio::test]
9999
async fn test_epochs_latest_parameters() {
100-
let json_value = json!({
101-
"epoch": 225,
102-
"min_fee_a": 44,
103-
"min_fee_b": 155381,
104-
"max_block_size": 65536,
105-
"max_tx_size": 16384,
106-
"max_block_header_size": 1100,
107-
"key_deposit": "2000000",
108-
"pool_deposit": "500000000",
109-
"e_max": 18,
110-
"n_opt": 150,
111-
"a0": 0.3,
112-
"rho": 0.003,
113-
"tau": 0.2,
114-
"decentralisation_param": 0.5,
115-
"extra_entropy": null,
116-
"protocol_major_ver": 2,
117-
"protocol_minor_ver": 0,
118-
"min_utxo": "1000000",
119-
"min_pool_cost": "340000000",
120-
"nonce": "1a3be38bcbb7911969283716ad7aa550250226b76a61fc51cc9a9a35d9276d81",
121-
"price_mem": 0.001,
122-
"price_step": 0.01,
123-
"max_tx_ex_mem": "11000000000",
124-
"max_tx_ex_steps": "11000000000",
125-
"max_block_ex_mem": "110000000000",
126-
"max_block_ex_steps": "110000000000",
127-
"max_val_size": "5000",
128-
"collateral_percent": 15,
129-
"max_collateral_inputs": 6,
130-
"coins_per_utxo_word": "34482",
131-
"cost_models": null,
132-
"coins_per_utxo_size": "34482"
133-
});
100+
// not building with `json!` macro because this payload is too big
101+
let mut json_value = serde_json::Map::new();
102+
json_value.insert("epoch".to_string(), json!(225));
103+
json_value.insert("min_fee_a".to_string(), json!(44));
104+
json_value.insert("min_fee_b".to_string(), json!(155381));
105+
json_value.insert("max_block_size".to_string(), json!(65536));
106+
json_value.insert("max_tx_size".to_string(), json!(16384));
107+
json_value.insert("max_block_header_size".to_string(), json!(1100));
108+
json_value.insert("key_deposit".to_string(), json!("2000000"));
109+
json_value.insert("pool_deposit".to_string(), json!("500000000"));
110+
json_value.insert("e_max".to_string(), json!(18));
111+
json_value.insert("n_opt".to_string(), json!(150));
112+
json_value.insert("a0".to_string(), json!(0.3));
113+
json_value.insert("rho".to_string(), json!(0.003));
114+
json_value.insert("tau".to_string(), json!(0.2));
115+
json_value.insert("decentralisation_param".to_string(), json!(0.5));
116+
json_value.insert("extra_entropy".to_string(), json!(null));
117+
json_value.insert("protocol_major_ver".to_string(), json!(2));
118+
json_value.insert("protocol_minor_ver".to_string(), json!(0));
119+
json_value.insert("min_utxo".to_string(), json!("1000000"));
120+
json_value.insert("min_pool_cost".to_string(), json!("340000000"));
121+
json_value.insert(
122+
"nonce".to_string(),
123+
json!("1a3be38bcbb7911969283716ad7aa550250226b76a61fc51cc9a9a35d9276d81"),
124+
);
125+
json_value.insert("price_mem".to_string(), json!(0.001));
126+
json_value.insert("price_step".to_string(), json!(0.01));
127+
json_value.insert("max_tx_ex_mem".to_string(), json!("11000000000"));
128+
json_value.insert("max_tx_ex_steps".to_string(), json!("11000000000"));
129+
json_value.insert("max_block_ex_mem".to_string(), json!("110000000000"));
130+
json_value.insert("max_block_ex_steps".to_string(), json!("110000000000"));
131+
json_value.insert("max_val_size".to_string(), json!("5000"));
132+
json_value.insert("collateral_percent".to_string(), json!(15));
133+
json_value.insert("max_collateral_inputs".to_string(), json!(6));
134+
json_value.insert("coins_per_utxo_word".to_string(), json!("34482"));
135+
json_value.insert("cost_models".to_string(), json!(null));
136+
json_value.insert("coins_per_utxo_size".to_string(), json!("34482"));
137+
json_value.insert("pvt_motion_no_confidence".to_string(), json!(null));
138+
json_value.insert("pvt_committee_normal".to_string(), json!(null));
139+
json_value.insert("pvt_committee_no_confidence".to_string(), json!(null));
140+
json_value.insert("pvt_hard_fork_initiation".to_string(), json!(null));
141+
json_value.insert("dvt_motion_no_confidence".to_string(), json!(null));
142+
json_value.insert("dvt_committee_normal".to_string(), json!(null));
143+
json_value.insert("dvt_committee_no_confidence".to_string(), json!(null));
144+
json_value.insert("dvt_update_to_constitution".to_string(), json!(null));
145+
json_value.insert("dvt_hard_fork_initiation".to_string(), json!(null));
146+
json_value.insert("dvt_p_p_network_group".to_string(), json!(null));
147+
json_value.insert("dvt_p_p_economic_group".to_string(), json!(null));
148+
json_value.insert("dvt_p_p_technical_group".to_string(), json!(null));
149+
json_value.insert("dvt_p_p_gov_group".to_string(), json!(null));
150+
json_value.insert("dvt_treasury_withdrawal".to_string(), json!(null));
151+
json_value.insert("committee_min_size".to_string(), json!(null));
152+
json_value.insert("committee_max_term_length".to_string(), json!(null));
153+
json_value.insert("gov_action_lifetime".to_string(), json!(null));
154+
json_value.insert("gov_action_deposit".to_string(), json!(null));
155+
json_value.insert("drep_deposit".to_string(), json!(null));
156+
json_value.insert("drep_activity".to_string(), json!(null));
157+
json_value.insert("pvtpp_security_group".to_string(), json!(null));
158+
json_value.insert("pvt_p_p_security_group".to_string(), json!(null));
159+
json_value.insert("min_fee_ref_script_cost_per_byte".to_string(), json!(null));
160+
let json_value = serde_json::Value::Object(json_value);
134161

135162
serde_json::from_value::<EpochParamContent>(json_value).unwrap();
136163
}

src/api/endpoints/nutlink.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use crate::*;
22
use blockfrost_openapi::models::{
33
nutlink_address::NutlinkAddress, nutlink_address_ticker_inner::NutlinkAddressTickerInner,
4-
nutlink_address_ticker_inner_payload::NutlinkAddressTickerInnerPayload,
54
nutlink_address_tickers_inner::NutlinkAddressTickersInner,
5+
nutlink_tickers_ticker_inner::NutlinkTickersTickerInner,
66
};
77

88
impl BlockfrostAPI {
@@ -20,7 +20,7 @@ impl BlockfrostAPI {
2020

2121
pub async fn nutlink_address_ticker_by_id(
2222
&self, address: &str, ticker: &str, pagination: Pagination,
23-
) -> BlockfrostResult<Vec<NutlinkAddressTickerInnerPayload>> {
23+
) -> BlockfrostResult<Vec<NutlinkAddressTickerInner>> {
2424
self.call_paged_endpoint(
2525
format!("/nutlink/{}/tickers/{}", address, ticker).as_str(),
2626
pagination,
@@ -30,7 +30,7 @@ impl BlockfrostAPI {
3030

3131
pub async fn nutlink_ticker_by_id(
3232
&self, ticker: &str, pagination: Pagination,
33-
) -> BlockfrostResult<Vec<NutlinkAddressTickerInner>> {
33+
) -> BlockfrostResult<Vec<NutlinkTickersTickerInner>> {
3434
self.call_paged_endpoint(format!("/nutlink/tickers/{}", ticker).as_str(), pagination)
3535
.await
3636
}

src/api/endpoints/transactions.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::{request::send_request, url::Url, *};
22
use blockfrost_openapi::models::{
3-
tx_content::TxContent, tx_content_delegations_inner::TxContentDelegationsInner,
3+
tx_content::TxContent, tx_content_cbor::TxContentCbor,
4+
tx_content_delegations_inner::TxContentDelegationsInner,
45
tx_content_metadata_cbor_inner::TxContentMetadataCborInner,
56
tx_content_metadata_inner::TxContentMetadataInner, tx_content_mirs_inner::TxContentMirsInner,
67
tx_content_pool_retires_inner::TxContentPoolRetiresInner,
@@ -104,6 +105,11 @@ impl BlockfrostAPI {
104105
.await
105106
}
106107

108+
pub async fn transactions_cbor(&self, hash: &str) -> BlockfrostResult<TxContentCbor> {
109+
self.call_endpoint(format!("/txs/{}/cbor", hash).as_str())
110+
.await
111+
}
112+
107113
pub async fn transactions_redeemers(
108114
&self, hash: &str,
109115
) -> BlockfrostResult<Vec<TxContentRedeemersInner>> {

0 commit comments

Comments
 (0)