Skip to content

Commit

Permalink
bump sphinx
Browse files Browse the repository at this point in the history
  • Loading branch information
Evanfeenstra committed Feb 7, 2024
1 parent d6fb5e7 commit 9369bca
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 17 deletions.
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 = "60cff7f2e408d384e690ecff948a04573cb6409e", features = [
sphinx = { git = "https://github.com/stakwork/sphinx", rev = "973d2d4c7fc64c5fdf78622a2fc52ac4fea1081b", features = [
"msg",
"bindings",
] }
Expand Down
13 changes: 11 additions & 2 deletions sphinx-ffi/src/auto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use sphinx::bindings;
use sphinx::serde_json;

pub struct RunReturn {
pub new_subscription: Option<String>,
pub topic_0: Option<String>,
pub payload_0: Option<Vec<u8>>,
pub topic_1: Option<String>,
Expand Down Expand Up @@ -100,6 +99,17 @@ pub fn get_subscription_topic(
)
}

pub fn get_tribe_management_topic(
seed: String,
unique_time: String,
full_state: Vec<u8>,
) -> Result<String> {
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<u8>) -> Result<RunReturn> {
Ok(bindings::initial_setup(&seed, &unique_time, &full_state)
.map_err(|e| SphinxError::HandleFailed { r: e.to_string() })?
Expand Down Expand Up @@ -351,7 +361,6 @@ pub fn process_invite(
impl From<bindings::RunReturn> 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,
Expand Down
24 changes: 15 additions & 9 deletions sphinx-ffi/src/sphinxrs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down Expand Up @@ -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`
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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`)
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
}
Expand Down
3 changes: 2 additions & 1 deletion sphinx-ffi/src/sphinxrs.udl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ dictionary VlsResponse {
};

dictionary RunReturn {
string? new_subscription;
string? topic_0;
bytes? payload_0;
string? topic_1;
Expand Down Expand Up @@ -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);
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 @@ -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
Expand Down Expand Up @@ -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

Expand Down
20 changes: 16 additions & 4 deletions sphinx-ffi/src/uniffi/sphinxrs/sphinxrs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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")
}
Expand Down Expand Up @@ -911,7 +918,6 @@ public object FfiConverterTypeKeys: FfiConverterRustBuffer<Keys> {


data class RunReturn (
var `newSubscription`: String?,
var `topic0`: String?,
var `payload0`: ByteArray?,
var `topic1`: String?,
Expand Down Expand Up @@ -944,7 +950,6 @@ data class RunReturn (
public object FfiConverterTypeRunReturn: FfiConverterRustBuffer<RunReturn> {
override fun read(buf: ByteBuffer): RunReturn {
return RunReturn(
FfiConverterOptionalString.read(buf),
FfiConverterOptionalString.read(buf),
FfiConverterOptionalByteArray.read(buf),
FfiConverterOptionalString.read(buf),
Expand Down Expand Up @@ -974,7 +979,6 @@ public object FfiConverterTypeRunReturn: FfiConverterRustBuffer<RunReturn> {
}

override fun allocationSize(value: RunReturn) = (
FfiConverterOptionalString.allocationSize(value.`newSubscription`) +
FfiConverterOptionalString.allocationSize(value.`topic0`) +
FfiConverterOptionalByteArray.allocationSize(value.`payload0`) +
FfiConverterOptionalString.allocationSize(value.`topic1`) +
Expand Down Expand Up @@ -1003,7 +1007,6 @@ public object FfiConverterTypeRunReturn: FfiConverterRustBuffer<RunReturn> {
)

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)
Expand Down Expand Up @@ -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 ->
Expand Down

0 comments on commit 9369bca

Please sign in to comment.