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
94 changes: 0 additions & 94 deletions packages/rs-platform-wallet-ffi/src/established_contact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,41 +117,6 @@ pub unsafe extern "C" fn established_contact_get_alias(
PlatformWalletFFIResult::ok()
}

/// Set the alias for an established contact
#[no_mangle]
pub unsafe extern "C" fn established_contact_set_alias(
contact_handle: Handle,
alias: *const std::os::raw::c_char,
) -> PlatformWalletFFIResult {
let alias_str = if alias.is_null() {
None
} else {
unsafe {
Some(unwrap_result_or_return!(std::ffi::CStr::from_ptr(alias).to_str()).to_string())
}
};

let option = ESTABLISHED_CONTACT_STORAGE.with_item_mut(contact_handle, |contact| {
if let Some(a) = alias_str {
contact.set_alias(a);
}
});
unwrap_option_or_return!(option);
PlatformWalletFFIResult::ok()
}

/// Clear the alias for an established contact
#[no_mangle]
pub unsafe extern "C" fn established_contact_clear_alias(
contact_handle: Handle,
) -> PlatformWalletFFIResult {
let option = ESTABLISHED_CONTACT_STORAGE.with_item_mut(contact_handle, |contact| {
contact.clear_alias();
});
unwrap_option_or_return!(option);
PlatformWalletFFIResult::ok()
}

/// Get the note for an established contact
#[no_mangle]
pub unsafe extern "C" fn established_contact_get_note(
Expand All @@ -174,41 +139,6 @@ pub unsafe extern "C" fn established_contact_get_note(
PlatformWalletFFIResult::ok()
}

/// Set the note for an established contact
#[no_mangle]
pub unsafe extern "C" fn established_contact_set_note(
contact_handle: Handle,
note: *const std::os::raw::c_char,
) -> PlatformWalletFFIResult {
let note_str = if note.is_null() {
None
} else {
unsafe {
Some(unwrap_result_or_return!(std::ffi::CStr::from_ptr(note).to_str()).to_string())
}
};

let option = ESTABLISHED_CONTACT_STORAGE.with_item_mut(contact_handle, |contact| {
if let Some(n) = note_str {
contact.set_note(n);
}
});
unwrap_option_or_return!(option);
PlatformWalletFFIResult::ok()
}

/// Clear the note for an established contact
#[no_mangle]
pub unsafe extern "C" fn established_contact_clear_note(
contact_handle: Handle,
) -> PlatformWalletFFIResult {
let option = ESTABLISHED_CONTACT_STORAGE.with_item_mut(contact_handle, |contact| {
contact.clear_note();
});
unwrap_option_or_return!(option);
PlatformWalletFFIResult::ok()
}

/// Check if an established contact is hidden
#[no_mangle]
pub unsafe extern "C" fn established_contact_is_hidden(
Expand Down Expand Up @@ -244,30 +174,6 @@ pub unsafe extern "C" fn established_contact_is_payment_channel_broken(
PlatformWalletFFIResult::ok()
}

/// Hide an established contact from the contact list
#[no_mangle]
pub unsafe extern "C" fn established_contact_hide(
contact_handle: Handle,
) -> PlatformWalletFFIResult {
let option = ESTABLISHED_CONTACT_STORAGE.with_item_mut(contact_handle, |contact| {
contact.hide();
});
unwrap_option_or_return!(option);
PlatformWalletFFIResult::ok()
}

/// Unhide an established contact
#[no_mangle]
pub unsafe extern "C" fn established_contact_unhide(
contact_handle: Handle,
) -> PlatformWalletFFIResult {
let option = ESTABLISHED_CONTACT_STORAGE.with_item_mut(contact_handle, |contact| {
contact.unhide();
});
unwrap_option_or_return!(option);
PlatformWalletFFIResult::ok()
}

/// Destroy an established contact handle and free resources
#[no_mangle]
pub unsafe extern "C" fn established_contact_destroy(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,6 @@ public final class EstablishedContact: @unchecked Sendable {
return String(cString: ptr)
}

/// Set the contact's alias
public func setAlias(_ alias: String) throws {
let aliasCStr = (alias as NSString).utf8String
try established_contact_set_alias(handle, aliasCStr).check()
}

/// Clear the contact's alias
public func clearAlias() throws {
try established_contact_clear_alias(handle).check()
}

/// Get the contact's note. Returns `nil` when no note is set —
/// see `getAlias()` for the `NotFound` rationale.
public func getNote() throws -> String? {
Expand All @@ -91,31 +80,10 @@ public final class EstablishedContact: @unchecked Sendable {
return String(cString: ptr)
}

/// Set the contact's note
public func setNote(_ note: String) throws {
let noteCStr = (note as NSString).utf8String
try established_contact_set_note(handle, noteCStr).check()
}

/// Clear the contact's note
public func clearNote() throws {
try established_contact_clear_note(handle).check()
}

/// Check if the contact is hidden
public func isHidden() throws -> Bool {
var hidden: Bool = false
try established_contact_is_hidden(handle, &hidden).check()
return hidden
}

/// Hide the contact
public func hide() throws {
try established_contact_hide(handle).check()
}

/// Unhide the contact
public func unhide() throws {
try established_contact_unhide(handle).check()
}
}
Loading