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

Display transactions #14

Merged
merged 4 commits into from
Nov 12, 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
51 changes: 51 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,59 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.7.0] - 2024-11-12

### Added

- Transaction preparation functionality
- Option to prepare transactions without sending to ledger
- Toggle for transaction signing
- Toggle for transaction submission
- Visual indicators for transaction preparation mode
- Enhanced transaction display
- Improved JSON formatting for transactions
- Clean transaction copying without descriptive text
- Separate display of transaction status and content
- Copy functionality for prepared transactions

### Changed

- Modified the transaction workflow
- Separated transaction preparation from submission
- Added explicit transaction signing step
- Improved transaction display formatting
- Enhanced error handling for transaction preparation
- Updated UI elements
- Added transaction options checkboxes
- Improved transaction status indicators
- Enhanced feedback for transaction operations
- Better organization of transaction controls

### Fixed

- Transaction display issues
- Removed descriptive text from copied transactions
- Fixed JSON formatting in display and copy operations
- Corrected transaction status messages
- Resolved borrow checker issues with transaction handling
- UI interaction improvements
- Fixed transaction copy functionality
- Improved error message display
- Enhanced transaction status visibility
- Better handling of transaction state

### Security

- Improved transaction handling
- Clear separation of unsigned and signed transactions
- Better visibility of transaction signing state
- Enhanced transaction preparation feedback
- Improved transaction state management

## [0.6.0] - 2024-11-11

[Previous changelog content...]

### Added

- Genesis file viewing capability
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "indyforge"
version = "0.6.0"
version = "0.7.0"
authors = ["Sylvain Martel <[email protected]>"]
edition = "2021"
include = ["LICENSE-APACHE", "LICENSE-MIT", "**/*.rs", "Cargo.toml"]
Expand Down
18 changes: 18 additions & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,21 @@ pub enum MyRoles {
Trustee = 0,
}

#[derive(serde::Deserialize, serde::Serialize, Debug)]
pub struct TransactionOptions {
pub sign: bool,
pub send: bool,
}

impl Default for TransactionOptions {
fn default() -> Self {
Self {
sign: true,
send: true,
}
}
}

pub struct SchemaInfo {
pub schema_name: String,
pub schema_version: String,
Expand Down Expand Up @@ -85,6 +100,7 @@ pub struct TemplateApp {
show_genesis_content: bool,
current_genesis_path: Option<String>,
connection_start_time: Option<std::time::Instant>,
transaction_options: TransactionOptions,
}

impl Default for TemplateApp {
Expand Down Expand Up @@ -126,6 +142,7 @@ impl Default for TemplateApp {
show_genesis_content: false,
current_genesis_path: None,
connection_start_time: None,
transaction_options: TransactionOptions::default(),
}
}
}
Expand Down Expand Up @@ -442,6 +459,7 @@ impl eframe::App for TemplateApp {
&mut self.schema_info,
&mut self.txn,
&mut self.signed_txn_result,
&mut self.transaction_options,
).expect("Failed to render publish tool UI");
}
}
Expand Down
91 changes: 71 additions & 20 deletions src/helpers/ledgers.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::app::NymInfo;
use crate::app::{NymInfo, TransactionOptions};
use crate::helpers::genesis::GenesisSource;
use crate::helpers::wallet::IndyWallet;
use indy_data_types::anoncreds::schema::Schema;
Expand Down Expand Up @@ -80,41 +80,92 @@ impl IndyLedger {
wallet: &IndyWallet,
submitter_did: &str,
schema: &Schema,
options: &TransactionOptions,
) -> VdrResult<String> {
let mut request = self
.pool
.get_request_builder()
.build_schema_request(&DidValue(submitter_did.to_string()), schema.clone())
.unwrap();
.build_schema_request(&DidValue(submitter_did.to_string()), schema.clone())?;

self._sign_and_submit_request(wallet, &mut request).await
let result = if options.sign {
let sig_bytes = request.get_signature_input()?;
let signature = wallet.sign(sig_bytes.as_bytes()).await;
request.set_signature(&signature)?;
serde_json::to_string_pretty(&request.req_json).map_err(|e| {
VdrError::new(
VdrErrorKind::Input,
Some(format!(
"Failed to serialize signed schema transaction: {}",
e
)),
None,
)
})?
} else {
serde_json::to_string_pretty(&request.req_json).map_err(|e| {
VdrError::new(
VdrErrorKind::Input,
Some(format!(
"Failed to serialize unsigned schema transaction: {}",
e
)),
None,
)
})?
};

if options.send {
self._submit_request(&request).await
} else {
Ok(result)
}
}

pub async fn publish_nym(
&self,
wallet: &IndyWallet,
submitter_did: &str,
nym_info: &mut NymInfo,
// target_did: &str,
// verkey: &str,
role: UpdateRole,
options: &TransactionOptions,
) -> VdrResult<String> {
let alias = nym_info.alias.clone().filter(|a| !a.trim().is_empty());
let mut request = self
.pool
.get_request_builder()
.build_nym_request(
&DidValue(submitter_did.to_string()),
&DidValue(nym_info.did.to_string()),
Some(nym_info.verkey.to_string()),
alias,
Some(role),
None,
None,
)
.unwrap();
let mut request = self.pool.get_request_builder().build_nym_request(
&DidValue(submitter_did.to_string()),
&DidValue(nym_info.did.to_string()),
Some(nym_info.verkey.to_string()),
alias,
Some(role),
None,
None,
)?;

self._sign_and_submit_request(wallet, &mut request).await
let result = if options.sign {
let sig_bytes = request.get_signature_input()?;
let signature = wallet.sign(sig_bytes.as_bytes()).await;
request.set_signature(&signature)?;
serde_json::to_string_pretty(&request.req_json).map_err(|e| {
VdrError::new(
VdrErrorKind::Input, // Using Input for serialization errors
Some(format!("Failed to serialize signed transaction: {}", e)),
None,
)
})?
} else {
serde_json::to_string_pretty(&request.req_json).map_err(|e| {
VdrError::new(
VdrErrorKind::Input, // Using Input for serialization errors
Some(format!("Failed to serialize unsigned transaction: {}", e)),
None,
)
})?
};

if options.send {
self._submit_request(&request).await
} else {
Ok(result)
}
}

// function to only send a transaction that is already signed
Expand Down
Loading
Loading