Skip to content

Commit 492ae4c

Browse files
committed
refactor(ffi): expose satschip stepwise wait via wait
1 parent 257fc83 commit 492ae4c

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

cktap-ffi/src/sats_chip.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,9 @@ impl SatsChip {
4747
read(&mut *card, None).await
4848
}
4949

50-
pub async fn wait(&self) -> Result<(), CkTapError> {
50+
pub async fn wait(&self) -> Result<Option<u8>, CkTapError> {
5151
let mut card = self.0.lock().await;
52-
// if auth delay call wait
53-
while card.auth_delay().is_some() {
54-
card.wait(None).await?;
55-
}
56-
Ok(())
52+
card.wait(None).await.map_err(CkTapError::from)
5753
}
5854

5955
pub async fn check_cert(&self) -> Result<(), CertsError> {

cktap-swift/Sources/CKTap/cktap_ffi.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,7 @@ public protocol SatsChipProtocol: AnyObject, Sendable {
922922

923923
func status() async -> SatsChipStatus
924924

925-
func wait() async throws
925+
func wait() async throws -> UInt8?
926926

927927
func xpub(master: Bool, cvc: String) async throws -> String
928928

@@ -1112,7 +1112,7 @@ open func status()async -> SatsChipStatus {
11121112
)
11131113
}
11141114

1115-
open func wait()async throws {
1115+
open func wait()async throws -> UInt8? {
11161116
return
11171117
try await uniffiRustCallAsync(
11181118
rustFutureFunc: {
@@ -1121,10 +1121,10 @@ open func wait()async throws {
11211121

11221122
)
11231123
},
1124-
pollFunc: ffi_cktap_ffi_rust_future_poll_void,
1125-
completeFunc: ffi_cktap_ffi_rust_future_complete_void,
1126-
freeFunc: ffi_cktap_ffi_rust_future_free_void,
1127-
liftFunc: { $0 },
1124+
pollFunc: ffi_cktap_ffi_rust_future_poll_rust_buffer,
1125+
completeFunc: ffi_cktap_ffi_rust_future_complete_rust_buffer,
1126+
freeFunc: ffi_cktap_ffi_rust_future_free_rust_buffer,
1127+
liftFunc: FfiConverterOptionUInt8.lift,
11281128
errorHandler: FfiConverterTypeCkTapError_lift
11291129
)
11301130
}
@@ -3775,7 +3775,7 @@ private let initializationResult: InitializationResult = {
37753775
if (uniffi_cktap_ffi_checksum_method_satschip_status() != 14916) {
37763776
return InitializationResult.apiChecksumMismatch
37773777
}
3778-
if (uniffi_cktap_ffi_checksum_method_satschip_wait() != 25914) {
3778+
if (uniffi_cktap_ffi_checksum_method_satschip_wait() != 900) {
37793779
return InitializationResult.apiChecksumMismatch
37803780
}
37813781
if (uniffi_cktap_ffi_checksum_method_satschip_xpub() != 24217) {

0 commit comments

Comments
 (0)