Skip to content
Open
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
2 changes: 1 addition & 1 deletion sdk/core/src/bucket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use cap_common::{
/// contract is created using multiple bucket canisters, which are interconnected using a root bucket
/// and router system. Querying buckets also features pagination.
#[derive(Copy, Clone)]
pub struct Bucket(pub(crate) Principal);
pub struct Bucket(pub Principal);

impl Bucket {
/// Returns the list of canisters which have different pages of data.
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/src/root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use serde::{Deserialize, Serialize};
///
/// Use [`RootBucket`]'s [`Into<Bucket>`] implementation to use a [`RootBucket`] as a [`Bucket`].
#[derive(Copy, Clone, Serialize, Deserialize, CandidType)]
pub struct RootBucket(pub(crate) Principal);
pub struct RootBucket(pub Principal);

impl RootBucket {
/// Returns a bucket that be used to query for the given transaction ID.
Expand Down
22 changes: 12 additions & 10 deletions sdk/src/transaction/query.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use cap_sdk_core::GetTransactionResponse;
use cap_sdk_core::{Bucket, GetTransactionResponse};

use crate::{CapEnv, GetTransactionError, Transaction, TransactionId};

Expand Down Expand Up @@ -28,19 +28,21 @@ pub async fn get_transaction(id: TransactionId) -> Result<Transaction, GetTransa
.await
.map_err(|(code, details)| GetTransactionError::Unexpected(code, details))?;

let transaction = bucket
let mut transaction = bucket
.get_transaction(id)
.await
.map_err(|(code, details)| GetTransactionError::Unexpected(code, details))?;

if let GetTransactionResponse::Found(event, _) = transaction {
if let Some(event) = event {
Ok(event)
} else {
Err(GetTransactionError::InvalidId)
}
while let GetTransactionResponse::Delegate(bucket, _) = transaction {
transaction = Bucket(bucket)
.get_transaction(id)
.await
.map_err(|(code, details)| GetTransactionError::Unexpected(code, details))?;
}

if let GetTransactionResponse::Found(Some(event), _) = transaction {
Ok(event)
} else {
// TODO: Delegate
unimplemented!("This version of cap-sdk does not support multi-canister.")
Err(GetTransactionError::InvalidId)
}
}