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
//! # CryptoPay - Etherscan Payment Gateway Library
//!
//! A comprehensive Rust library for integrating with Etherscan API to verify and monitor
//! cryptocurrency payments on Ethereum.
//!
//! ## Features
//!
//! - **Etherscan API Integration**: Full support for accounts, transactions, tokens, and gas tracking
//! - **Payment Verification**: Verify ETH and ERC20 token payments with confirmation tracking
//! - **Payment Monitoring**: Monitor pending payments with callbacks
//! - **Rate Limiting**: Built-in rate limiter respecting Etherscan's 5 req/s limit
//! - **Caching**: In-memory LRU cache to minimize API calls
//! - **Optional Storage**: PostgreSQL and SQLite storage implementations (feature-gated)
//!
//! ## Quick Start
//!
//! ```rust,no_run
//! use cryptopay::*;
//! use rust_decimal::Decimal;
//! use std::str::FromStr;
//!
//! #[tokio::main]
//! async fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
//! // Create Etherscan client
//! let client = EtherscanClient::new("your-api-key")?;
//! let verifier = PaymentVerifier::new(client);
//!
//! // Create payment request
//! let payment = PaymentRequest {
//! amount: Decimal::from_str("0.1").unwrap(),
//! currency: Currency::ETH,
//! recipient_address: "0x...".to_string(),
//! required_confirmations: 12,
//! timeout_seconds: Some(1800),
//! };
//!
//! // Verify payment
//! match verifier.verify_payment(&payment).await? {
//! VerificationResult::Confirmed { tx_hash, .. } => {
//! println!("Payment confirmed: {}", tx_hash);
//! }
//! VerificationResult::Pending { confirmations, .. } => {
//! println!("Waiting for confirmations: {}/{}",
//! confirmations, payment.required_confirmations);
//! }
//! _ => println!("No payment found"),
//! }
//!
//! Ok(())
//! }
//! ```
// Re-export main types for convenience
pub use BscScanClient as EtherscanClient;
pub use BscScanClient; // Keep for backward compat
pub use ClientConfig;
pub use ;
pub use ;
pub use ;
pub use SqliteStorage;