fn main()

in projects/web3/eth_wallet/host/src/main.rs [115:152]


fn main() -> Result<()> {
    let args = cli::Opt::from_args();
    match args.command {
        cli::Command::CreateWallet(_opt) => {
            let wallet_id = create_wallet()?;
            println!("Wallet ID: {}", wallet_id);
        }
        cli::Command::RemoveWallet(opt) => {
            remove_wallet(opt.wallet_id)?;
            println!("Wallet removed");
        }
        cli::Command::DeriveAddress(opt) => {
            let address = derive_address(opt.wallet_id, &opt.hd_path)?;
            println!("Address: 0x{}", hex::encode(&address));
        }
        cli::Command::SignTransaction(opt) => {
            let signature = sign_transaction(
                opt.wallet_id,
                &opt.hd_path,
                opt.chain_id,
                opt.nonce,
                opt.to,
                opt.value,
                opt.gas_price,
                opt.gas,
            )?;
            println!("Signature: {}", hex::encode(&signature));
        }
        cli::Command::Test => {
            tests::tests::test_workflow();
            println!("Tests passed");
        }
        _ => {
            bail!("Unsupported command");
        }
    }
    Ok(())
}