From 128c5b7b55203577df6280926eda08440b6a662c Mon Sep 17 00:00:00 2001 From: Sebastien Guillemot Date: Mon, 13 May 2024 05:08:25 +0900 Subject: [PATCH] 3.2.0 --- Cargo.lock | 2 +- docs/bin/openapi.json | 2 +- docs/package.json | 2 +- indexer/Cargo.toml | 2 +- .../src/multiera/multiera_projected_nft.rs | 42 +++++++------------ webserver/client/package.json | 2 +- webserver/examples/package.json | 2 +- webserver/server/package.json | 2 +- 8 files changed, 21 insertions(+), 35 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 79a42af3..9c6f7a13 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -581,7 +581,7 @@ dependencies = [ [[package]] name = "carp" -version = "3.1.1" +version = "3.2.0" dependencies = [ "anyhow", "async-trait", diff --git a/docs/bin/openapi.json b/docs/bin/openapi.json index 2e039dab..cc254592 100644 --- a/docs/bin/openapi.json +++ b/docs/bin/openapi.json @@ -1531,7 +1531,7 @@ }, "info": { "title": "carp", - "version": "3.0.0", + "version": "3.2.0", "description": "API for the Postgres database generated by Carp", "license": { "name": "MIT" diff --git a/docs/package.json b/docs/package.json index 317a5d6b..c719eb41 100644 --- a/docs/package.json +++ b/docs/package.json @@ -1,6 +1,6 @@ { "name": "my-website", - "version": "0.0.0", + "version": "3.2.0", "private": true, "scripts": { "prepare": "yarn bin:sql && yarn bin:refresh-ep && yarn bin:refresh-task-docs && yarn bin:openapi", diff --git a/indexer/Cargo.toml b/indexer/Cargo.toml index 075b24bb..1beae87f 100644 --- a/indexer/Cargo.toml +++ b/indexer/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "carp" -version = "3.1.1" +version = "3.2.0" edition = "2021" license = "MIT" diff --git a/indexer/tasks/src/multiera/multiera_projected_nft.rs b/indexer/tasks/src/multiera/multiera_projected_nft.rs index 6e6610c5..7edebd06 100644 --- a/indexer/tasks/src/multiera/multiera_projected_nft.rs +++ b/indexer/tasks/src/multiera/multiera_projected_nft.rs @@ -114,6 +114,9 @@ impl ProjectedNftInputsQueryOutputResult { } } +type TxInputToProjectedNft = + BTreeMap, BTreeMap>>; + async fn handle_projected_nft( db_tx: &DatabaseTransaction, block: BlockInfo<'_, cml_multi_era::MultiEraBlock, BlockGlobalInfo>, @@ -132,9 +135,8 @@ async fn handle_projected_nft( let async_get_projected_nft_inputs = || async { get_projected_nft_inputs(db_tx, multiera_used_inputs_to_outputs_map).await }; - let ONCE_USED_PROJECTED_NFTS: OnceCell< - Result, BTreeMap>>, DbErr>, - > = OnceCell::const_new(); + let once_used_projected_nfts: OnceCell> = + OnceCell::const_new(); for ((tx_body, tx_witness), cardano_transaction) in block .1 @@ -146,10 +148,7 @@ async fn handle_projected_nft( if !cardano_transaction.is_valid { continue; } - let mut partial_withdrawals_inputs: BTreeMap< - Vec, - BTreeMap>, - > = BTreeMap::new(); + let mut partial_withdrawals_inputs: TxInputToProjectedNft = BTreeMap::new(); // 1) Check for projected NFT inputs let inputs = tx_body.inputs(); let mut parsed_inputs: Vec<(&MultiEraTransactionInput, MultiEraTransactionOutput)> = inputs @@ -202,7 +201,7 @@ async fn handle_projected_nft( }) .unwrap_or_else(BTreeMap::new); - let used_projected_nfts = ONCE_USED_PROJECTED_NFTS + let used_projected_nfts = once_used_projected_nfts .get_or_init(async_get_projected_nft_inputs) .await .as_ref() @@ -307,10 +306,7 @@ async fn handle_projected_nft( fn find_lock_outputs_for_corresponding_partial_withdrawals( projected_nft_outputs: &mut [ProjectedNftData], - partial_withdrawals_inputs: &mut BTreeMap< - Vec, - BTreeMap>, - >, + partial_withdrawals_inputs: &mut TxInputToProjectedNft, ) -> Result<(), DbErr> { for output_data in projected_nft_outputs.iter_mut() { if output_data.partial_withdrawn_from_input.is_some() { @@ -373,10 +369,7 @@ fn find_lock_outputs_for_corresponding_partial_withdrawals( fn handle_partial_withdraw( output_projected_nft_data: &ProjectedNftData, - partial_withdrawals_inputs: &mut BTreeMap< - Vec, - BTreeMap>, - >, + partial_withdrawals_inputs: &mut TxInputToProjectedNft, ) -> Result<(), DbErr> { let (withdrawn_from_input_hash, withdrawn_from_input_index) = if let Some((hash, index)) = &output_projected_nft_data.partial_withdrawn_from_input { @@ -441,7 +434,7 @@ fn decode_script_hash(script_hash: String) -> Result, BTreeMap>, -) -> Result, BTreeMap>>, DbErr> { +) -> Result { let inputs_condition = multiera_used_inputs_to_outputs_map .iter() .flat_map(|(_input_tx_id, map)| { @@ -479,8 +472,7 @@ async fn get_projected_nft_inputs( .all(db_tx) .await?; - let mut result: BTreeMap, BTreeMap>> = - BTreeMap::new(); + let mut result: TxInputToProjectedNft = BTreeMap::new(); for nft in projected_nfts { result .entry(nft.tx_hash.clone()) @@ -496,12 +488,9 @@ fn handle_claims_and_partial_withdraws( sorted_inputs: &[&cml_multi_era::utils::MultiEraTransactionInput], cardano_transaction: &TransactionModel, redeemers: &BTreeMap, - used_projected_nfts: &BTreeMap< - Vec, - BTreeMap>, - >, + used_projected_nfts: &TxInputToProjectedNft, queued_projected_nft_records: &mut Vec, -) -> BTreeMap, BTreeMap>> { +) -> TxInputToProjectedNft { let mut partially_withdrawn = BTreeMap::new(); for (sorted_index, input) in sorted_inputs.iter().enumerate() { @@ -639,10 +628,7 @@ struct ProjectedNftData { fn extract_operation_and_datum( output: &MultiEraTransactionOutput, output_model: entity::transaction_output::Model, - partial_withdrawals: &BTreeMap< - Vec, - BTreeMap>, - >, + partial_withdrawals: &TxInputToProjectedNft, ) -> Result { let output = match output { MultiEraTransactionOutput::Byron(_) => { diff --git a/webserver/client/package.json b/webserver/client/package.json index 02cd41e6..3014a02e 100644 --- a/webserver/client/package.json +++ b/webserver/client/package.json @@ -1,6 +1,6 @@ { "name": "@dcspark/carp-client", - "version": "3.1.1", + "version": "3.2.0", "description": "Web client for the Carp server", "main": "client/src/index.js", "scripts": { diff --git a/webserver/examples/package.json b/webserver/examples/package.json index f52a48d1..8822e2a2 100644 --- a/webserver/examples/package.json +++ b/webserver/examples/package.json @@ -1,6 +1,6 @@ { "name": "@dcspark/carp-examples", - "version": "3.0.0", + "version": "3.2.0", "description": "Examples that leverage the Carp client", "scripts": { "eslint": "eslint tests", diff --git a/webserver/server/package.json b/webserver/server/package.json index 05bb4672..e6297e5a 100644 --- a/webserver/server/package.json +++ b/webserver/server/package.json @@ -1,6 +1,6 @@ { "name": "carp", - "version": "3.0.0", + "version": "3.2.0", "description": "API for the Postgres database generated by Carp", "main": "client/src/index.js", "scripts": {