use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Wallet {
pub chain: String,
pub address: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SocialAccount {
pub platform: String,
pub username: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct BankrClub {
pub active: bool,
pub subscription_type: Option<String>,
pub renew_or_cancel_on: Option<u64>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Leaderboard {
pub score: u64,
pub rank: Option<u64>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UserInfoResponse {
pub success: bool,
pub wallets: Vec<Wallet>,
pub social_accounts: Vec<SocialAccount>,
pub ref_code: Option<String>,
pub bankr_club: Option<BankrClub>,
pub leaderboard: Option<Leaderboard>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PromptRequest {
pub prompt: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub thread_id: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PromptResponse {
pub success: bool,
pub job_id: String,
pub thread_id: String,
pub status: String,
pub message: String,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum JobStatus {
Pending,
Processing,
Completed,
Failed,
Cancelled,
}
impl std::fmt::Display for JobStatus {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Pending => write!(f, "pending"),
Self::Processing => write!(f, "processing"),
Self::Completed => write!(f, "completed"),
Self::Failed => write!(f, "failed"),
Self::Cancelled => write!(f, "cancelled"),
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct StatusUpdate {
pub message: Option<String>,
pub timestamp: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RichDataItem {
#[serde(rename = "type")]
pub kind: String,
#[serde(flatten)]
pub extra: serde_json::Value,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct JobResponse {
pub success: bool,
pub job_id: String,
pub thread_id: Option<String>,
pub status: JobStatus,
pub prompt: String,
pub created_at: String,
pub cancellable: Option<bool>,
pub status_updates: Option<Vec<StatusUpdate>>,
pub started_at: Option<String>,
pub response: Option<String>,
pub rich_data: Option<Vec<RichDataItem>>,
pub completed_at: Option<String>,
pub processing_time: Option<u64>,
pub error: Option<String>,
pub cancelled_at: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CancelJobResponse {
pub success: bool,
pub job_id: String,
pub status: String,
pub prompt: Option<String>,
pub created_at: Option<String>,
pub cancelled_at: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum SignatureType {
#[serde(rename = "personal_sign")]
PersonalSign,
#[serde(rename = "eth_signTypedData_v4")]
EthSignTypedDataV4,
#[serde(rename = "eth_signTransaction")]
EthSignTransaction,
}
impl std::fmt::Display for SignatureType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::PersonalSign => write!(f, "personal_sign"),
Self::EthSignTypedDataV4 => write!(f, "eth_signTypedData_v4"),
Self::EthSignTransaction => write!(f, "eth_signTransaction"),
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EvmTransaction {
pub to: String,
pub chain_id: u64,
#[serde(skip_serializing_if = "Option::is_none")]
pub value: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub data: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub gas: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub gas_price: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub max_fee_per_gas: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub max_priority_fee_per_gas: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub nonce: Option<u64>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SignRequest {
pub signature_type: SignatureType,
#[serde(skip_serializing_if = "Option::is_none")]
pub message: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub typed_data: Option<serde_json::Value>,
#[serde(skip_serializing_if = "Option::is_none")]
pub transaction: Option<EvmTransaction>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SignResponse {
pub success: bool,
pub signature: Option<String>,
pub signer: Option<String>,
pub signature_type: Option<SignatureType>,
pub error: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SubmitRequest {
pub transaction: EvmTransaction,
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub wait_for_confirmation: Option<bool>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SubmitResponse {
pub success: bool,
pub transaction_hash: Option<String>,
pub status: Option<String>,
pub block_number: Option<String>,
pub gas_used: Option<String>,
pub signer: Option<String>,
pub chain_id: Option<u64>,
pub error: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ApiErrorBody {
pub error: Option<String>,
pub message: Option<String>,
pub reset_at: Option<u64>,
pub limit: Option<u64>,
pub used: Option<u64>,
}