diff --git a/sphinx-ffi/Cargo.toml b/sphinx-ffi/Cargo.toml index fcd18fc..e0125a8 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 = "60cff7f2e408d384e690ecff948a04573cb6409e", features = [ +sphinx = { git = "https://github.com/stakwork/sphinx", rev = "973d2d4c7fc64c5fdf78622a2fc52ac4fea1081b", features = [ "msg", "bindings", ] } diff --git a/sphinx-ffi/src/auto.rs b/sphinx-ffi/src/auto.rs index 9353d58..8c1caae 100644 --- a/sphinx-ffi/src/auto.rs +++ b/sphinx-ffi/src/auto.rs @@ -3,7 +3,6 @@ use sphinx::bindings; use sphinx::serde_json; pub struct RunReturn { - pub new_subscription: Option, pub topic_0: Option, pub payload_0: Option>, pub topic_1: Option, @@ -100,6 +99,17 @@ pub fn get_subscription_topic( ) } +pub fn get_tribe_management_topic( + seed: String, + unique_time: String, + full_state: Vec, +) -> Result { + Ok( + bindings::get_tribe_management_topic(&seed, &unique_time, &full_state) + .map_err(|e| SphinxError::HandleFailed { r: e.to_string() })?, + ) +} + pub fn initial_setup(seed: String, unique_time: String, full_state: Vec) -> Result { Ok(bindings::initial_setup(&seed, &unique_time, &full_state) .map_err(|e| SphinxError::HandleFailed { r: e.to_string() })? @@ -351,7 +361,6 @@ pub fn process_invite( impl From for RunReturn { fn from(rr: bindings::RunReturn) -> Self { RunReturn { - new_subscription: rr.new_subscription, topic_0: rr.topic_0, payload_0: rr.payload_0, topic_1: rr.topic_1, diff --git a/sphinx-ffi/src/sphinxrs.swift b/sphinx-ffi/src/sphinxrs.swift index d850bf1..373cd63 100644 --- a/sphinx-ffi/src/sphinxrs.swift +++ b/sphinx-ffi/src/sphinxrs.swift @@ -476,7 +476,6 @@ public func FfiConverterTypeKeys_lower(_ value: Keys) -> RustBuffer { public struct RunReturn { - public var `newSubscription`: String? public var `topic0`: String? public var `payload0`: Data? public var `topic1`: String? @@ -505,8 +504,7 @@ public struct RunReturn { // Default memberwise initializers are never public by default, so we // declare one manually. - public init(`newSubscription`: String?, `topic0`: String?, `payload0`: Data?, `topic1`: String?, `payload1`: Data?, `topic2`: String?, `payload2`: Data?, `stateMp`: Data?, `msg`: String?, `msgType`: UInt8?, `msgUuid`: String?, `msgIndex`: String?, `msgSender`: String?, `msgMsat`: UInt64?, `msgTimestamp`: UInt64?, `newBalance`: UInt64?, `myContactInfo`: String?, `sentStatus`: String?, `sentTo`: String?, `settledStatus`: String?, `error`: String?, `newTribe`: String?, `tribeMembers`: String?, `newInvite`: String?, `inviterContactInfo`: String?, `lspHost`: String?) { - self.`newSubscription` = `newSubscription` + public init(`topic0`: String?, `payload0`: Data?, `topic1`: String?, `payload1`: Data?, `topic2`: String?, `payload2`: Data?, `stateMp`: Data?, `msg`: String?, `msgType`: UInt8?, `msgUuid`: String?, `msgIndex`: String?, `msgSender`: String?, `msgMsat`: UInt64?, `msgTimestamp`: UInt64?, `newBalance`: UInt64?, `myContactInfo`: String?, `sentStatus`: String?, `sentTo`: String?, `settledStatus`: String?, `error`: String?, `newTribe`: String?, `tribeMembers`: String?, `newInvite`: String?, `inviterContactInfo`: String?, `lspHost`: String?) { self.`topic0` = `topic0` self.`payload0` = `payload0` self.`topic1` = `topic1` @@ -538,9 +536,6 @@ public struct RunReturn { extension RunReturn: Equatable, Hashable { public static func ==(lhs: RunReturn, rhs: RunReturn) -> Bool { - if lhs.`newSubscription` != rhs.`newSubscription` { - return false - } if lhs.`topic0` != rhs.`topic0` { return false } @@ -620,7 +615,6 @@ extension RunReturn: Equatable, Hashable { } public func hash(into hasher: inout Hasher) { - hasher.combine(`newSubscription`) hasher.combine(`topic0`) hasher.combine(`payload0`) hasher.combine(`topic1`) @@ -653,7 +647,6 @@ extension RunReturn: Equatable, Hashable { public struct FfiConverterTypeRunReturn: FfiConverterRustBuffer { public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> RunReturn { return try RunReturn( - `newSubscription`: FfiConverterOptionString.read(from: &buf), `topic0`: FfiConverterOptionString.read(from: &buf), `payload0`: FfiConverterOptionData.read(from: &buf), `topic1`: FfiConverterOptionString.read(from: &buf), @@ -683,7 +676,6 @@ public struct FfiConverterTypeRunReturn: FfiConverterRustBuffer { } public static func write(_ value: RunReturn, into buf: inout [UInt8]) { - FfiConverterOptionString.write(value.`newSubscription`, into: &buf) FfiConverterOptionString.write(value.`topic0`, into: &buf) FfiConverterOptionData.write(value.`payload0`, into: &buf) FfiConverterOptionString.write(value.`topic1`, into: &buf) @@ -1593,6 +1585,17 @@ public func `getSubscriptionTopic`(`seed`: String, `uniqueTime`: String, `state` ) } +public func `getTribeManagementTopic`(`seed`: String, `uniqueTime`: String, `state`: Data) throws -> String { + return try FfiConverterString.lift( + try rustCallWithError(FfiConverterTypeSphinxError.lift) { + uniffi_sphinxrs_fn_func_get_tribe_management_topic( + FfiConverterString.lower(`seed`), + FfiConverterString.lower(`uniqueTime`), + FfiConverterData.lower(`state`),$0) +} + ) +} + public func `initialSetup`(`seed`: String, `uniqueTime`: String, `state`: Data) throws -> RunReturn { return try FfiConverterTypeRunReturn.lift( try rustCallWithError(FfiConverterTypeSphinxError.lift) { @@ -1892,6 +1895,9 @@ private var initializationResult: InitializationResult { if (uniffi_sphinxrs_checksum_func_get_subscription_topic() != 12763) { return InitializationResult.apiChecksumMismatch } + if (uniffi_sphinxrs_checksum_func_get_tribe_management_topic() != 29476) { + return InitializationResult.apiChecksumMismatch + } if (uniffi_sphinxrs_checksum_func_initial_setup() != 63727) { return InitializationResult.apiChecksumMismatch } diff --git a/sphinx-ffi/src/sphinxrs.udl b/sphinx-ffi/src/sphinxrs.udl index b213f46..72e3ae8 100644 --- a/sphinx-ffi/src/sphinxrs.udl +++ b/sphinx-ffi/src/sphinxrs.udl @@ -43,7 +43,6 @@ dictionary VlsResponse { }; dictionary RunReturn { - string? new_subscription; string? topic_0; bytes? payload_0; string? topic_1; @@ -138,6 +137,8 @@ namespace sphinxrs { [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); + [Throws=SphinxError] RunReturn initial_setup(string seed, string unique_time, bytes state); [Throws=SphinxError] RunReturn fetch_msgs(string seed, string unique_time, bytes state, u64 last_msg_idx, u32? limit); diff --git a/sphinx-ffi/src/sphinxrsFFI.h b/sphinx-ffi/src/sphinxrsFFI.h index 7071970..7f6dda1 100644 --- a/sphinx-ffi/src/sphinxrsFFI.h +++ b/sphinx-ffi/src/sphinxrsFFI.h @@ -129,6 +129,8 @@ RustBuffer uniffi_sphinxrs_fn_func_list_contacts(RustBuffer state, RustCallStatu ); 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 +); RustBuffer uniffi_sphinxrs_fn_func_initial_setup(RustBuffer seed, RustBuffer unique_time, RustBuffer state, RustCallStatus *_Nonnull out_status ); RustBuffer uniffi_sphinxrs_fn_func_fetch_msgs(RustBuffer seed, RustBuffer unique_time, RustBuffer state, uint64_t last_msg_idx, RustBuffer limit, RustCallStatus *_Nonnull out_status @@ -261,6 +263,9 @@ uint16_t uniffi_sphinxrs_checksum_func_list_contacts(void ); uint16_t uniffi_sphinxrs_checksum_func_get_subscription_topic(void +); +uint16_t uniffi_sphinxrs_checksum_func_get_tribe_management_topic(void + ); uint16_t uniffi_sphinxrs_checksum_func_initial_setup(void diff --git a/sphinx-ffi/src/uniffi/sphinxrs/sphinxrs.kt b/sphinx-ffi/src/uniffi/sphinxrs/sphinxrs.kt index 1ef1e25..b1c592a 100644 --- a/sphinx-ffi/src/uniffi/sphinxrs/sphinxrs.kt +++ b/sphinx-ffi/src/uniffi/sphinxrs/sphinxrs.kt @@ -430,6 +430,8 @@ internal interface _UniFFILib : Library { ): 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, + ): RustBuffer.ByValue fun uniffi_sphinxrs_fn_func_initial_setup(`seed`: RustBuffer.ByValue,`uniqueTime`: RustBuffer.ByValue,`state`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus, ): RustBuffer.ByValue fun uniffi_sphinxrs_fn_func_fetch_msgs(`seed`: RustBuffer.ByValue,`uniqueTime`: RustBuffer.ByValue,`state`: RustBuffer.ByValue,`lastMsgIdx`: Long,`limit`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus, @@ -530,6 +532,8 @@ internal interface _UniFFILib : Library { ): Short fun uniffi_sphinxrs_checksum_func_get_subscription_topic( ): Short + fun uniffi_sphinxrs_checksum_func_get_tribe_management_topic( + ): Short fun uniffi_sphinxrs_checksum_func_initial_setup( ): Short fun uniffi_sphinxrs_checksum_func_fetch_msgs( @@ -672,6 +676,9 @@ private fun uniffiCheckApiChecksums(lib: _UniFFILib) { if (lib.uniffi_sphinxrs_checksum_func_get_subscription_topic() != 12763.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } + if (lib.uniffi_sphinxrs_checksum_func_get_tribe_management_topic() != 29476.toShort()) { + throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } if (lib.uniffi_sphinxrs_checksum_func_initial_setup() != 63727.toShort()) { throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project") } @@ -911,7 +918,6 @@ public object FfiConverterTypeKeys: FfiConverterRustBuffer { data class RunReturn ( - var `newSubscription`: String?, var `topic0`: String?, var `payload0`: ByteArray?, var `topic1`: String?, @@ -944,7 +950,6 @@ data class RunReturn ( public object FfiConverterTypeRunReturn: FfiConverterRustBuffer { override fun read(buf: ByteBuffer): RunReturn { return RunReturn( - FfiConverterOptionalString.read(buf), FfiConverterOptionalString.read(buf), FfiConverterOptionalByteArray.read(buf), FfiConverterOptionalString.read(buf), @@ -974,7 +979,6 @@ public object FfiConverterTypeRunReturn: FfiConverterRustBuffer { } override fun allocationSize(value: RunReturn) = ( - FfiConverterOptionalString.allocationSize(value.`newSubscription`) + FfiConverterOptionalString.allocationSize(value.`topic0`) + FfiConverterOptionalByteArray.allocationSize(value.`payload0`) + FfiConverterOptionalString.allocationSize(value.`topic1`) + @@ -1003,7 +1007,6 @@ public object FfiConverterTypeRunReturn: FfiConverterRustBuffer { ) override fun write(value: RunReturn, buf: ByteBuffer) { - FfiConverterOptionalString.write(value.`newSubscription`, buf) FfiConverterOptionalString.write(value.`topic0`, buf) FfiConverterOptionalByteArray.write(value.`payload0`, buf) FfiConverterOptionalString.write(value.`topic1`, buf) @@ -2120,6 +2123,15 @@ fun `getSubscriptionTopic`(`seed`: String, `uniqueTime`: String, `state`: ByteAr @Throws(SphinxException::class) +fun `getTribeManagementTopic`(`seed`: String, `uniqueTime`: String, `state`: ByteArray): String { + return FfiConverterString.lift( + rustCallWithError(SphinxException) { _status -> + _UniFFILib.INSTANCE.uniffi_sphinxrs_fn_func_get_tribe_management_topic(FfiConverterString.lower(`seed`),FfiConverterString.lower(`uniqueTime`),FfiConverterByteArray.lower(`state`),_status) +}) +} + +@Throws(SphinxException::class) + fun `initialSetup`(`seed`: String, `uniqueTime`: String, `state`: ByteArray): RunReturn { return FfiConverterTypeRunReturn.lift( rustCallWithError(SphinxException) { _status ->