Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 3 additions & 15 deletions examples/CRISP/server/src/cli/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@

use crisp_constants::get_default_paramset;
use dialoguer::{theme::ColorfulTheme, FuzzySelect, Input};
use e3_sdk::bfv_helpers::BfvParamSets;
use log::info;
use num_bigint::BigUint;
use reqwest::Client;
use serde::{Deserialize, Serialize};

use super::approve;
use super::CLI_DB;
use alloy::primitives::{Address, Bytes, U256};
use alloy::providers::{Provider, ProviderBuilder};
use alloy::sol_types::SolValue;
use crisp::config::CONFIG;
use e3_sdk::bfv_helpers::{build_bfv_params_from_set_arc, encode_bfv_params};
use e3_sdk::evm_helpers::contracts::{EnclaveContract, EnclaveRead, EnclaveWrite, E3};
Expand All @@ -41,12 +40,6 @@ struct ComputeProviderParams {
batch_size: u32,
}

#[derive(Debug, Deserialize, Serialize)]
struct CustomParams {
token_address: String,
balance_threshold: String,
}

#[derive(Debug, Deserialize, Serialize)]
struct PKRequest {
round_id: u64,
Expand Down Expand Up @@ -105,15 +98,10 @@ pub async fn initialize_crisp_round(
}

let token_address: Address = token_address.parse()?;
let balance_threshold = BigUint::parse_bytes(balance_threshold.as_bytes(), 10)
.ok_or("Invalid balance threshold")?;
let balance_threshold = U256::from_str_radix(&balance_threshold, 10)?;

let custom_params = CustomParams {
token_address: token_address.to_string(),
balance_threshold: balance_threshold.to_string(),
};
// Serialize the custom parameters to bytes.
let custom_params_bytes = Bytes::from(serde_json::to_vec(&custom_params)?);
let custom_params_bytes = Bytes::from((token_address, balance_threshold).abi_encode());
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Comment thread
coderabbitai[bot] marked this conversation as resolved.

let threshold: [u32; 2] = [CONFIG.e3_threshold_min, CONFIG.e3_threshold_max];
let mut current_timestamp = get_current_timestamp().await?;
Expand Down
14 changes: 4 additions & 10 deletions examples/CRISP/server/src/server/routes/rounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
use crate::config::CONFIG;
use crate::server::app_data::AppData;
use crate::server::models::{
CTRequest, ComputeProviderParams, CustomParams, JsonResponse, PKRequest, RoundRequest,
CTRequest, ComputeProviderParams, JsonResponse, PKRequest, RoundRequest,
};

use actix_web::{web, HttpResponse, Responder};
use alloy::primitives::{Address, Bytes, U256};
use alloy::sol_types::SolValue;
use chrono::Utc;
use crisp_constants::get_default_paramset;
use e3_sdk::bfv_helpers::{build_bfv_params_from_set_arc, encode_bfv_params};
use e3_sdk::evm_helpers::contracts::{EnclaveContract, EnclaveRead, EnclaveWrite};
use log::{error, info};
use num_bigint::BigUint;

pub fn setup_routes(config: &mut web::ServiceConfig) {
config.service(
Expand Down Expand Up @@ -183,16 +183,10 @@ pub async fn initialize_crisp_round(
let params = encode_bfv_params(&build_bfv_params_from_set_arc(get_default_paramset()));

let token_address: Address = token_address.parse()?;
let balance_threshold = BigUint::parse_bytes(balance_threshold.as_bytes(), 10)
.ok_or("Invalid balance threshold")?;

let custom_params = CustomParams {
token_address: token_address.to_string(),
balance_threshold: balance_threshold.to_string(),
};
let balance_threshold = U256::from_str_radix(&balance_threshold, 10)?;

// Serialize the custom parameters to bytes.
let custom_params_bytes = Bytes::from(serde_json::to_vec(&custom_params)?);
let custom_params_bytes = Bytes::from((token_address, balance_threshold).abi_encode());

info!("Requesting E3...");
let threshold: [u32; 2] = [CONFIG.e3_threshold_min, CONFIG.e3_threshold_max];
Expand Down
Loading