Skip to content

Commit

Permalink
device topic
Browse files Browse the repository at this point in the history
  • Loading branch information
Evanfeenstra committed May 28, 2024
1 parent 1aa483f commit fa49513
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 61 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 = "f4aadc063fd2b50f67e802fea8c2685a60d4d342", features = [
sphinx = { git = "https://github.com/stakwork/sphinx", rev = "b57b3b7e3f02fe3d44910c305070e7610702bb4e", features = [
"msg",
"bindings",
] }
Expand Down
17 changes: 4 additions & 13 deletions sphinx-ffi/src/auto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub struct RunReturn {
pub msgs: Vec<Msg>,
pub msgs_total: Option<u64>,
pub msgs_counts: Option<String>,
pub subscription_topics: Vec<String>,
pub topics: Vec<String>,
pub payloads: Vec<Vec<u8>>,
pub state_mp: Option<Vec<u8>>,
Expand Down Expand Up @@ -137,17 +138,6 @@ pub fn contact_pubkey_by_encrypted_child(
)
}

pub fn get_subscription_topic(
seed: String,
unique_time: String,
full_state: Vec<u8>,
) -> Result<String> {
Ok(
bindings::get_subscription_topic(&seed, &unique_time, &full_state)
.map_err(|e| SphinxError::HandleFailed { r: e.to_string() })?,
)
}

pub fn get_tribe_management_topic(
seed: String,
unique_time: String,
Expand All @@ -159,8 +149,8 @@ pub fn get_tribe_management_topic(
)
}

pub fn initial_setup(seed: String, unique_time: String, full_state: Vec<u8>) -> Result<RunReturn> {
Ok(bindings::initial_setup(&seed, &unique_time, &full_state)
pub fn initial_setup(seed: String, unique_time: String, full_state: Vec<u8>, device: String) -> Result<RunReturn> {
Ok(bindings::initial_setup(&seed, &unique_time, &full_state, &device)
.map_err(|e| SphinxError::HandleFailed { r: e.to_string() })?
.into())
}
Expand Down Expand Up @@ -655,6 +645,7 @@ impl From<bindings::RunReturn> for RunReturn {
msgs: rr.msgs.into_iter().map(|m| m.into()).collect(),
msgs_total: rr.msgs_total,
msgs_counts: rr.msgs_counts,
subscription_topics: rr.subscription_topics,
topics: rr.topics,
payloads: rr.payloads,
state_mp: rr.state_mp,
Expand Down
31 changes: 13 additions & 18 deletions sphinx-ffi/src/sphinxrs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,7 @@ public struct RunReturn {
public var `msgs`: [Msg]
public var `msgsTotal`: UInt64?
public var `msgsCounts`: String?
public var `subscriptionTopics`: [String]
public var `topics`: [String]
public var `payloads`: [Data]
public var `stateMp`: Data?
Expand All @@ -632,10 +633,11 @@ public struct RunReturn {

// Default memberwise initializers are never public by default, so we
// declare one manually.
public init(`msgs`: [Msg], `msgsTotal`: UInt64?, `msgsCounts`: String?, `topics`: [String], `payloads`: [Data], `stateMp`: Data?, `stateToDelete`: [String], `newBalance`: UInt64?, `myContactInfo`: String?, `sentStatus`: String?, `settledStatus`: String?, `error`: String?, `newTribe`: String?, `tribeMembers`: String?, `newInvite`: String?, `inviterContactInfo`: String?, `inviterAlias`: String?, `initialTribe`: String?, `lspHost`: String?, `invoice`: String?, `route`: String?, `node`: String?, `lastRead`: String?, `muteLevels`: String?, `payments`: String?, `paymentsTotal`: UInt64?) {
public init(`msgs`: [Msg], `msgsTotal`: UInt64?, `msgsCounts`: String?, `subscriptionTopics`: [String], `topics`: [String], `payloads`: [Data], `stateMp`: Data?, `stateToDelete`: [String], `newBalance`: UInt64?, `myContactInfo`: String?, `sentStatus`: String?, `settledStatus`: String?, `error`: String?, `newTribe`: String?, `tribeMembers`: String?, `newInvite`: String?, `inviterContactInfo`: String?, `inviterAlias`: String?, `initialTribe`: String?, `lspHost`: String?, `invoice`: String?, `route`: String?, `node`: String?, `lastRead`: String?, `muteLevels`: String?, `payments`: String?, `paymentsTotal`: UInt64?) {
self.`msgs` = `msgs`
self.`msgsTotal` = `msgsTotal`
self.`msgsCounts` = `msgsCounts`
self.`subscriptionTopics` = `subscriptionTopics`
self.`topics` = `topics`
self.`payloads` = `payloads`
self.`stateMp` = `stateMp`
Expand Down Expand Up @@ -674,6 +676,9 @@ extension RunReturn: Equatable, Hashable {
if lhs.`msgsCounts` != rhs.`msgsCounts` {
return false
}
if lhs.`subscriptionTopics` != rhs.`subscriptionTopics` {
return false
}
if lhs.`topics` != rhs.`topics` {
return false
}
Expand Down Expand Up @@ -750,6 +755,7 @@ extension RunReturn: Equatable, Hashable {
hasher.combine(`msgs`)
hasher.combine(`msgsTotal`)
hasher.combine(`msgsCounts`)
hasher.combine(`subscriptionTopics`)
hasher.combine(`topics`)
hasher.combine(`payloads`)
hasher.combine(`stateMp`)
Expand Down Expand Up @@ -783,6 +789,7 @@ public struct FfiConverterTypeRunReturn: FfiConverterRustBuffer {
`msgs`: FfiConverterSequenceTypeMsg.read(from: &buf),
`msgsTotal`: FfiConverterOptionUInt64.read(from: &buf),
`msgsCounts`: FfiConverterOptionString.read(from: &buf),
`subscriptionTopics`: FfiConverterSequenceString.read(from: &buf),
`topics`: FfiConverterSequenceString.read(from: &buf),
`payloads`: FfiConverterSequenceData.read(from: &buf),
`stateMp`: FfiConverterOptionData.read(from: &buf),
Expand Down Expand Up @@ -813,6 +820,7 @@ public struct FfiConverterTypeRunReturn: FfiConverterRustBuffer {
FfiConverterSequenceTypeMsg.write(value.`msgs`, into: &buf)
FfiConverterOptionUInt64.write(value.`msgsTotal`, into: &buf)
FfiConverterOptionString.write(value.`msgsCounts`, into: &buf)
FfiConverterSequenceString.write(value.`subscriptionTopics`, into: &buf)
FfiConverterSequenceString.write(value.`topics`, into: &buf)
FfiConverterSequenceData.write(value.`payloads`, into: &buf)
FfiConverterOptionData.write(value.`stateMp`, into: &buf)
Expand Down Expand Up @@ -1828,17 +1836,6 @@ public func `contactPubkeyByEncryptedChild`(`seed`: String, `state`: Data, `chil
)
}

public func `getSubscriptionTopic`(`seed`: String, `uniqueTime`: String, `state`: Data) throws -> String {
return try FfiConverterString.lift(
try rustCallWithError(FfiConverterTypeSphinxError.lift) {
uniffi_sphinxrs_fn_func_get_subscription_topic(
FfiConverterString.lower(`seed`),
FfiConverterString.lower(`uniqueTime`),
FfiConverterData.lower(`state`),$0)
}
)
}

public func `getTribeManagementTopic`(`seed`: String, `uniqueTime`: String, `state`: Data) throws -> String {
return try FfiConverterString.lift(
try rustCallWithError(FfiConverterTypeSphinxError.lift) {
Expand All @@ -1850,13 +1847,14 @@ public func `getTribeManagementTopic`(`seed`: String, `uniqueTime`: String, `sta
)
}

public func `initialSetup`(`seed`: String, `uniqueTime`: String, `state`: Data) throws -> RunReturn {
public func `initialSetup`(`seed`: String, `uniqueTime`: String, `state`: Data, `device`: String) throws -> RunReturn {
return try FfiConverterTypeRunReturn.lift(
try rustCallWithError(FfiConverterTypeSphinxError.lift) {
uniffi_sphinxrs_fn_func_initial_setup(
FfiConverterString.lower(`seed`),
FfiConverterString.lower(`uniqueTime`),
FfiConverterData.lower(`state`),$0)
FfiConverterData.lower(`state`),
FfiConverterString.lower(`device`),$0)
}
)
}
Expand Down Expand Up @@ -2362,13 +2360,10 @@ private var initializationResult: InitializationResult {
if (uniffi_sphinxrs_checksum_func_contact_pubkey_by_encrypted_child() != 6829) {
return InitializationResult.apiChecksumMismatch
}
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) {
if (uniffi_sphinxrs_checksum_func_initial_setup() != 30402) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_sphinxrs_checksum_func_fetch_msgs() != 12460) {
Expand Down
5 changes: 2 additions & 3 deletions sphinx-ffi/src/sphinxrs.udl
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ dictionary RunReturn {
sequence<Msg> msgs;
u64? msgs_total;
string? msgs_counts;
sequence<string> subscription_topics;
sequence<string> topics;
sequence<bytes> payloads;
bytes? state_mp;
Expand Down Expand Up @@ -155,11 +156,9 @@ namespace sphinxrs {
[Throws=SphinxError]
string contact_pubkey_by_encrypted_child(string seed, bytes state, string child);
[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);
RunReturn initial_setup(string seed, string unique_time, bytes state, string device);
[Throws=SphinxError]
RunReturn fetch_msgs(string seed, string unique_time, bytes state, u64 last_msg_idx, u32? limit);
[Throws=SphinxError]
Expand Down
7 changes: 1 addition & 6 deletions sphinx-ffi/src/sphinxrsFFI.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,9 @@ RustBuffer uniffi_sphinxrs_fn_func_contact_pubkey_by_child_index(RustBuffer stat
);
RustBuffer uniffi_sphinxrs_fn_func_contact_pubkey_by_encrypted_child(RustBuffer seed, RustBuffer state, RustBuffer child, 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
);
RustBuffer uniffi_sphinxrs_fn_func_initial_setup(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, RustBuffer device, 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 @@ -304,9 +302,6 @@ uint16_t uniffi_sphinxrs_checksum_func_contact_pubkey_by_child_index(void
);
uint16_t uniffi_sphinxrs_checksum_func_contact_pubkey_by_encrypted_child(void

);
uint16_t uniffi_sphinxrs_checksum_func_get_subscription_topic(void

);
uint16_t uniffi_sphinxrs_checksum_func_get_tribe_management_topic(void

Expand Down
28 changes: 8 additions & 20 deletions sphinx-ffi/src/uniffi/sphinxrs/sphinxrs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -432,11 +432,9 @@ internal interface _UniFFILib : Library {
): RustBuffer.ByValue
fun uniffi_sphinxrs_fn_func_contact_pubkey_by_encrypted_child(`seed`: RustBuffer.ByValue,`state`: RustBuffer.ByValue,`child`: RustBuffer.ByValue,_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,
): RustBuffer.ByValue
fun uniffi_sphinxrs_fn_func_initial_setup(`seed`: RustBuffer.ByValue,`uniqueTime`: RustBuffer.ByValue,`state`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus,
fun uniffi_sphinxrs_fn_func_initial_setup(`seed`: RustBuffer.ByValue,`uniqueTime`: RustBuffer.ByValue,`state`: RustBuffer.ByValue,`device`: 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,
): RustBuffer.ByValue
Expand Down Expand Up @@ -572,8 +570,6 @@ internal interface _UniFFILib : Library {
): Short
fun uniffi_sphinxrs_checksum_func_contact_pubkey_by_encrypted_child(
): 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(
Expand Down Expand Up @@ -755,13 +751,10 @@ private fun uniffiCheckApiChecksums(lib: _UniFFILib) {
if (lib.uniffi_sphinxrs_checksum_func_contact_pubkey_by_encrypted_child() != 6829.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")
}
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()) {
if (lib.uniffi_sphinxrs_checksum_func_initial_setup() != 30402.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
if (lib.uniffi_sphinxrs_checksum_func_fetch_msgs() != 12460.toShort()) {
Expand Down Expand Up @@ -1119,6 +1112,7 @@ data class RunReturn (
var `msgs`: List<Msg>,
var `msgsTotal`: ULong?,
var `msgsCounts`: String?,
var `subscriptionTopics`: List<String>,
var `topics`: List<String>,
var `payloads`: List<ByteArray>,
var `stateMp`: ByteArray?,
Expand Down Expand Up @@ -1153,6 +1147,7 @@ public object FfiConverterTypeRunReturn: FfiConverterRustBuffer<RunReturn> {
FfiConverterOptionalULong.read(buf),
FfiConverterOptionalString.read(buf),
FfiConverterSequenceString.read(buf),
FfiConverterSequenceString.read(buf),
FfiConverterSequenceByteArray.read(buf),
FfiConverterOptionalByteArray.read(buf),
FfiConverterSequenceString.read(buf),
Expand Down Expand Up @@ -1182,6 +1177,7 @@ public object FfiConverterTypeRunReturn: FfiConverterRustBuffer<RunReturn> {
FfiConverterSequenceTypeMsg.allocationSize(value.`msgs`) +
FfiConverterOptionalULong.allocationSize(value.`msgsTotal`) +
FfiConverterOptionalString.allocationSize(value.`msgsCounts`) +
FfiConverterSequenceString.allocationSize(value.`subscriptionTopics`) +
FfiConverterSequenceString.allocationSize(value.`topics`) +
FfiConverterSequenceByteArray.allocationSize(value.`payloads`) +
FfiConverterOptionalByteArray.allocationSize(value.`stateMp`) +
Expand Down Expand Up @@ -1211,6 +1207,7 @@ public object FfiConverterTypeRunReturn: FfiConverterRustBuffer<RunReturn> {
FfiConverterSequenceTypeMsg.write(value.`msgs`, buf)
FfiConverterOptionalULong.write(value.`msgsTotal`, buf)
FfiConverterOptionalString.write(value.`msgsCounts`, buf)
FfiConverterSequenceString.write(value.`subscriptionTopics`, buf)
FfiConverterSequenceString.write(value.`topics`, buf)
FfiConverterSequenceByteArray.write(value.`payloads`, buf)
FfiConverterOptionalByteArray.write(value.`stateMp`, buf)
Expand Down Expand Up @@ -2458,15 +2455,6 @@ fun `contactPubkeyByEncryptedChild`(`seed`: String, `state`: ByteArray, `child`:

@Throws(SphinxException::class)

fun `getSubscriptionTopic`(`seed`: String, `uniqueTime`: String, `state`: ByteArray): String {
return FfiConverterString.lift(
rustCallWithError(SphinxException) { _status ->
_UniFFILib.INSTANCE.uniffi_sphinxrs_fn_func_get_subscription_topic(FfiConverterString.lower(`seed`),FfiConverterString.lower(`uniqueTime`),FfiConverterByteArray.lower(`state`),_status)
})
}

@Throws(SphinxException::class)

fun `getTribeManagementTopic`(`seed`: String, `uniqueTime`: String, `state`: ByteArray): String {
return FfiConverterString.lift(
rustCallWithError(SphinxException) { _status ->
Expand All @@ -2476,10 +2464,10 @@ fun `getTribeManagementTopic`(`seed`: String, `uniqueTime`: String, `state`: Byt

@Throws(SphinxException::class)

fun `initialSetup`(`seed`: String, `uniqueTime`: String, `state`: ByteArray): RunReturn {
fun `initialSetup`(`seed`: String, `uniqueTime`: String, `state`: ByteArray, `device`: String): RunReturn {
return FfiConverterTypeRunReturn.lift(
rustCallWithError(SphinxException) { _status ->
_UniFFILib.INSTANCE.uniffi_sphinxrs_fn_func_initial_setup(FfiConverterString.lower(`seed`),FfiConverterString.lower(`uniqueTime`),FfiConverterByteArray.lower(`state`),_status)
_UniFFILib.INSTANCE.uniffi_sphinxrs_fn_func_initial_setup(FfiConverterString.lower(`seed`),FfiConverterString.lower(`uniqueTime`),FfiConverterByteArray.lower(`state`),FfiConverterString.lower(`device`),_status)
})
}

Expand Down

0 comments on commit fa49513

Please sign in to comment.