| 661 | match provider.send_transaction(tx_request).await { |
| 662 | Ok(pending) => { |
| 663 | println!("Transaction sent: {}", pending.tx_hash()); |
| 664 | match pending.get_receipt().await { |
| 665 | Ok(receipt) => { |
| 666 | println!("Receipt: {:?}", receipt); |
| 667 | Ok(()) |
| 668 | } |
| 669 | Err(e) => panic!("Transaction failed: {e}"), |
| 670 | } |
| 671 | } |
| 672 | Err(e) => panic!("Error sending transaction: {}", e), |
| 673 | } |
| 674 | } |
| 675 | |
| 676 | async fn get_latest_epoch(rpc_port: u16) -> Result<u64, Box<dyn std::error::Error>> { |
| 677 | let url = format!("http://localhost:{}", rpc_port); |
| 678 | let client = HttpClientBuilder::default().build(&url)?; |
| 679 | let epoch = client.get_latest_epoch().await?; |
| 680 | Ok(epoch) |
| 681 | } |
| 682 | |
| 683 | async fn get_validator_balance( |
| 684 | rpc_port: u16, |
| 685 | public_key: String, |
| 686 | ) -> Result<u64, Box<dyn std::error::Error>> { |
| 687 | let url = format!("http://localhost:{}", rpc_port); |
| 688 | let client = HttpClientBuilder::default().build(&url)?; |
| 689 | let balance = client.get_validator_balance(public_key).await?; |
| 690 | Ok(balance) |