Skip to content

Commit

Permalink
contact_pubkey_by_child_index
Browse files Browse the repository at this point in the history
  • Loading branch information
Evanfeenstra committed Apr 25, 2024
1 parent 6fa63a1 commit 9ace668
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sphinx-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ sphinx-signer = { path = "../signer", default-features = false, features = [
"no-native",
] }
sphinx-glyph = { path = "../glyph", default-features = false }
sphinx = { git = "https://github.com/stakwork/sphinx", rev = "839ba21f5ca3b2c3c9faede46de1f0d880cc0f42", features = [
sphinx = { git = "https://github.com/stakwork/sphinx", rev = "138c94f2ce3eb1cf69f8d8094e7eaa01b1553392", features = [
"msg",
"bindings",
] }
Expand Down
10 changes: 10 additions & 0 deletions sphinx-ffi/src/auto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,16 @@ pub fn list_contacts(full_state: Vec<u8>) -> Result<String> {
Ok(json)
}

pub fn contact_pubkey_by_child_index(full_state: Vec<u8>, child_idx: u64) -> Result<String> {
Ok(
bindings::contact_pubkey_by_child_index(&full_state, child_idx).map_err(|e| {
SphinxError::GetContactFailed {
r: format!("contact_pubkey_by_child_index failed: {:?}", e),
}
})?,
)
}

pub fn get_subscription_topic(
seed: String,
unique_time: String,
Expand Down
13 changes: 13 additions & 0 deletions sphinx-ffi/src/sphinxrs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1799,6 +1799,16 @@ public func `listContacts`(`state`: Data) throws -> String {
)
}

public func `contactPubkeyByChildIndex`(`state`: Data, `childIdx`: UInt64) throws -> String {
return try FfiConverterString.lift(
try rustCallWithError(FfiConverterTypeSphinxError.lift) {
uniffi_sphinxrs_fn_func_contact_pubkey_by_child_index(
FfiConverterData.lower(`state`),
FfiConverterUInt64.lower(`childIdx`),$0)
}
)
}

public func `getSubscriptionTopic`(`seed`: String, `uniqueTime`: String, `state`: Data) throws -> String {
return try FfiConverterString.lift(
try rustCallWithError(FfiConverterTypeSphinxError.lift) {
Expand Down Expand Up @@ -2313,6 +2323,9 @@ private var initializationResult: InitializationResult {
if (uniffi_sphinxrs_checksum_func_list_contacts() != 18133) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_sphinxrs_checksum_func_contact_pubkey_by_child_index() != 7496) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_sphinxrs_checksum_func_get_subscription_topic() != 12763) {
return InitializationResult.apiChecksumMismatch
}
Expand Down
2 changes: 2 additions & 0 deletions sphinx-ffi/src/sphinxrs.udl
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ namespace sphinxrs {
[Throws=SphinxError]
string list_contacts(bytes state);
[Throws=SphinxError]
string contact_pubkey_by_child_index(bytes state, u64 child_idx);
[Throws=SphinxError]
string get_subscription_topic(string seed, string unique_time, bytes state);
[Throws=SphinxError]
string get_tribe_management_topic(string seed, string unique_time, bytes state);
Expand Down
5 changes: 5 additions & 0 deletions sphinx-ffi/src/sphinxrsFFI.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ RustBuffer uniffi_sphinxrs_fn_func_get_contact(RustBuffer state, RustBuffer pubk
);
RustBuffer uniffi_sphinxrs_fn_func_list_contacts(RustBuffer state, RustCallStatus *_Nonnull out_status
);
RustBuffer uniffi_sphinxrs_fn_func_contact_pubkey_by_child_index(RustBuffer state, uint64_t child_idx, RustCallStatus *_Nonnull out_status
);
RustBuffer uniffi_sphinxrs_fn_func_get_subscription_topic(RustBuffer seed, RustBuffer unique_time, RustBuffer state, RustCallStatus *_Nonnull out_status
);
RustBuffer uniffi_sphinxrs_fn_func_get_tribe_management_topic(RustBuffer seed, RustBuffer unique_time, RustBuffer state, RustCallStatus *_Nonnull out_status
Expand Down Expand Up @@ -292,6 +294,9 @@ uint16_t uniffi_sphinxrs_checksum_func_get_contact(void
);
uint16_t uniffi_sphinxrs_checksum_func_list_contacts(void

);
uint16_t uniffi_sphinxrs_checksum_func_contact_pubkey_by_child_index(void

);
uint16_t uniffi_sphinxrs_checksum_func_get_subscription_topic(void

Expand Down
16 changes: 16 additions & 0 deletions sphinx-ffi/src/uniffi/sphinxrs/sphinxrs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,8 @@ internal interface _UniFFILib : Library {
): RustBuffer.ByValue
fun uniffi_sphinxrs_fn_func_list_contacts(`state`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus,
): RustBuffer.ByValue
fun uniffi_sphinxrs_fn_func_contact_pubkey_by_child_index(`state`: RustBuffer.ByValue,`childIdx`: Long,_uniffi_out_err: RustCallStatus,
): RustBuffer.ByValue
fun uniffi_sphinxrs_fn_func_get_subscription_topic(`seed`: RustBuffer.ByValue,`uniqueTime`: RustBuffer.ByValue,`state`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus,
): RustBuffer.ByValue
fun uniffi_sphinxrs_fn_func_get_tribe_management_topic(`seed`: RustBuffer.ByValue,`uniqueTime`: RustBuffer.ByValue,`state`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus,
Expand Down Expand Up @@ -562,6 +564,8 @@ internal interface _UniFFILib : Library {
): Short
fun uniffi_sphinxrs_checksum_func_list_contacts(
): Short
fun uniffi_sphinxrs_checksum_func_contact_pubkey_by_child_index(
): Short
fun uniffi_sphinxrs_checksum_func_get_subscription_topic(
): Short
fun uniffi_sphinxrs_checksum_func_get_tribe_management_topic(
Expand Down Expand Up @@ -737,6 +741,9 @@ private fun uniffiCheckApiChecksums(lib: _UniFFILib) {
if (lib.uniffi_sphinxrs_checksum_func_list_contacts() != 18133.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
if (lib.uniffi_sphinxrs_checksum_func_contact_pubkey_by_child_index() != 7496.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
if (lib.uniffi_sphinxrs_checksum_func_get_subscription_topic() != 12763.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
Expand Down Expand Up @@ -2415,6 +2422,15 @@ fun `listContacts`(`state`: ByteArray): String {

@Throws(SphinxException::class)

fun `contactPubkeyByChildIndex`(`state`: ByteArray, `childIdx`: ULong): String {
return FfiConverterString.lift(
rustCallWithError(SphinxException) { _status ->
_UniFFILib.INSTANCE.uniffi_sphinxrs_fn_func_contact_pubkey_by_child_index(FfiConverterByteArray.lower(`state`),FfiConverterULong.lower(`childIdx`),_status)
})
}

@Throws(SphinxException::class)

fun `getSubscriptionTopic`(`seed`: String, `uniqueTime`: String, `state`: ByteArray): String {
return FfiConverterString.lift(
rustCallWithError(SphinxException) { _status ->
Expand Down

0 comments on commit 9ace668

Please sign in to comment.