Skip to content

Commit

Permalink
update_tribe, delete_tribe, fix sync contact for self msgs
Browse files Browse the repository at this point in the history
  • Loading branch information
Evanfeenstra committed Jun 7, 2024
1 parent 61d0edf commit 7f72827
Show file tree
Hide file tree
Showing 6 changed files with 115 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 = "0d40771c9a5efcdbd7fe9357bfdc77a44e8ade0a", features = [
sphinx = { git = "https://github.com/stakwork/sphinx", rev = "b51771ba9a8b5e4742cc8818136410a8f719ba17", features = [
"msg",
"bindings",
] }
Expand Down
36 changes: 36 additions & 0 deletions sphinx-ffi/src/auto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,42 @@ pub fn create_tribe(
.into())
}

pub fn update_tribe(
seed: String,
unique_time: String,
full_state: Vec<u8>,
tribe_server_pubkey: String,
tribe_json: String,
) -> Result<RunReturn> {
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<u8>,
tribe_server_pubkey: String,
tribe_pubkey: String,
) -> Result<RunReturn> {
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,
Expand Down
32 changes: 32 additions & 0 deletions sphinx-ffi/src/sphinxrs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
4 changes: 4 additions & 0 deletions sphinx-ffi/src/sphinxrs.udl
Original file line number Diff line number Diff line change
Expand Up @@ -239,4 +239,8 @@ namespace sphinxrs {
RunReturn get_tags(string seed, string unique_time, bytes state, sequence<string> tags, string? pubkey);
[Throws=SphinxError]
RunReturn delete_msgs(string seed, string unique_time, bytes state, string? pubkey, sequence<u64>? 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);
};
10 changes: 10 additions & 0 deletions sphinx-ffi/src/sphinxrsFFI.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
32 changes: 32 additions & 0 deletions sphinx-ffi/src/uniffi/sphinxrs/sphinxrs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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

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


0 comments on commit 7f72827

Please sign in to comment.