diff --git a/package.json b/package.json index b1fb2cf6..88438529 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "bundle": "yarn redocly bundle -o ./blockfrost-openapi.yaml src/definitions.yaml && yarn openapi-merge-cli && yarn redocly bundle -o ./openapi.json ./openapi.yaml && yarn copy-spec && yarn build:midnight-docs", "build:midnight-docs": "yarn spectaql ./spectaql.yaml && cp ./midnight-indexer-api.graphql ./docs/midnight/midnight-indexer-api.graphql", "generate-types": "yarn openapi-typescript ./openapi.yaml --output ./src/generated-types.ts", - "generate-types:rust": "openapi-generator-cli generate -i openapi.yaml -g rust -o ./rust -c rust/openapi-generator.json -t rust/templates --global-property models,modelDocs=false,apis=false,apiDocs=false,supportingFiles && node rust/fix-cargo.js", + "generate-types:rust": "rimraf ./rust/src/models && openapi-generator-cli generate -i openapi.yaml -g rust -o ./rust -c rust/openapi-generator.json -t rust/templates --global-property models,modelDocs=false,apis=false,apiDocs=false,supportingFiles && node rust/fix-cargo.js", "generate-json-schema": "node lib/scripts/generate-json-schema.js > json-schema.json", "sync-version": "ts-node ./src/scripts/sync-version.ts", "test": "vitest", diff --git a/rust/Cargo.lock b/rust/Cargo.lock index fb546f25..e14db339 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -31,7 +31,7 @@ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "blockfrost-openapi" -version = "0.1.88" +version = "0.1.90" dependencies = [ "serde", "serde_json", diff --git a/rust/Cargo.toml b/rust/Cargo.toml index f8f1962f..d9d1d966 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "blockfrost-openapi" -version = "0.1.88" +version = "0.1.90" authors = ["contact@blockfrost.io"] description = "Blockfrost OpenAPI types for Cardano" license = "MIT" diff --git a/rust/README.md b/rust/README.md index 95080ed8..1817429d 100644 --- a/rust/README.md +++ b/rust/README.md @@ -240,8 +240,8 @@ For more information, please visit [https://blockfrost.io](https://blockfrost.io This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://openapis.org) from a remote server, you can easily generate an API client. -- API version: 0.1.88 -- Package version: 0.1.88 +- API version: 0.1.90 +- Package version: 0.1.90 - Generator version: 7.20.0 - Build package: `org.openapitools.codegen.languages.RustClientCodegen` @@ -322,10 +322,11 @@ Class | Method | HTTP request | Description - [Drep](docs/Drep.md) - [DrepDelegatorsInner](docs/DrepDelegatorsInner.md) - [DrepMetadata](docs/DrepMetadata.md) - - [DrepMetadataError](docs/DrepMetadataError.md) - [DrepUpdatesInner](docs/DrepUpdatesInner.md) - [DrepVotesInner](docs/DrepVotesInner.md) - [DrepsInner](docs/DrepsInner.md) + - [DrepsInnerMetadata](docs/DrepsInnerMetadata.md) + - [DrepsInnerMetadataError](docs/DrepsInnerMetadataError.md) - [EpochContent](docs/EpochContent.md) - [EpochParamContent](docs/EpochParamContent.md) - [EpochSettingsMessage](docs/EpochSettingsMessage.md) @@ -398,6 +399,7 @@ Class | Method | HTTP request | Description - [ScriptDatumCbor](docs/ScriptDatumCbor.md) - [ScriptJson](docs/ScriptJson.md) - [ScriptRedeemersInner](docs/ScriptRedeemersInner.md) + - [ScriptUtxosInner](docs/ScriptUtxosInner.md) - [ScriptsInner](docs/ScriptsInner.md) - [Signer](docs/Signer.md) - [SignerRegistrationsListItemMessage](docs/SignerRegistrationsListItemMessage.md) diff --git a/rust/src/models/_pools__pool_id__metadata_get_200_response.rs b/rust/src/models/_pools__pool_id__metadata_get_200_response.rs index db61c454..d6a2f80e 100644 --- a/rust/src/models/_pools__pool_id__metadata_get_200_response.rs +++ b/rust/src/models/_pools__pool_id__metadata_get_200_response.rs @@ -16,7 +16,7 @@ pub struct PoolsPoolIdMetadataGet200Response { #[serde(rename = "hash", deserialize_with = "Option::deserialize")] pub hash: Option, #[serde(rename = "error", skip_serializing_if = "Option::is_none")] - pub error: Option>, + pub error: Option>, /// Ticker of the stake pool #[serde(rename = "ticker", deserialize_with = "Option::deserialize")] pub ticker: Option, diff --git a/rust/src/models/drep.rs b/rust/src/models/drep.rs index 89413744..3c3be6d6 100644 --- a/rust/src/models/drep.rs +++ b/rust/src/models/drep.rs @@ -18,13 +18,13 @@ pub struct Drep { /// Epoch of the most recent registration #[serde(rename = "active_epoch", deserialize_with = "Option::deserialize")] pub active_epoch: Option, - /// Flag which shows if this DRep credentials are a script hash + /// Flag indicating whether this DRep's credential is a script hash #[serde(rename = "has_script")] pub has_script: bool, /// Registration state of the DRep. Set to `true` if the DRep has been deregistered; otherwise, `false`. #[serde(rename = "retired")] pub retired: bool, - /// Whether the DRep has been inactive for a consecutive number of epochs (determined by a epoch parameter `drep_activity`) + /// Whether the DRep has been inactive for a consecutive number of epochs (determined by an epoch parameter `drep_activity`) #[serde(rename = "expired")] pub expired: bool, /// Epoch of the most recent action - registration, update, deregistration or voting diff --git a/rust/src/models/drep_metadata.rs b/rust/src/models/drep_metadata.rs index 8d28bb4a..0d5a5e9e 100644 --- a/rust/src/models/drep_metadata.rs +++ b/rust/src/models/drep_metadata.rs @@ -22,7 +22,7 @@ pub struct DrepMetadata { #[serde(rename = "bytes", deserialize_with = "Option::deserialize")] pub bytes: Option, #[serde(rename = "error", skip_serializing_if = "Option::is_none")] - pub error: Option>, + pub error: Option>, } impl DrepMetadata { diff --git a/rust/src/models/dreps_inner.rs b/rust/src/models/dreps_inner.rs index d1740281..cf9efc86 100644 --- a/rust/src/models/dreps_inner.rs +++ b/rust/src/models/dreps_inner.rs @@ -9,13 +9,36 @@ pub struct DrepsInner { /// The raw bytes of the DRep #[serde(rename = "hex")] pub hex: String, + /// The total amount of voting power this DRep is delegated. + #[serde(rename = "amount")] + pub amount: String, + /// Flag indicating whether this DRep's credential is a script hash + #[serde(rename = "has_script")] + pub has_script: bool, + /// Registration state of the DRep. Set to `true` if the DRep has been deregistered; otherwise, `false`. + #[serde(rename = "retired")] + pub retired: bool, + /// Whether the DRep has been inactive for a consecutive number of epochs (determined by an epoch parameter `drep_activity`) + #[serde(rename = "expired")] + pub expired: bool, + /// Epoch of the most recent action - registration, update, deregistration or voting + #[serde(rename = "last_active_epoch", deserialize_with = "Option::deserialize")] + pub last_active_epoch: Option, + #[serde(rename = "metadata", deserialize_with = "Option::deserialize")] + pub metadata: Option>, } impl DrepsInner { - pub fn new(drep_id: String, hex: String) -> DrepsInner { + pub fn new(drep_id: String, hex: String, amount: String, has_script: bool, retired: bool, expired: bool, last_active_epoch: Option, metadata: Option) -> DrepsInner { DrepsInner { drep_id, hex, + amount, + has_script, + retired, + expired, + last_active_epoch, + metadata: if let Some(x) = metadata {Some(Box::new(x))} else {None}, } } } diff --git a/rust/src/models/dreps_inner_metadata.rs b/rust/src/models/dreps_inner_metadata.rs new file mode 100644 index 00000000..5088e6e3 --- /dev/null +++ b/rust/src/models/dreps_inner_metadata.rs @@ -0,0 +1,35 @@ +use crate::models; +use serde::{Deserialize, Serialize}; + +/// DrepsInnerMetadata : Off-chain metadata associated with the DRep's latest registration. `null` when the DRep has no registration anchor (e.g. special DReps such as `drep_always_abstain` / `drep_always_no_confidence`). When an anchor exists but the off-chain content could not be fetched or validated, `error` is populated and `json_metadata` / `bytes` are `null`. +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct DrepsInnerMetadata { + /// URL to the drep metadata + #[serde(rename = "url")] + pub url: String, + /// Hash of the metadata file + #[serde(rename = "hash")] + pub hash: String, + /// Content of the JSON metadata (validated CIP-119) + #[serde(rename = "json_metadata", deserialize_with = "Option::deserialize")] + pub json_metadata: Option, + /// Content of the metadata (raw) + #[serde(rename = "bytes", deserialize_with = "Option::deserialize")] + pub bytes: Option, + #[serde(rename = "error", skip_serializing_if = "Option::is_none")] + pub error: Option>, +} + +impl DrepsInnerMetadata { + /// Off-chain metadata associated with the DRep's latest registration. `null` when the DRep has no registration anchor (e.g. special DReps such as `drep_always_abstain` / `drep_always_no_confidence`). When an anchor exists but the off-chain content could not be fetched or validated, `error` is populated and `json_metadata` / `bytes` are `null`. + pub fn new(url: String, hash: String, json_metadata: Option, bytes: Option) -> DrepsInnerMetadata { + DrepsInnerMetadata { + url, + hash, + json_metadata, + bytes, + error: None, + } + } +} + diff --git a/rust/src/models/drep_metadata_error.rs b/rust/src/models/dreps_inner_metadata_error.rs similarity index 79% rename from rust/src/models/drep_metadata_error.rs rename to rust/src/models/dreps_inner_metadata_error.rs index 266b1e28..9e176530 100644 --- a/rust/src/models/drep_metadata_error.rs +++ b/rust/src/models/dreps_inner_metadata_error.rs @@ -1,9 +1,9 @@ use crate::models; use serde::{Deserialize, Serialize}; -/// DrepMetadataError : Present when metadata could not be fetched or validated. +/// DrepsInnerMetadataError : Present when metadata could not be fetched or validated. #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct DrepMetadataError { +pub struct DrepsInnerMetadataError { /// Stable machine-readable error code. #[serde(rename = "code")] pub code: Code, @@ -12,10 +12,10 @@ pub struct DrepMetadataError { pub message: String, } -impl DrepMetadataError { +impl DrepsInnerMetadataError { /// Present when metadata could not be fetched or validated. - pub fn new(code: Code, message: String) -> DrepMetadataError { - DrepMetadataError { + pub fn new(code: Code, message: String) -> DrepsInnerMetadataError { + DrepsInnerMetadataError { code, message, } diff --git a/rust/src/models/mod.rs b/rust/src/models/mod.rs index 8dd22df6..44b04f0d 100644 --- a/rust/src/models/mod.rs +++ b/rust/src/models/mod.rs @@ -116,14 +116,16 @@ pub mod drep_delegators_inner; pub use self::drep_delegators_inner::DrepDelegatorsInner; pub mod drep_metadata; pub use self::drep_metadata::DrepMetadata; -pub mod drep_metadata_error; -pub use self::drep_metadata_error::DrepMetadataError; pub mod drep_updates_inner; pub use self::drep_updates_inner::DrepUpdatesInner; pub mod drep_votes_inner; pub use self::drep_votes_inner::DrepVotesInner; pub mod dreps_inner; pub use self::dreps_inner::DrepsInner; +pub mod dreps_inner_metadata; +pub use self::dreps_inner_metadata::DrepsInnerMetadata; +pub mod dreps_inner_metadata_error; +pub use self::dreps_inner_metadata_error::DrepsInnerMetadataError; pub mod epoch_content; pub use self::epoch_content::EpochContent; pub mod epoch_param_content; @@ -268,6 +270,8 @@ pub mod script_json; pub use self::script_json::ScriptJson; pub mod script_redeemers_inner; pub use self::script_redeemers_inner::ScriptRedeemersInner; +pub mod script_utxos_inner; +pub use self::script_utxos_inner::ScriptUtxosInner; pub mod scripts_inner; pub use self::scripts_inner::ScriptsInner; pub mod signer; diff --git a/rust/src/models/pool_list_extended_inner_metadata.rs b/rust/src/models/pool_list_extended_inner_metadata.rs index 7fb336ea..1ed58421 100644 --- a/rust/src/models/pool_list_extended_inner_metadata.rs +++ b/rust/src/models/pool_list_extended_inner_metadata.rs @@ -10,7 +10,7 @@ pub struct PoolListExtendedInnerMetadata { #[serde(rename = "hash", deserialize_with = "Option::deserialize")] pub hash: Option, #[serde(rename = "error", skip_serializing_if = "Option::is_none")] - pub error: Option>, + pub error: Option>, /// Ticker of the stake pool #[serde(rename = "ticker", deserialize_with = "Option::deserialize")] pub ticker: Option, diff --git a/rust/src/models/pool_metadata.rs b/rust/src/models/pool_metadata.rs index 25ebac35..4e3d0474 100644 --- a/rust/src/models/pool_metadata.rs +++ b/rust/src/models/pool_metadata.rs @@ -16,7 +16,7 @@ pub struct PoolMetadata { #[serde(rename = "hash", deserialize_with = "Option::deserialize")] pub hash: Option, #[serde(rename = "error", skip_serializing_if = "Option::is_none")] - pub error: Option>, + pub error: Option>, /// Ticker of the stake pool #[serde(rename = "ticker", deserialize_with = "Option::deserialize")] pub ticker: Option, diff --git a/rust/src/models/proposal_metadata_v2.rs b/rust/src/models/proposal_metadata_v2.rs index c1154aa9..b03ab016 100644 --- a/rust/src/models/proposal_metadata_v2.rs +++ b/rust/src/models/proposal_metadata_v2.rs @@ -25,7 +25,7 @@ pub struct ProposalMetadataV2 { #[serde(rename = "bytes", deserialize_with = "Option::deserialize")] pub bytes: Option, #[serde(rename = "error", skip_serializing_if = "Option::is_none")] - pub error: Option>, + pub error: Option>, } impl ProposalMetadataV2 { diff --git a/rust/src/models/proposal_metadata_v2_error.rs b/rust/src/models/proposal_metadata_v2_error.rs deleted file mode 100644 index a5b8e98c..00000000 --- a/rust/src/models/proposal_metadata_v2_error.rs +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Blockfrost.io ~ API Documentation - * - * Blockfrost is an API as a service that allows users to interact with the Cardano blockchain and parts of its ecosystem. ## Tokens After signing up on https://blockfrost.io, a `project_id` token is automatically generated for each project. HTTP header of your request MUST include this `project_id` in order to authenticate against Blockfrost servers. ## Available networks At the moment, you can use the following networks. Please, note that each network has its own `project_id`.
Network Endpoint
Cardano mainnet https://cardano-mainnet.blockfrost.io/api/v0
Cardano preprod https://cardano-preprod.blockfrost.io/api/v0
Cardano preview https://cardano-preview.blockfrost.io/api/v0
InterPlanetary File System https://ipfs.blockfrost.io/api/v0
## Concepts * All endpoints return either a JSON object or an array. * Data is returned in *ascending* (oldest first, newest last) order, if not stated otherwise. * You might use the `?order=desc` query parameter to reverse this order. * By default, we return 100 results at a time. You have to use `?page=2` to list through the results. * All time and timestamp related fields (except `server_time`) are in seconds of UNIX time. * All amounts are returned in Lovelaces, where 1 ADA = 1 000 000 Lovelaces. * Addresses, accounts and pool IDs are in Bech32 format. * All values are case sensitive. * All hex encoded values are lower case. * Examples are not based on real data. Any resemblance to actual events is purely coincidental. * We allow to upload files up to 100MB of size to IPFS. This might increase in the future. * Only pinned IPFS files are counted towards the IPFS quota. * Non-pinned IPFS files are subject to regular garbage collection and will be removed unless pinned. * We allow maximum of 100 queued pins per IPFS user. ## Errors ### HTTP Status codes The following are HTTP status code your application might receive when reaching Blockfrost endpoints and it should handle all of these cases. * HTTP `400` return code is used when the request is not valid. * HTTP `402` return code is used when the projects exceed their daily request limit. * HTTP `403` return code is used when the request is not authenticated. * HTTP `404` return code is used when the resource doesn't exist. * HTTP `418` return code is used when the user has been auto-banned for flooding too much after previously receiving error code `402` or `429`. * HTTP `425` return code is used in Cardano networks, when the user has submitted a transaction when the mempool is already full, not accepting new txs straight away. * HTTP `425` return code is used in IPFS network, when the user has submitted a pin when the pin queue is already full, not accepting new pins straight away. * HTTP `429` return code is used when the user has sent too many requests in a given amount of time and therefore has been rate-limited. * HTTP `500` return code is used when our endpoints are having a problem. ### Error codes An internal error code number is used for better indication of the error in question. It is passed using the following payload. ```json { \"status_code\": 403, \"error\": \"Forbidden\", \"message\": \"Invalid project token.\" } ``` ## Limits There are two types of limits we are enforcing: The first depends on your plan and is the number of request we allow per day. We defined the day from midnight to midnight of UTC time. The second is rate limiting. We limit an end user, distinguished by IP address, to 10 requests per second. On top of that, we allow each user to send burst of 500 requests, which cools off at rate of 10 requests per second. In essence, a user is allowed to make another whole burst after (currently) 500/10 = 50 seconds. E.g. if a user attempts to make a call 3 seconds after whole burst, 30 requests will be processed. We believe this should be sufficient for most of the use cases. If it is not and you have a specific use case, please get in touch with us, and we will make sure to take it into account as much as we can. ## SDKs We support a number of SDKs that will help you in developing your application on top of Blockfrost.
Programming language SDK
JavaScript blockfrost-js
Haskell blockfrost-haskell
Python blockfrost-python
Rust blockfrost-rust
Golang blockfrost-go
Ruby blockfrost-ruby
Java blockfrost-java
Scala blockfrost-scala
Swift blockfrost-swift
Kotlin blockfrost-kotlin
Elixir blockfrost-elixir
.NET blockfrost-dotnet
Arduino blockfrost-arduino
PHP blockfrost-php
Crystal blockfrost-crystal
- * - * The version of the OpenAPI document: 0.1.83 - * Contact: contact@blockfrost.io - * Generated by: https://openapi-generator.tech - */ - -use crate::models; -use serde::{Deserialize, Serialize}; - -/// ProposalMetadataV2Error : Present when metadata could not be fetched or validated. -#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct ProposalMetadataV2Error { - /// Stable machine-readable error code. - #[serde(rename = "code")] - pub code: Code, - /// Human-readable description of the error. - #[serde(rename = "message")] - pub message: String, -} - -impl ProposalMetadataV2Error { - /// Present when metadata could not be fetched or validated. - pub fn new(code: Code, message: String) -> ProposalMetadataV2Error { - ProposalMetadataV2Error { - code, - message, - } - } -} -/// Stable machine-readable error code. -#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] -pub enum Code { - #[serde(rename = "HASH_MISMATCH")] - HashMismatch, - #[serde(rename = "CONNECTION_ERROR")] - ConnectionError, - #[serde(rename = "HTTP_RESPONSE_ERROR")] - HttpResponseError, - #[serde(rename = "DECODE_ERROR")] - DecodeError, - #[serde(rename = "SIZE_EXCEEDED")] - SizeExceeded, - #[serde(rename = "UNKNOWN_ERROR")] - UnknownError, -} - -impl Default for Code { - fn default() -> Code { - Self::HashMismatch - } -} - diff --git a/rust/src/models/script_utxos_inner.rs b/rust/src/models/script_utxos_inner.rs new file mode 100644 index 00000000..6abe93c9 --- /dev/null +++ b/rust/src/models/script_utxos_inner.rs @@ -0,0 +1,45 @@ +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ScriptUtxosInner { + /// Bech32 encoded address of the UTXO holding the reference script + #[serde(rename = "address")] + pub address: String, + /// Transaction hash of the UTXO + #[serde(rename = "tx_hash")] + pub tx_hash: String, + /// UTXO index in the transaction + #[serde(rename = "output_index")] + pub output_index: i32, + #[serde(rename = "amount")] + pub amount: Vec, + /// Block hash of the UTXO + #[serde(rename = "block")] + pub block: String, + /// The hash of the transaction output datum + #[serde(rename = "data_hash", deserialize_with = "Option::deserialize")] + pub data_hash: Option, + /// CBOR encoded inline datum + #[serde(rename = "inline_datum", deserialize_with = "Option::deserialize")] + pub inline_datum: Option, + /// The hash of the reference script of the output. Equals the queried script hash. + #[serde(rename = "reference_script_hash")] + pub reference_script_hash: String, +} + +impl ScriptUtxosInner { + pub fn new(address: String, tx_hash: String, output_index: i32, amount: Vec, block: String, data_hash: Option, inline_datum: Option, reference_script_hash: String) -> ScriptUtxosInner { + ScriptUtxosInner { + address, + tx_hash, + output_index, + amount, + block, + data_hash, + inline_datum, + reference_script_hash, + } + } +} +