cotyledon 0.1.0

Framework for writing sprouts — sandboxed, event-driven on-chain trading bots.
Documentation
//! The sprout's wallet handle.

use crate::{Result, host};

/// The sprout's custodial wallet. Signing happens in the engine; the private key
/// never enters the sandbox.
pub struct Wallet;

impl Wallet {
    /// The wallet's public address.
    pub async fn address(&self) -> Result<String> {
        host::wallet_address().await
    }

    /// The wallet's balance of a token.
    pub async fn balance(&self, token: &str) -> Result<f64> {
        host::wallet_balance(token).await
    }

    /// Sign a payload (e.g. a serialized transaction).
    pub async fn sign(&self, payload: &[u8]) -> Result<Vec<u8>> {
        host::sign(payload).await
    }
}