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
//! This module contains implementations for different types of signers in the NEO blockchain.
//!
//! It includes:
//! - `AccountSigner`: Represents an account-based signer.
//! - `ContractSigner`: Represents a contract-based signer.
//! - `TransactionSigner`: Represents a transaction-specific signer.
//! - `Signer`: An enum that can be any of the above signer types.
//!
//! This module also provides traits and utilities for working with signers,
//! including serialization, deserialization, and common signer operations.
//!
//! # Usage
//!
//! To use the signers in your NEO blockchain transactions:
//!
//! 1. Import the necessary types:
//! ```rust
//! use neo3::neo_builder::{AccountSigner, ContractSigner, TransactionSigner, Signer};
//! ```
//!
//! 2. Create a signer based on your needs:
//! ```rust,no_run
//! use neo3::neo_protocol::{Account, AccountTrait};
//! use neo3::neo_builder::{AccountSigner, ContractSigner, TransactionSigner, WitnessScope};
//! use neo3::prelude::H160;
//! use std::str::FromStr;
//!
//! // For an account-based signer
//! let account = Account::from_wif("YOUR_WIF_HERE").unwrap();
//! let account_signer = AccountSigner::called_by_entry(&account).unwrap();
//!
//! // For a contract-based signer
//! let contract_hash = H160::from_str("0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5").unwrap();
//! let contract_signer = ContractSigner::called_by_entry(contract_hash, &[]);
//!
//! // For a transaction-specific signer
//! let transaction_signer = TransactionSigner::new(account.get_script_hash(), vec![WitnessScope::CalledByEntry]);
//! ```
//!
//! 3. Use the signer in your transaction:
//! ```rust,no_run
//! # use neo3::neo_builder::{TransactionBuilder, AccountSigner};
//! # use neo3::neo_protocol::{Account, AccountTrait};
//! # let account = Account::from_wif("YOUR_WIF_HERE").unwrap();
//! # let account_signer = AccountSigner::called_by_entry(&account).unwrap();
//! # use neo3::neo_clients::HttpProvider;
//! let mut tx_builder: TransactionBuilder<'_, HttpProvider> = TransactionBuilder::default();
//! tx_builder.set_signers(vec![account_signer.into()]);
//! // ... add other transaction details ...
//! # async {
//! let tx = tx_builder.build().await.unwrap();
//! # };
//! ```
//!
//! 4. You can also convert between signer types using the `Signer` enum:
//! ```rust,no_run
//! # use neo3::neo_builder::{Signer, AccountSigner};
//! # use neo3::neo_protocol::{Account, AccountTrait};
//! # let account = Account::from_wif("YOUR_WIF_HERE").unwrap();
//! # let account_signer = AccountSigner::called_by_entry(&account).unwrap();
//! let generic_signer: Signer = account_signer.into();
//! ```
//!
//! Remember to handle errors and manage scopes, allowed contracts, and other signer properties as needed for your specific use case.
pub use *;
pub use *;
pub use *;
pub use *;