Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: chang compatibility #26

Merged
merged 5 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
- name: Build
run: cargo build --verbose
- name: Publish to crates.io
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: cargo publish --token ${CRATES_TOKEN}
env:
CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}
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-rust-sdk"
version = "1.1.3"
version = "1.2.2"
description = "Rust SDK for the Maestro Dapp Platform"
repository = "https://github.com/maestro-org/rust-sdk"
documentation = "https://docs.gomaestro.org/"
Expand Down
8 changes: 4 additions & 4 deletions src/client/general.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::maestro::Maestro;
use crate::models::{
common::BasicResponse,
general::{ChainTip, EraHistory, ProtocolParameters},
general::{ChainTip, EraSummaries, ProtocolParameters},
};
use std::error::Error;

Expand All @@ -13,15 +13,15 @@ impl Maestro {
Ok(chain_tip)
}

pub async fn era_history(&self) -> Result<EraHistory, Box<dyn Error>> {
let url = "/era-history";
pub async fn era_history(&self) -> Result<EraSummaries, Box<dyn Error>> {
let url = "/era-summaries";
let resp = self.get(url).await?;
let era_history = serde_json::from_str(&resp).map_err(|e| Box::new(e) as Box<dyn Error>)?;
Ok(era_history)
}

pub async fn protocol_parameters(&self) -> Result<ProtocolParameters, Box<dyn Error>> {
let url = "/protocol-params";
let url = "/protocol-parameters";
let resp = self.get(url).await?;
let protocol_params =
serde_json::from_str(&resp).map_err(|e| Box::new(e) as Box<dyn Error>)?;
Expand Down
73 changes: 45 additions & 28 deletions src/models/general.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,57 +36,74 @@ pub struct Era {
}

#[derive(Deserialize, Debug, Clone)]
pub struct EraHistory {
pub struct EraSummaries {
pub data: Vec<Era>,
pub last_updated: utils::LastUpdated,
}

#[derive(Deserialize, Debug, Clone)]
pub struct ProtocolParameters {
pub data: ProtocolParams,
pub data: ProtocolParametersData,
pub last_updated: utils::LastUpdated,
}

#[derive(Deserialize, Debug, Clone)]
pub struct Bytes {
pub bytes: u64,
}

#[derive(Deserialize, Debug, Clone)]
pub struct ExUnits {
pub memory: i64,
pub steps: i64,
pub memory: u64,
pub cpu: u64,
}

#[derive(Deserialize, Debug, Clone)]
pub struct StringExUnits {
pub memory: String,
pub steps: String,
pub struct LovelaceAmount {
pub lovelace: u64,
}

#[derive(Deserialize, Debug, Clone)]
pub struct ProtocolVersion {
pub major: i64,
pub minor: i64,
pub major: u64,
pub minor: u64,
}

#[derive(Deserialize, Debug, Clone)]
pub struct PlutusCostModels {
pub plutus_v1: Vec<u64>,
pub plutus_v2: Vec<u64>,
}

#[derive(Deserialize, Debug, Clone)]
pub struct ScriptExecutionPrices {
pub memory: String,
pub cpu: String,
}

#[derive(Deserialize, Debug, Clone)]
pub struct ProtocolParams {
pub coins_per_utxo_byte: i64,
pub collateral_percentage: i64,
pub cost_models: serde_json::Value,
pub desired_number_of_pools: i64,
pub max_block_body_size: i64,
pub max_block_header_size: i64,
pub max_collateral_inputs: i64,
pub struct ProtocolParametersData {
pub collateral_percentage: u64,
pub desired_number_of_stake_pools: u64,
pub max_block_body_size: Bytes,
pub max_block_header_size: Bytes,
pub max_collateral_inputs: u64,
pub max_execution_units_per_block: ExUnits,
pub max_execution_units_per_transaction: ExUnits,
pub max_tx_size: i64,
pub max_value_size: i64,
pub min_fee_coefficient: i64,
pub min_fee_constant: i64,
pub min_pool_cost: i64,
pub max_transaction_size: Bytes,
pub max_value_size: Bytes,
pub min_fee_coefficient: u64,
pub min_fee_constant: LovelaceAmount,
pub min_stake_pool_cost: LovelaceAmount,
pub min_utxo_deposit_coefficient: u64,
pub min_utxo_deposit_constant: LovelaceAmount,
pub monetary_expansion: String,
pub pool_deposit: i64,
pub pool_influence: String,
pub pool_retirement_epoch_bound: i64,
pub prices: StringExUnits,
pub protocol_version: ProtocolVersion,
pub stake_key_deposit: i64,
pub plutus_cost_models: PlutusCostModels,
pub script_execution_prices: ScriptExecutionPrices,
pub stake_credential_deposit: LovelaceAmount,
pub stake_pool_deposit: LovelaceAmount,
pub stake_pool_pledge_influence: String,
pub stake_pool_retirement_epoch_bound: u64,
pub treasury_expansion: String,
pub version: ProtocolVersion,
}
2 changes: 0 additions & 2 deletions src/models/pools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ pub struct PoolMintedBlocks {

#[derive(Deserialize, Debug, Clone)]
pub struct StakePoolDelegator {
pub active_epoch_no: i64,
pub amount: String,
pub latest_delegation_tx_hash: String,
pub stake_address: String,
Expand Down Expand Up @@ -79,7 +78,6 @@ pub struct Relay {

#[derive(Deserialize, Debug, Clone)]
pub struct StakePoolDetails {
pub active_epoch_no: i64,
pub active_stake: i64,
pub block_count: i64,
pub fixed_cost: i64,
Expand Down
1 change: 1 addition & 0 deletions src/models/scripts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use serde::Serialize;
pub enum ScriptVersion {
PlutusV1,
PlutusV2,
PlutusV3,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
Expand Down
24 changes: 22 additions & 2 deletions src/models/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,24 @@ use super::{addresses::Utxo, scripts::Script};

#[derive(Deserialize, Debug, Clone)]
pub struct Certificates {
pub auth_committee_hot_certs: Vec<serde_json::Value>,
pub mir_transfers: Vec<serde_json::Value>,
pub pool_registrations: Vec<serde_json::Value>,
pub pool_retirements: Vec<serde_json::Value>,
pub reg_certs: Vec<serde_json::Value>,
pub reg_drep_certs: Vec<serde_json::Value>,
pub resign_committee_cold_certs: Vec<serde_json::Value>,
pub stake_delegations: Vec<serde_json::Value>,
pub stake_deregistrations: Vec<serde_json::Value>,
pub stake_registrations_reserves: Vec<serde_json::Value>,
pub stake_reg_delegations: Vec<serde_json::Value>,
pub stake_registrations: Vec<serde_json::Value>,
pub stake_vote_delegations: Vec<serde_json::Value>,
pub stake_vote_reg_delegations: Vec<serde_json::Value>,
pub unreg_certs: Vec<serde_json::Value>,
pub unreg_drep_certs: Vec<serde_json::Value>,
pub update_drep_certs: Vec<serde_json::Value>,
pub vote_delegations: Vec<serde_json::Value>,
pub vote_reg_delegations: Vec<serde_json::Value>,
}

#[derive(Deserialize, Debug, Clone)]
Expand All @@ -19,6 +31,14 @@ pub struct Redeemers {
pub mints: Vec<serde_json::Value>,
pub spends: Vec<serde_json::Value>,
pub withdrawals: Vec<serde_json::Value>,
pub votes: Vec<serde_json::Value>,
pub proposals: Vec<serde_json::Value>,
}

#[derive(Deserialize, Debug, Clone)]
pub struct MintAsset {
pub unit: String,
pub amount: serde_json::Value,
}

#[derive(Deserialize, Debug, Clone)]
Expand All @@ -38,7 +58,7 @@ pub struct TransactionDetail {
pub invalid_before: i64,
pub invalid_hereafter: i64,
pub metadata: serde_json::Value,
pub mint: Vec<serde_json::Value>,
pub mint: Vec<MintAsset>,
pub outputs: Vec<Utxo>,
pub redeemers: Vec<Redeemers>,
pub reference_inputs: Vec<serde_json::Value>,
Expand Down
Loading