Skip to content

Commit

Permalink
Merge pull request #35 from stakwork/mobile-signer-cmd-vel
Browse files Browse the repository at this point in the history
build kotlin and swift
  • Loading branch information
Evanfeenstra authored Jul 28, 2023
2 parents aa8f527 + b9caf9f commit e44b89e
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 70 deletions.
6 changes: 3 additions & 3 deletions sphinx-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ lto = true # Enable Link Time Optimization
codegen-units = 1 # Reduce number of codegen units to increase optimizations.
debug = true # Enable debug symbols. For example, we can use `dwarfdump` to check crash traces.

# [[bin]]
# name = "uniffi-bindgen"
# path = "uniffi-bindgen.rs"
[[bin]]
name = "uniffi-bindgen"
path = "uniffi-bindgen.rs"
58 changes: 23 additions & 35 deletions sphinx-ffi/src/sphinxrs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -443,19 +443,17 @@ public func FfiConverterTypeKeys_lower(_ value: Keys) -> RustBuffer {

public struct VlsResponse {
public var `topic`: String
public var `vlsBytes`: Data?
public var `lssBytes`: Data?
public var `bytes`: Data
public var `sequence`: UInt16
public var `cmd`: String
public var `velocity`: Data?
public var `state`: Data?
public var `state`: Data

// Default memberwise initializers are never public by default, so we
// declare one manually.
public init(`topic`: String, `vlsBytes`: Data?, `lssBytes`: Data?, `sequence`: UInt16, `cmd`: String, `velocity`: Data?, `state`: Data?) {
public init(`topic`: String, `bytes`: Data, `sequence`: UInt16, `cmd`: String, `velocity`: Data?, `state`: Data) {
self.`topic` = `topic`
self.`vlsBytes` = `vlsBytes`
self.`lssBytes` = `lssBytes`
self.`bytes` = `bytes`
self.`sequence` = `sequence`
self.`cmd` = `cmd`
self.`velocity` = `velocity`
Expand All @@ -469,10 +467,7 @@ extension VlsResponse: Equatable, Hashable {
if lhs.`topic` != rhs.`topic` {
return false
}
if lhs.`vlsBytes` != rhs.`vlsBytes` {
return false
}
if lhs.`lssBytes` != rhs.`lssBytes` {
if lhs.`bytes` != rhs.`bytes` {
return false
}
if lhs.`sequence` != rhs.`sequence` {
Expand All @@ -492,8 +487,7 @@ extension VlsResponse: Equatable, Hashable {

public func hash(into hasher: inout Hasher) {
hasher.combine(`topic`)
hasher.combine(`vlsBytes`)
hasher.combine(`lssBytes`)
hasher.combine(`bytes`)
hasher.combine(`sequence`)
hasher.combine(`cmd`)
hasher.combine(`velocity`)
Expand All @@ -506,23 +500,21 @@ public struct FfiConverterTypeVlsResponse: FfiConverterRustBuffer {
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> VlsResponse {
return try VlsResponse(
`topic`: FfiConverterString.read(from: &buf),
`vlsBytes`: FfiConverterOptionData.read(from: &buf),
`lssBytes`: FfiConverterOptionData.read(from: &buf),
`bytes`: FfiConverterData.read(from: &buf),
`sequence`: FfiConverterUInt16.read(from: &buf),
`cmd`: FfiConverterString.read(from: &buf),
`velocity`: FfiConverterOptionData.read(from: &buf),
`state`: FfiConverterOptionData.read(from: &buf)
`state`: FfiConverterData.read(from: &buf)
)
}

public static func write(_ value: VlsResponse, into buf: inout [UInt8]) {
FfiConverterString.write(value.`topic`, into: &buf)
FfiConverterOptionData.write(value.`vlsBytes`, into: &buf)
FfiConverterOptionData.write(value.`lssBytes`, into: &buf)
FfiConverterData.write(value.`bytes`, into: &buf)
FfiConverterUInt16.write(value.`sequence`, into: &buf)
FfiConverterString.write(value.`cmd`, into: &buf)
FfiConverterOptionData.write(value.`velocity`, into: &buf)
FfiConverterOptionData.write(value.`state`, into: &buf)
FfiConverterData.write(value.`state`, into: &buf)
}
}

Expand Down Expand Up @@ -850,54 +842,50 @@ public func `parseResponse`(`res`: String) throws -> String {
)
}

public func `runInit1`(`args`: String, `state`: Data, `msg1`: Data) throws -> VlsResponse {
public func `runInit1`(`args`: String, `state`: Data, `msg1`: Data, `expectedSequence`: UInt16?) throws -> VlsResponse {
return try FfiConverterTypeVlsResponse.lift(
try rustCallWithError(FfiConverterTypeSphinxError.lift) {
uniffi_sphinxrs_fn_func_run_init_1(
FfiConverterString.lower(`args`),
FfiConverterData.lower(`state`),
FfiConverterData.lower(`msg1`),$0)
FfiConverterData.lower(`msg1`),
FfiConverterOptionUInt16.lower(`expectedSequence`),$0)
}
)
}

public func `runInit2`(`args`: String, `state`: Data, `msg1`: Data, `msg2`: Data) throws -> VlsResponse {
public func `runInit2`(`args`: String, `state`: Data, `msg2`: Data, `expectedSequence`: UInt16?) throws -> VlsResponse {
return try FfiConverterTypeVlsResponse.lift(
try rustCallWithError(FfiConverterTypeSphinxError.lift) {
uniffi_sphinxrs_fn_func_run_init_2(
FfiConverterString.lower(`args`),
FfiConverterData.lower(`state`),
FfiConverterData.lower(`msg1`),
FfiConverterData.lower(`msg2`),$0)
FfiConverterData.lower(`msg2`),
FfiConverterOptionUInt16.lower(`expectedSequence`),$0)
}
)
}

public func `runVls`(`args`: String, `state`: Data, `msg1`: Data, `msg2`: Data, `vlsMsg`: Data, `expectedSequence`: UInt16?) throws -> VlsResponse {
public func `runVls`(`args`: String, `state`: Data, `vlsMsg`: Data, `expectedSequence`: UInt16?) throws -> VlsResponse {
return try FfiConverterTypeVlsResponse.lift(
try rustCallWithError(FfiConverterTypeSphinxError.lift) {
uniffi_sphinxrs_fn_func_run_vls(
FfiConverterString.lower(`args`),
FfiConverterData.lower(`state`),
FfiConverterData.lower(`msg1`),
FfiConverterData.lower(`msg2`),
FfiConverterData.lower(`vlsMsg`),
FfiConverterOptionUInt16.lower(`expectedSequence`),$0)
}
)
}

public func `runLss`(`args`: String, `state`: Data, `msg1`: Data, `msg2`: Data, `lssMsg`: Data, `prevVls`: Data, `prevLss`: Data) throws -> VlsResponse {
public func `runLss`(`args`: String, `state`: Data, `lssMsg`: Data, `expectedSequence`: UInt16?) throws -> VlsResponse {
return try FfiConverterTypeVlsResponse.lift(
try rustCallWithError(FfiConverterTypeSphinxError.lift) {
uniffi_sphinxrs_fn_func_run_lss(
FfiConverterString.lower(`args`),
FfiConverterData.lower(`state`),
FfiConverterData.lower(`msg1`),
FfiConverterData.lower(`msg2`),
FfiConverterData.lower(`lssMsg`),
FfiConverterData.lower(`prevVls`),
FfiConverterData.lower(`prevLss`),$0)
FfiConverterOptionUInt16.lower(`expectedSequence`),$0)
}
)
}
Expand Down Expand Up @@ -954,16 +942,16 @@ private var initializationResult: InitializationResult {
if (uniffi_sphinxrs_checksum_func_parse_response() != 12980) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_sphinxrs_checksum_func_run_init_1() != 42322) {
if (uniffi_sphinxrs_checksum_func_run_init_1() != 44577) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_sphinxrs_checksum_func_run_init_2() != 13191) {
if (uniffi_sphinxrs_checksum_func_run_init_2() != 3141) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_sphinxrs_checksum_func_run_vls() != 35014) {
if (uniffi_sphinxrs_checksum_func_run_vls() != 7208) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_sphinxrs_checksum_func_run_lss() != 63303) {
if (uniffi_sphinxrs_checksum_func_run_lss() != 41202) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_sphinxrs_checksum_func_make_auth_token() != 13236) {
Expand Down
8 changes: 4 additions & 4 deletions sphinx-ffi/src/sphinxrsFFI.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ RustBuffer uniffi_sphinxrs_fn_func_build_request(RustBuffer msg, RustBuffer secr
);
RustBuffer uniffi_sphinxrs_fn_func_parse_response(RustBuffer res, RustCallStatus *_Nonnull out_status
);
RustBuffer uniffi_sphinxrs_fn_func_run_init_1(RustBuffer args, RustBuffer state, RustBuffer msg1, RustCallStatus *_Nonnull out_status
RustBuffer uniffi_sphinxrs_fn_func_run_init_1(RustBuffer args, RustBuffer state, RustBuffer msg1, RustBuffer expected_sequence, RustCallStatus *_Nonnull out_status
);
RustBuffer uniffi_sphinxrs_fn_func_run_init_2(RustBuffer args, RustBuffer state, RustBuffer msg1, RustBuffer msg2, RustCallStatus *_Nonnull out_status
RustBuffer uniffi_sphinxrs_fn_func_run_init_2(RustBuffer args, RustBuffer state, RustBuffer msg2, RustBuffer expected_sequence, RustCallStatus *_Nonnull out_status
);
RustBuffer uniffi_sphinxrs_fn_func_run_vls(RustBuffer args, RustBuffer state, RustBuffer msg1, RustBuffer msg2, RustBuffer vls_msg, RustBuffer expected_sequence, RustCallStatus *_Nonnull out_status
RustBuffer uniffi_sphinxrs_fn_func_run_vls(RustBuffer args, RustBuffer state, RustBuffer vls_msg, RustBuffer expected_sequence, RustCallStatus *_Nonnull out_status
);
RustBuffer uniffi_sphinxrs_fn_func_run_lss(RustBuffer args, RustBuffer state, RustBuffer msg1, RustBuffer msg2, RustBuffer lss_msg, RustBuffer prev_vls, RustBuffer prev_lss, RustCallStatus *_Nonnull out_status
RustBuffer uniffi_sphinxrs_fn_func_run_lss(RustBuffer args, RustBuffer state, RustBuffer lss_msg, RustBuffer expected_sequence, RustCallStatus *_Nonnull out_status
);
RustBuffer uniffi_sphinxrs_fn_func_make_auth_token(uint32_t ts, RustBuffer secret, RustCallStatus *_Nonnull out_status
);
Expand Down
52 changes: 24 additions & 28 deletions sphinx-ffi/src/uniffi/sphinxrs/sphinxrs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -382,13 +382,13 @@ internal interface _UniFFILib : Library {
): RustBuffer.ByValue
fun uniffi_sphinxrs_fn_func_parse_response(`res`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus,
): RustBuffer.ByValue
fun uniffi_sphinxrs_fn_func_run_init_1(`args`: RustBuffer.ByValue,`state`: RustBuffer.ByValue,`msg1`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus,
fun uniffi_sphinxrs_fn_func_run_init_1(`args`: RustBuffer.ByValue,`state`: RustBuffer.ByValue,`msg1`: RustBuffer.ByValue,`expectedSequence`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus,
): RustBuffer.ByValue
fun uniffi_sphinxrs_fn_func_run_init_2(`args`: RustBuffer.ByValue,`state`: RustBuffer.ByValue,`msg1`: RustBuffer.ByValue,`msg2`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus,
fun uniffi_sphinxrs_fn_func_run_init_2(`args`: RustBuffer.ByValue,`state`: RustBuffer.ByValue,`msg2`: RustBuffer.ByValue,`expectedSequence`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus,
): RustBuffer.ByValue
fun uniffi_sphinxrs_fn_func_run_vls(`args`: RustBuffer.ByValue,`state`: RustBuffer.ByValue,`msg1`: RustBuffer.ByValue,`msg2`: RustBuffer.ByValue,`vlsMsg`: RustBuffer.ByValue,`expectedSequence`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus,
fun uniffi_sphinxrs_fn_func_run_vls(`args`: RustBuffer.ByValue,`state`: RustBuffer.ByValue,`vlsMsg`: RustBuffer.ByValue,`expectedSequence`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus,
): RustBuffer.ByValue
fun uniffi_sphinxrs_fn_func_run_lss(`args`: RustBuffer.ByValue,`state`: RustBuffer.ByValue,`msg1`: RustBuffer.ByValue,`msg2`: RustBuffer.ByValue,`lssMsg`: RustBuffer.ByValue,`prevVls`: RustBuffer.ByValue,`prevLss`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus,
fun uniffi_sphinxrs_fn_func_run_lss(`args`: RustBuffer.ByValue,`state`: RustBuffer.ByValue,`lssMsg`: RustBuffer.ByValue,`expectedSequence`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus,
): RustBuffer.ByValue
fun uniffi_sphinxrs_fn_func_make_auth_token(`ts`: Int,`secret`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus,
): RustBuffer.ByValue
Expand Down Expand Up @@ -472,16 +472,16 @@ private fun uniffiCheckApiChecksums(lib: _UniFFILib) {
if (lib.uniffi_sphinxrs_checksum_func_parse_response() != 12980.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
if (lib.uniffi_sphinxrs_checksum_func_run_init_1() != 42322.toShort()) {
if (lib.uniffi_sphinxrs_checksum_func_run_init_1() != 44577.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
if (lib.uniffi_sphinxrs_checksum_func_run_init_2() != 13191.toShort()) {
if (lib.uniffi_sphinxrs_checksum_func_run_init_2() != 3141.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
if (lib.uniffi_sphinxrs_checksum_func_run_vls() != 35014.toShort()) {
if (lib.uniffi_sphinxrs_checksum_func_run_vls() != 7208.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
if (lib.uniffi_sphinxrs_checksum_func_run_lss() != 63303.toShort()) {
if (lib.uniffi_sphinxrs_checksum_func_run_lss() != 41202.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
if (lib.uniffi_sphinxrs_checksum_func_make_auth_token() != 13236.toShort()) {
Expand Down Expand Up @@ -648,12 +648,11 @@ public object FfiConverterTypeKeys: FfiConverterRustBuffer<Keys> {

data class VlsResponse (
var `topic`: String,
var `vlsBytes`: ByteArray?,
var `lssBytes`: ByteArray?,
var `bytes`: ByteArray,
var `sequence`: UShort,
var `cmd`: String,
var `velocity`: ByteArray?,
var `state`: ByteArray?
var `state`: ByteArray
) {

}
Expand All @@ -662,33 +661,30 @@ public object FfiConverterTypeVlsResponse: FfiConverterRustBuffer<VlsResponse> {
override fun read(buf: ByteBuffer): VlsResponse {
return VlsResponse(
FfiConverterString.read(buf),
FfiConverterOptionalByteArray.read(buf),
FfiConverterOptionalByteArray.read(buf),
FfiConverterByteArray.read(buf),
FfiConverterUShort.read(buf),
FfiConverterString.read(buf),
FfiConverterOptionalByteArray.read(buf),
FfiConverterOptionalByteArray.read(buf),
FfiConverterByteArray.read(buf),
)
}

override fun allocationSize(value: VlsResponse) = (
FfiConverterString.allocationSize(value.`topic`) +
FfiConverterOptionalByteArray.allocationSize(value.`vlsBytes`) +
FfiConverterOptionalByteArray.allocationSize(value.`lssBytes`) +
FfiConverterByteArray.allocationSize(value.`bytes`) +
FfiConverterUShort.allocationSize(value.`sequence`) +
FfiConverterString.allocationSize(value.`cmd`) +
FfiConverterOptionalByteArray.allocationSize(value.`velocity`) +
FfiConverterOptionalByteArray.allocationSize(value.`state`)
FfiConverterByteArray.allocationSize(value.`state`)
)

override fun write(value: VlsResponse, buf: ByteBuffer) {
FfiConverterString.write(value.`topic`, buf)
FfiConverterOptionalByteArray.write(value.`vlsBytes`, buf)
FfiConverterOptionalByteArray.write(value.`lssBytes`, buf)
FfiConverterByteArray.write(value.`bytes`, buf)
FfiConverterUShort.write(value.`sequence`, buf)
FfiConverterString.write(value.`cmd`, buf)
FfiConverterOptionalByteArray.write(value.`velocity`, buf)
FfiConverterOptionalByteArray.write(value.`state`, buf)
FfiConverterByteArray.write(value.`state`, buf)
}
}

Expand Down Expand Up @@ -1188,37 +1184,37 @@ fun `parseResponse`(`res`: String): String {

@Throws(SphinxException::class)

fun `runInit1`(`args`: String, `state`: ByteArray, `msg1`: ByteArray): VlsResponse {
fun `runInit1`(`args`: String, `state`: ByteArray, `msg1`: ByteArray, `expectedSequence`: UShort?): VlsResponse {
return FfiConverterTypeVlsResponse.lift(
rustCallWithError(SphinxException) { _status ->
_UniFFILib.INSTANCE.uniffi_sphinxrs_fn_func_run_init_1(FfiConverterString.lower(`args`),FfiConverterByteArray.lower(`state`),FfiConverterByteArray.lower(`msg1`),_status)
_UniFFILib.INSTANCE.uniffi_sphinxrs_fn_func_run_init_1(FfiConverterString.lower(`args`),FfiConverterByteArray.lower(`state`),FfiConverterByteArray.lower(`msg1`),FfiConverterOptionalUShort.lower(`expectedSequence`),_status)
})
}

@Throws(SphinxException::class)

fun `runInit2`(`args`: String, `state`: ByteArray, `msg1`: ByteArray, `msg2`: ByteArray): VlsResponse {
fun `runInit2`(`args`: String, `state`: ByteArray, `msg2`: ByteArray, `expectedSequence`: UShort?): VlsResponse {
return FfiConverterTypeVlsResponse.lift(
rustCallWithError(SphinxException) { _status ->
_UniFFILib.INSTANCE.uniffi_sphinxrs_fn_func_run_init_2(FfiConverterString.lower(`args`),FfiConverterByteArray.lower(`state`),FfiConverterByteArray.lower(`msg1`),FfiConverterByteArray.lower(`msg2`),_status)
_UniFFILib.INSTANCE.uniffi_sphinxrs_fn_func_run_init_2(FfiConverterString.lower(`args`),FfiConverterByteArray.lower(`state`),FfiConverterByteArray.lower(`msg2`),FfiConverterOptionalUShort.lower(`expectedSequence`),_status)
})
}

@Throws(SphinxException::class)

fun `runVls`(`args`: String, `state`: ByteArray, `msg1`: ByteArray, `msg2`: ByteArray, `vlsMsg`: ByteArray, `expectedSequence`: UShort?): VlsResponse {
fun `runVls`(`args`: String, `state`: ByteArray, `vlsMsg`: ByteArray, `expectedSequence`: UShort?): VlsResponse {
return FfiConverterTypeVlsResponse.lift(
rustCallWithError(SphinxException) { _status ->
_UniFFILib.INSTANCE.uniffi_sphinxrs_fn_func_run_vls(FfiConverterString.lower(`args`),FfiConverterByteArray.lower(`state`),FfiConverterByteArray.lower(`msg1`),FfiConverterByteArray.lower(`msg2`),FfiConverterByteArray.lower(`vlsMsg`),FfiConverterOptionalUShort.lower(`expectedSequence`),_status)
_UniFFILib.INSTANCE.uniffi_sphinxrs_fn_func_run_vls(FfiConverterString.lower(`args`),FfiConverterByteArray.lower(`state`),FfiConverterByteArray.lower(`vlsMsg`),FfiConverterOptionalUShort.lower(`expectedSequence`),_status)
})
}

@Throws(SphinxException::class)

fun `runLss`(`args`: String, `state`: ByteArray, `msg1`: ByteArray, `msg2`: ByteArray, `lssMsg`: ByteArray, `prevVls`: ByteArray, `prevLss`: ByteArray): VlsResponse {
fun `runLss`(`args`: String, `state`: ByteArray, `lssMsg`: ByteArray, `expectedSequence`: UShort?): VlsResponse {
return FfiConverterTypeVlsResponse.lift(
rustCallWithError(SphinxException) { _status ->
_UniFFILib.INSTANCE.uniffi_sphinxrs_fn_func_run_lss(FfiConverterString.lower(`args`),FfiConverterByteArray.lower(`state`),FfiConverterByteArray.lower(`msg1`),FfiConverterByteArray.lower(`msg2`),FfiConverterByteArray.lower(`lssMsg`),FfiConverterByteArray.lower(`prevVls`),FfiConverterByteArray.lower(`prevLss`),_status)
_UniFFILib.INSTANCE.uniffi_sphinxrs_fn_func_run_lss(FfiConverterString.lower(`args`),FfiConverterByteArray.lower(`state`),FfiConverterByteArray.lower(`lssMsg`),FfiConverterOptionalUShort.lower(`expectedSequence`),_status)
})
}

Expand Down

0 comments on commit e44b89e

Please sign in to comment.