| Crates.io | sanctum-solana-serde |
| lib.rs | sanctum-solana-serde |
| version | 1.0.1 |
| created_at | 2023-12-11 04:13:05.169174+00 |
| updated_at | 2024-01-17 06:55:33.867669+00 |
| description | Collection of newtypes for common solana types to implement serde on for easy use in web applications |
| homepage | |
| repository | https://github.com/igneous-labs/sanctum-solana-serde.git |
| max_upload_size | |
| id | 1064729 |
| size | 23,316 |
Collection of newtypes for common solana types to implement serde on for easy use in web applications.
B64VersionedTx with Jupiter Swap APILet's say you're building an application that calls Jupiter Swap API's /swap endpoint. You can use B64VersionedTx to handle deserialization of the API response for you:
use sanctum_solana_serde::b64_versioned_tx::B64VersionedTx;
use serde::Deserialize;
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct JupSwapResp {
pub swap_transaction: B64VersionedTx,
pub last_valid_block_height: u64, // note: jup API serializes this as a json number, not a string
}
use reqwest::Client;
use solana_sdk::transaction::VersionedTransaction;
async fn get_swap_tx_from_jup(
client: &Client,
post_params: serde_json::Value
) -> VersionedTransaction {
let JupSwapResp {
swap_transaction,
..
} = client.post("https://quote-api.jup.ag/v6/swap")
.json(post_params)
.send()
.await
.unwrap()
.json()
.await
.unwrap();
swap_transaction.0
}
All individual newtypes are behind their own individual feature flag. All of them are enabled by default.
utoipaThe non-default utoipa feature implements utoipa::ToSchema for all the newtypes, allowing you to document them in openAPI/Swagger docs generated by utoipa.