diff --git a/sphinx-ffi/Cargo.toml b/sphinx-ffi/Cargo.toml index 49995d4..0b3f6ee 100644 --- a/sphinx-ffi/Cargo.toml +++ b/sphinx-ffi/Cargo.toml @@ -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 = "0d40771c9a5efcdbd7fe9357bfdc77a44e8ade0a", features = [ +sphinx = { git = "https://github.com/stakwork/sphinx", rev = "b51771ba9a8b5e4742cc8818136410a8f719ba17", features = [ "msg", "bindings", ] } diff --git a/sphinx-ffi/src/auto.rs b/sphinx-ffi/src/auto.rs index 36ef2ac..04ffc77 100644 --- a/sphinx-ffi/src/auto.rs +++ b/sphinx-ffi/src/auto.rs @@ -425,6 +425,42 @@ pub fn create_tribe( .into()) } +pub fn update_tribe( + seed: String, + unique_time: String, + full_state: Vec, + tribe_server_pubkey: String, + tribe_json: String, +) -> Result { + Ok(bindings::update_tribe( + &seed, + &unique_time, + &full_state, + &tribe_server_pubkey, + &tribe_json, + ) + .map_err(|e| SphinxError::SendFailed { r: e.to_string() })? + .into()) +} + +pub fn delete_tribe( + seed: String, + unique_time: String, + full_state: Vec, + tribe_server_pubkey: String, + tribe_pubkey: String, +) -> Result { + Ok(bindings::delete_tribe( + &seed, + &unique_time, + &full_state, + &tribe_server_pubkey, + &tribe_pubkey, + ) + .map_err(|e| SphinxError::SendFailed { r: e.to_string() })? + .into()) +} + pub fn join_tribe( seed: String, unique_time: String, diff --git a/sphinx-ffi/src/sphinxrs.swift b/sphinx-ffi/src/sphinxrs.swift index 1e57f12..41b203c 100644 --- a/sphinx-ffi/src/sphinxrs.swift +++ b/sphinx-ffi/src/sphinxrs.swift @@ -2453,6 +2453,32 @@ public func `deleteMsgs`(`seed`: String, `uniqueTime`: String, `state`: Data, `p ) } +public func `updateTribe`(`seed`: String, `uniqueTime`: String, `state`: Data, `tribeServerPubkey`: String, `tribeJson`: String) throws -> RunReturn { + return try FfiConverterTypeRunReturn.lift( + try rustCallWithError(FfiConverterTypeSphinxError.lift) { + uniffi_sphinxrs_fn_func_update_tribe( + FfiConverterString.lower(`seed`), + FfiConverterString.lower(`uniqueTime`), + FfiConverterData.lower(`state`), + FfiConverterString.lower(`tribeServerPubkey`), + FfiConverterString.lower(`tribeJson`),$0) +} + ) +} + +public func `deleteTribe`(`seed`: String, `uniqueTime`: String, `state`: Data, `tribeServerPubkey`: String, `tribePubkey`: String) throws -> RunReturn { + return try FfiConverterTypeRunReturn.lift( + try rustCallWithError(FfiConverterTypeSphinxError.lift) { + uniffi_sphinxrs_fn_func_delete_tribe( + FfiConverterString.lower(`seed`), + FfiConverterString.lower(`uniqueTime`), + FfiConverterData.lower(`state`), + FfiConverterString.lower(`tribeServerPubkey`), + FfiConverterString.lower(`tribePubkey`),$0) +} + ) +} + private enum InitializationResult { case ok case contractVersionMismatch @@ -2678,6 +2704,12 @@ private var initializationResult: InitializationResult { if (uniffi_sphinxrs_checksum_func_delete_msgs() != 39403) { return InitializationResult.apiChecksumMismatch } + if (uniffi_sphinxrs_checksum_func_update_tribe() != 26002) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_sphinxrs_checksum_func_delete_tribe() != 11926) { + return InitializationResult.apiChecksumMismatch + } return InitializationResult.ok } diff --git a/sphinx-ffi/src/sphinxrs.udl b/sphinx-ffi/src/sphinxrs.udl index f520250..b51d895 100644 --- a/sphinx-ffi/src/sphinxrs.udl +++ b/sphinx-ffi/src/sphinxrs.udl @@ -239,4 +239,8 @@ namespace sphinxrs { RunReturn get_tags(string seed, string unique_time, bytes state, sequence tags, string? pubkey); [Throws=SphinxError] RunReturn delete_msgs(string seed, string unique_time, bytes state, string? pubkey, sequence? msg_idxs); + [Throws=SphinxError] + RunReturn update_tribe(string seed, string unique_time, bytes state, string tribe_server_pubkey, string tribe_json); + [Throws=SphinxError] + RunReturn delete_tribe(string seed, string unique_time, bytes state, string tribe_server_pubkey, string tribe_pubkey); }; \ No newline at end of file diff --git a/sphinx-ffi/src/sphinxrsFFI.h b/sphinx-ffi/src/sphinxrsFFI.h index 8f4648a..ab86b2b 100644 --- a/sphinx-ffi/src/sphinxrsFFI.h +++ b/sphinx-ffi/src/sphinxrsFFI.h @@ -203,6 +203,10 @@ RustBuffer uniffi_sphinxrs_fn_func_get_tags(RustBuffer seed, RustBuffer unique_t ); RustBuffer uniffi_sphinxrs_fn_func_delete_msgs(RustBuffer seed, RustBuffer unique_time, RustBuffer state, RustBuffer pubkey, RustBuffer msg_idxs, RustCallStatus *_Nonnull out_status ); +RustBuffer uniffi_sphinxrs_fn_func_update_tribe(RustBuffer seed, RustBuffer unique_time, RustBuffer state, RustBuffer tribe_server_pubkey, RustBuffer tribe_json, RustCallStatus *_Nonnull out_status +); +RustBuffer uniffi_sphinxrs_fn_func_delete_tribe(RustBuffer seed, RustBuffer unique_time, RustBuffer state, RustBuffer tribe_server_pubkey, RustBuffer tribe_pubkey, RustCallStatus *_Nonnull out_status +); RustBuffer ffi_sphinxrs_rustbuffer_alloc(int32_t size, RustCallStatus *_Nonnull out_status ); RustBuffer ffi_sphinxrs_rustbuffer_from_bytes(ForeignBytes bytes, RustCallStatus *_Nonnull out_status @@ -420,6 +424,12 @@ uint16_t uniffi_sphinxrs_checksum_func_get_tags(void ); uint16_t uniffi_sphinxrs_checksum_func_delete_msgs(void +); +uint16_t uniffi_sphinxrs_checksum_func_update_tribe(void + +); +uint16_t uniffi_sphinxrs_checksum_func_delete_tribe(void + ); uint32_t ffi_sphinxrs_uniffi_contract_version(void diff --git a/sphinx-ffi/src/uniffi/sphinxrs/sphinxrs.kt b/sphinx-ffi/src/uniffi/sphinxrs/sphinxrs.kt index 79f3895..06f4786 100644 --- a/sphinx-ffi/src/uniffi/sphinxrs/sphinxrs.kt +++ b/sphinx-ffi/src/uniffi/sphinxrs/sphinxrs.kt @@ -504,6 +504,10 @@ internal interface _UniFFILib : Library { ): RustBuffer.ByValue fun uniffi_sphinxrs_fn_func_delete_msgs(`seed`: RustBuffer.ByValue,`uniqueTime`: RustBuffer.ByValue,`state`: RustBuffer.ByValue,`pubkey`: RustBuffer.ByValue,`msgIdxs`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue + fun uniffi_sphinxrs_fn_func_update_tribe(`seed`: RustBuffer.ByValue,`uniqueTime`: RustBuffer.ByValue,`state`: RustBuffer.ByValue,`tribeServerPubkey`: RustBuffer.ByValue,`tribeJson`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus, + ): RustBuffer.ByValue + fun uniffi_sphinxrs_fn_func_delete_tribe(`seed`: RustBuffer.ByValue,`uniqueTime`: RustBuffer.ByValue,`state`: RustBuffer.ByValue,`tribeServerPubkey`: RustBuffer.ByValue,`tribePubkey`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus, + ): RustBuffer.ByValue fun ffi_sphinxrs_rustbuffer_alloc(`size`: Int,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue fun ffi_sphinxrs_rustbuffer_from_bytes(`bytes`: ForeignBytes.ByValue,_uniffi_out_err: RustCallStatus, @@ -652,6 +656,10 @@ internal interface _UniFFILib : Library { ): Short fun uniffi_sphinxrs_checksum_func_delete_msgs( ): Short + fun uniffi_sphinxrs_checksum_func_update_tribe( + ): Short + fun uniffi_sphinxrs_checksum_func_delete_tribe( + ): Short fun ffi_sphinxrs_uniffi_contract_version( ): Int @@ -879,6 +887,12 @@ private fun uniffiCheckApiChecksums(lib: _UniFFILib) { if (lib.uniffi_sphinxrs_checksum_func_delete_msgs() != 39403.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } + if (lib.uniffi_sphinxrs_checksum_func_update_tribe() != 26002.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } + if (lib.uniffi_sphinxrs_checksum_func_delete_tribe() != 11926.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } } // Public interface members begin here. @@ -2923,4 +2937,22 @@ fun `deleteMsgs`(`seed`: String, `uniqueTime`: String, `state`: ByteArray, `pubk }) } +@Throws(SphinxException::class) + +fun `updateTribe`(`seed`: String, `uniqueTime`: String, `state`: ByteArray, `tribeServerPubkey`: String, `tribeJson`: String): RunReturn { + return FfiConverterTypeRunReturn.lift( + rustCallWithError(SphinxException) { _status -> + _UniFFILib.INSTANCE.uniffi_sphinxrs_fn_func_update_tribe(FfiConverterString.lower(`seed`),FfiConverterString.lower(`uniqueTime`),FfiConverterByteArray.lower(`state`),FfiConverterString.lower(`tribeServerPubkey`),FfiConverterString.lower(`tribeJson`),_status) +}) +} + +@Throws(SphinxException::class) + +fun `deleteTribe`(`seed`: String, `uniqueTime`: String, `state`: ByteArray, `tribeServerPubkey`: String, `tribePubkey`: String): RunReturn { + return FfiConverterTypeRunReturn.lift( + rustCallWithError(SphinxException) { _status -> + _UniFFILib.INSTANCE.uniffi_sphinxrs_fn_func_delete_tribe(FfiConverterString.lower(`seed`),FfiConverterString.lower(`uniqueTime`),FfiConverterByteArray.lower(`state`),FfiConverterString.lower(`tribeServerPubkey`),FfiConverterString.lower(`tribePubkey`),_status) +}) +} +