Skip to content

Commit

Permalink
Merge pull request #22 from sidan-lab/fix/post-duplicate-headers
Browse files Browse the repository at this point in the history
fix: remvoe duplicate header
  • Loading branch information
Vardominator authored Apr 11, 2024
2 parents 508cd20 + f9057b9 commit 831f54e
Show file tree
Hide file tree
Showing 20 changed files with 127 additions and 121 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "maestro"
version = "1.1.0"
version = "1.1.2"
edition = "2021"
license = "Apache-2.0"

Expand Down
8 changes: 4 additions & 4 deletions src/client/block_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ use crate::utils;
use serde::{Deserialize, Serialize};
use std::error::Error;

#[derive(Serialize, Deserialize)]
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct OperationalCertificate {
pub hot_vkey: String,
pub kes_period: i64,
pub kes_signature: String,
pub sequence_number: i64,
}

#[derive(Serialize, Deserialize)]
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct TotalExUnits {
pub mem: i64,
pub steps: i64,
}

#[derive(Serialize, Deserialize)]
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct BlockInfoData {
pub absolute_slot: i64,
pub block_producer: String,
Expand All @@ -40,7 +40,7 @@ pub struct BlockInfoData {
pub vrf_key: String,
}

#[derive(Deserialize)]
#[derive(Deserialize, Debug, Clone)]
pub struct BlockInfo {
pub data: BlockInfoData,
pub last_updated: utils::last_updated::LastUpdated,
Expand Down
4 changes: 2 additions & 2 deletions src/client/config.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use serde::Deserialize;

#[derive(Deserialize)]
#[derive(Deserialize, Debug, Clone)]
pub struct ClientConfig {
pub version: String,
pub timeout: i64,
}

#[derive(Deserialize)]
#[derive(Deserialize, Debug, Clone)]
pub struct Config {
pub client: ClientConfig,
}
Expand Down
2 changes: 1 addition & 1 deletion src/client/linear_vesting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::models::linear_vesting::{CollectTransaction, LockTransaction, Vesting
use serde::{Deserialize, Serialize};
use std::error::Error;

#[derive(Serialize, Deserialize)]
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct LockBody {
pub sender: String,
pub beneficiary: String,
Expand Down
2 changes: 0 additions & 2 deletions src/client/maestro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ impl Maestro {
let req = self
.http_client
.post(format!("{}{}", &self.base_url, url))
.header("Accept", "application/json")
.header("api-key", &self.api_key)
.header("Content-Type", "application/json")
.body(json_body);

Expand Down
17 changes: 9 additions & 8 deletions src/client/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use super::maestro::Maestro;
use crate::models::{
common::BasicResponse,
transactions::{
EvaluateTx, RedeemerEvaluation, TransactionDetails, TransactionOutputFromReference,
TransactionOutputsFromReferences,
AdditionalUtxo, EvaluateTx, RedeemerEvaluation, TransactionDetails,
TransactionOutputFromReference, TransactionOutputsFromReferences,
},
};
use std::{collections::HashMap, error::Error};
Expand Down Expand Up @@ -54,11 +54,12 @@ impl Maestro {
params: Option<HashMap<String, String>>,
) -> Result<TransactionOutputFromReference, Box<dyn Error>> {
let formatted_params = params.map_or("".to_string(), |p| {
"?".to_string() + p.iter()
.map(|(k, v)| format!("{}={}", k, v))
.collect::<Vec<String>>()
.join("&")
.as_str()
"?".to_string()
+ p.iter()
.map(|(k, v)| format!("{}={}", k, v))
.collect::<Vec<String>>()
.join("&")
.as_str()
});
let url = format!(
"/transactions/{}/outputs/{}/txo{}",
Expand Down Expand Up @@ -92,7 +93,7 @@ impl Maestro {
pub async fn evaluate_tx(
&self,
tx_cbor: &str,
additional_utxos: Vec<String>,
additional_utxos: Vec<AdditionalUtxo>,
) -> Result<Vec<RedeemerEvaluation>, Box<dyn Error>> {
let url = "/transactions/evaluate";
let body = EvaluateTx {
Expand Down
26 changes: 13 additions & 13 deletions src/models/accounts.rs
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
use crate::utils;
use serde::Deserialize;

#[derive(Deserialize)]
#[derive(Deserialize, Debug, Clone)]
pub struct AccountAddresses {
pub data: Vec<String>,
pub last_updated: utils::LastUpdated,
pub next_cursor: Option<String>,
}

#[derive(Deserialize)]
#[derive(Deserialize, Debug, Clone)]
pub struct AccountAsset {
pub amount: i64,
pub unit: String,
}

#[derive(Deserialize)]
#[derive(Deserialize, Debug, Clone)]
pub struct AccountAssets {
pub data: Vec<AccountAsset>,
pub last_updated: utils::LastUpdated,
pub next_cursor: Option<String>,
}

#[derive(Deserialize)]
#[derive(Deserialize, Debug, Clone)]
pub struct StakeAccountHistoryItem {
pub active_stake: i64,
pub epoch_no: i64,
pub pool_id: String,
}

#[derive(Deserialize)]
#[derive(Deserialize, Debug, Clone)]
pub struct StakeAccountHistory {
pub data: Vec<StakeAccountHistoryItem>,
pub last_updated: utils::LastUpdated,
pub next_cursor: Option<String>,
}

#[derive(Deserialize)]
#[derive(Deserialize, Debug, Clone)]
pub struct AccountInformation {
pub delegated_pool: String,
pub registered: bool,
Expand All @@ -47,20 +47,20 @@ pub struct AccountInformation {
pub utxo_balance: i64,
}

#[derive(Deserialize)]
#[derive(Deserialize, Debug, Clone)]
pub struct StakeAccountInformation {
pub data: AccountInformation,
pub last_updated: utils::LastUpdated,
}

#[derive(Deserialize)]
#[derive(Deserialize, Debug, Clone)]
pub enum StakeRewardType {
Member,
Leader,
Refund,
}

#[derive(Deserialize)]
#[derive(Deserialize, Debug, Clone)]
pub struct StakeAccountReward {
pub amount: i64,
pub earned_epoch: i64,
Expand All @@ -69,30 +69,30 @@ pub struct StakeAccountReward {
pub r#type: StakeRewardType,
}

#[derive(Deserialize)]
#[derive(Deserialize, Debug, Clone)]
pub struct StakeAccountRewards {
pub data: Vec<StakeAccountReward>,
pub last_updated: utils::LastUpdated,
pub next_cursor: Option<String>,
}

#[derive(Deserialize)]
#[derive(Deserialize, Debug, Clone)]
pub enum StakeUpdateAction {
Registration,
Deregistration,
Delegation,
Withdrawal,
}

#[derive(Deserialize)]
#[derive(Deserialize, Debug, Clone)]
pub struct StakeAccountUpdate {
pub absolute_slot: i64,
pub action: StakeUpdateAction,
pub epoch_no: i64,
pub tx_hash: String,
}

#[derive(Deserialize)]
#[derive(Deserialize, Debug, Clone)]
pub struct StakeAccountUpdates {
pub data: Vec<StakeAccountUpdate>,
pub last_updated: utils::LastUpdated,
Expand Down
30 changes: 15 additions & 15 deletions src/models/addresses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@ use crate::utils;
use serde::Deserialize;
use std::collections::HashMap;

#[derive(Deserialize)]
#[derive(Deserialize, Debug, Clone)]
pub enum Network {
Mainnet,
Testnet,
}

#[derive(Deserialize)]
#[derive(Deserialize, Debug, Clone)]
pub enum CredentialKind {
Key,
Script,
}

#[derive(Deserialize)]
#[derive(Deserialize, Debug, Clone)]
pub struct PaymentCredential {
pub bech32: String,
pub hex: String,
pub kind: CredentialKind,
}

#[derive(Deserialize)]
#[derive(Deserialize, Debug, Clone)]
pub struct StakingCredential {
pub bech32: String,
pub hex: String,
Expand All @@ -30,7 +30,7 @@ pub struct StakingCredential {
pub reward_address: String,
}

#[derive(Deserialize)]
#[derive(Deserialize, Debug, Clone)]
pub struct DecodedAddress {
pub bech32: String,
pub hex: String,
Expand All @@ -39,67 +39,67 @@ pub struct DecodedAddress {
pub staking_cred: StakingCredential,
}

#[derive(Deserialize)]
#[derive(Deserialize, Debug, Clone)]
pub struct AddressTransactionCount {
pub data: i32,
pub last_updated: utils::LastUpdated,
}

#[derive(Deserialize)]
#[derive(Deserialize, Debug, Clone)]
pub struct Transaction {
pub input: bool,
pub output: bool,
pub slot: i64,
pub tx_hash: String,
}

#[derive(Deserialize)]
#[derive(Deserialize, Debug, Clone)]
pub struct AddressTransactions {
pub data: Vec<Transaction>,
pub last_updated: utils::LastUpdated,
pub next_cursor: Option<String>,
}

#[derive(Deserialize)]
#[derive(Deserialize, Debug, Clone)]
pub struct UtxoReference {
pub index: i64,
pub tx_hash: String,
}

#[derive(Deserialize)]
#[derive(Deserialize, Debug, Clone)]
pub struct UtxoReferencesAtAddress {
pub data: Vec<UtxoReference>,
pub last_updated: utils::LastUpdated,
pub next_cursor: Option<String>,
}

#[derive(Deserialize)]
#[derive(Deserialize, Debug, Clone)]
pub struct Asset {
pub amount: i64,
pub unit: String,
}

#[derive(Deserialize)]
#[derive(Deserialize, Debug, Clone)]
pub struct Utxo {
pub address: String,
pub assets: Vec<Asset>,
pub datum: Option<HashMap<String, serde_json::Value>>,
pub index: i64,
pub reference_script: Option<ReferenceScript>,
pub tx_hash: String,
#[serde(alias="txout_cbor")]
#[serde(alias = "txout_cbor")]
pub tx_out_cbor: String,
}

#[derive(Deserialize)]
#[derive(Deserialize, Debug, Clone)]
pub struct ReferenceScript {
pub bytes: String,
pub hash: String,
pub json: Option<HashMap<String, serde_json::Value>>,
pub r#type: String,
}

#[derive(Deserialize)]
#[derive(Deserialize, Debug, Clone)]
pub struct UtxosAtAddress {
pub data: Vec<Utxo>,
pub last_updated: utils::LastUpdated,
Expand Down
Loading

0 comments on commit 831f54e

Please sign in to comment.