Skip to content

Commit

Permalink
chore: remove old code
Browse files Browse the repository at this point in the history
  • Loading branch information
chris13524 committed Dec 17, 2024
1 parent 6487f34 commit 85a55aa
Show file tree
Hide file tree
Showing 21 changed files with 62 additions and 2,274 deletions.
61 changes: 11 additions & 50 deletions crates/kotlin-ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use {
relay_rpc::domain::ProjectId,
std::time::Duration,
yttrium::{
account_client::{AccountClient as YAccountClient, SignerType},
account_client::AccountClient as YAccountClient,
chain_abstraction::{
api::{
prepare::{PrepareResponse, RouteResponseAvailable},
Expand All @@ -24,8 +24,6 @@ use {
ui_fields::UiFields,
},
config::Config,
private_key_service::PrivateKeyService,
sign_service::address_from_string,
transaction::{
send::safe_test::{
Address as FFIAddress, OwnerSignature as YOwnerSignature,
Expand All @@ -41,9 +39,6 @@ pub struct FFIAccountClientConfig {
pub owner_address: String,
pub chain_id: u64,
pub config: Config,
pub signer_type: String,
pub safe: bool,
pub private_key: String,
}

#[derive(uniffi::Record)]
Expand Down Expand Up @@ -225,25 +220,15 @@ impl ChainAbstractionClient {
impl FFIAccountClient {
#[uniffi::constructor]
pub fn new(config: FFIAccountClientConfig) -> Self {
let owner_address = config.owner_address.clone();
let signer_type = config.signer_type.clone();
let signer = SignerType::from(signer_type).unwrap();
let account_client = match signer {
SignerType::PrivateKey => {
let private_key_fn =
Box::new(move || Ok(config.private_key.clone()));
let owner = address_from_string(&owner_address).unwrap();
let service = PrivateKeyService::new(private_key_fn, owner);
YAccountClient::new_with_private_key_service(
config.owner_address.clone(),
config.chain_id,
config.config,
service,
config.safe,
)
}
SignerType::Native => todo!(),
};
let account_client = YAccountClient::new(
config
.owner_address
.parse::<alloy::primitives::Address>()
.unwrap()
.into(),
config.chain_id,
config.config,
);

Self {
owner_address: config.owner_address.clone(),
Expand All @@ -260,24 +245,10 @@ impl FFIAccountClient {
self.account_client
.get_address()
.await
.map(|address| address.to_string())
.map_err(|e| FFIError::General(e.to_string()))
}

pub async fn send_transactions(
&self,
transactions: Vec<FFITransaction>,
) -> Result<String, FFIError> {
let ytransactions: Vec<YTransaction> =
transactions.into_iter().map(YTransaction::from).collect();

Ok(self
.account_client
.send_transactions(ytransactions)
.await
.map_err(|e| FFIError::General(e.to_string()))?
.to_string())
}

pub async fn prepare_send_transactions(
&self,
transactions: Vec<FFITransaction>,
Expand Down Expand Up @@ -333,16 +304,6 @@ impl FFIAccountClient {
.to_string())
}

pub fn sign_message_with_mnemonic(
&self,
message: String,
mnemonic: String,
) -> Result<String, FFIError> {
self.account_client
.sign_message_with_mnemonic(message, mnemonic)
.map_err(|e| FFIError::General(e.to_string()))
}

pub async fn wait_for_user_operation_receipt(
&self,
user_operation_hash: String,
Expand Down
Loading

0 comments on commit 85a55aa

Please sign in to comment.