1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
//! # Kadena
//!
//! A comprehensive Rust library for interacting with Pact smart contracts and the Kadena blockchain.
//! This library provides a type-safe, ergonomic interface for creating and signing Pact commands,
//! managing cryptographic operations, and interacting with Kadena nodes.
//!
//! ## Features
//!
//! - **Cryptographic Operations**: Key generation, signing, and verification using ED25519
//! - **Pact Command Creation**: Type-safe builders for creating and signing Pact commands
//! - **Capability Management**: Create and manage Pact capabilities
//! - **Transaction Management**: Create, sign, and send transactions to Kadena nodes
//!
//! ## Quick Start
//!
//! ```rust
//! use kadena::{
//! crypto::PactKeypair,
//! pact::{
//! meta::Meta,
//! cap::Cap,
//! command::Cmd,
//! },
//! fetch::{ApiClient, ApiConfig}
//! };
//!
//! // Generate a new keypair
//! let keypair = PactKeypair::generate();
//!
//! // Set network and chain id
//! let network = "testnet04";
//! let chain_id = "0";
//!
//! // Create metadata for the transaction
//! let meta = Meta::new(chain_id, &format!("k:{}", keypair.public_key()))
//! .with_gas_limit(1500)
//! .with_gas_price(0.00000001);
//!
//! // Create capabilities
//! let caps = vec![
//! Cap::new("coin.GAS"),
//! Cap::transfer(
//! &format!("k:{}", keypair.public_key()),
//! "k:receiver",
//! 10.0
//! ),
//! ];
//!
//! // Prepare the command
//! let cmd = Cmd::prepare_exec(
//! &[(&keypair, caps)],
//! None,
//! "(coin.transfer)",
//! None,
//! meta,
//! Some(network.to_string()),
//! ).unwrap();
//!
//! // Create the client
//! let client = ApiClient::new(
//! ApiConfig::new("https://api.testnet.chainweb.com", network, chain_id).with_timeout(60),
//! );
//!
//! //Send the tx
//! //let result = client.local(&transaction_cmd).await?;
//! ```
//!
//! ## Modules
//!
//! - [`crypto`] - Cryptographic operations and key management
//! - [`pact`] - Pact command creation and management
//! - [`pact::meta`] - Transaction metadata handling
//! - [`pact::cap`] - Capability creation and management
//! - [`pact::command`] - Command preparation and signing
//! - [`fetch`] - API client management
//!
//! ## Examples
//!
//! ### Key Management
//!
//! ```rust
//! use kadena::crypto::PactKeypair;
//!
//! // Generate a new keypair
//! let keypair = PactKeypair::generate();
//!
//! // Sign a message
//! let message = b"Hello, Kadena!";
//! let signature = keypair.sign(message).unwrap();
//!
//! // Verify the signature
//! assert!(keypair.verify(message, &signature).unwrap());
//! ```
//!
//! ### Creating a Transfer Transaction
//!
//! ```rust
//! use kadena::pact::{
//! meta::Meta,
//! cap::Cap,
//! command::Cmd,
//! };
//! use kadena::crypto::PactKeypair;
//!
//! // Set up the transaction
//! let keypair = PactKeypair::generate();
//! let sender = format!("k:{}", keypair.public_key());
//!
//! let meta = Meta::new("0", &sender);
//! let caps = vec![
//! Cap::new("coin.GAS"),
//! Cap::transfer(&sender, "k:receiver", 10.0),
//! ];
//!
//! let pact_code = format!(
//! "(coin.transfer \"{}\" \"k:receiver\" 10.0)",
//! sender
//! );
//!
//! let cmd = Cmd::prepare_exec(
//! &[(&keypair, caps)],
//! None,
//! &pact_code,
//! None,
//! meta,
//! Some("testnet04".to_string()),
//! ).unwrap();
//! ```
//!
//! ## Performance
//!
//! This library includes comprehensive benchmarks for all critical operations. You can run them with:
//!
//! ```bash
//! cargo bench
//! ```
//!
//! ## Safety and Security
//!
//! This library uses well-audited cryptographic implementations:
//!
//! - ED25519 operations via `ed25519-dalek`
//! - Blake2b hashing via `blake2`
//! - Secure random number generation via `rand`
//!
//! ## Error Handling
//!
//! All operations that can fail return `Result` types with specific error enums:
//!
//! ```rust
//! use kadena::crypto::{PactKeypair, CryptoError};
//!
//! fn handle_signing() -> Result<(), CryptoError> {
//! let keypair = PactKeypair::generate();
//! let signature = keypair.sign(b"message")?;
//! Ok(())
//! }
//! ```
//!
//! ## Contribution
//!
//! Contributions are welcome! Please feel free to submit a Pull Request. Check out our
//! [Contribution Guidelines](CONTRIBUTING.md) for more information.
//!
//! ## License
//!
//! This project is licensed under the MIT License.
//!
pub use *;
pub use *;
pub use *;