Skip to content

Commit cd03eee

Browse files
committed
feat: add 'nfc' command to ffi bindings
1 parent a06b87e commit cd03eee

4 files changed

Lines changed: 36 additions & 3 deletions

File tree

cktap-ffi/src/sats_card.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::error::{
66
};
77
use crate::{ChainCode, PrivateKey, Psbt, PublicKey, check_cert, read};
88
use futures::lock::Mutex;
9-
use rust_cktap::shared::{Authentication, Wait};
9+
use rust_cktap::shared::{Authentication, Nfc, Wait};
1010
use std::sync::Arc;
1111

1212
#[derive(uniffi::Object)]
@@ -127,4 +127,10 @@ impl SatsCard {
127127
.map(|psbt| Psbt { inner: psbt })?;
128128
Ok(psbt)
129129
}
130+
131+
pub async fn nfc(&self) -> Result<String, CkTapError> {
132+
let mut card = self.0.lock().await;
133+
let url = card.nfc().await?;
134+
Ok(url)
135+
}
130136
}

cktap-ffi/src/sats_chip.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::error::{CertsError, ChangeError, CkTapError, DeriveError, ReadError,
55
use crate::tap_signer::{change, derive, init, sign_psbt};
66
use crate::{ChainCode, Psbt, PublicKey, check_cert, read};
77
use futures::lock::Mutex;
8-
use rust_cktap::shared::{Authentication, Wait};
8+
use rust_cktap::shared::{Authentication, Nfc, Wait};
99
use std::sync::Arc;
1010

1111
#[derive(uniffi::Object)]
@@ -79,4 +79,10 @@ impl SatsChip {
7979
change(&mut *card, new_cvc, cvc).await?;
8080
Ok(())
8181
}
82+
83+
pub async fn nfc(&self) -> Result<String, CkTapError> {
84+
let mut card = self.0.lock().await;
85+
let url = card.nfc().await?;
86+
Ok(url)
87+
}
8288
}

cktap-ffi/src/tap_signer.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use crate::error::{CertsError, ChangeError, CkTapError, DeriveError, ReadError, SignPsbtError};
55
use crate::{ChainCode, Psbt, PublicKey, check_cert, read};
66
use futures::lock::Mutex;
7-
use rust_cktap::shared::{Authentication, Wait};
7+
use rust_cktap::shared::{Authentication, Nfc, Wait};
88
use rust_cktap::tap_signer::TapSignerShared;
99
use std::sync::Arc;
1010

@@ -81,6 +81,12 @@ impl TapSigner {
8181
change(&mut *card, new_cvc, cvc).await?;
8282
Ok(())
8383
}
84+
85+
pub async fn nfc(&self) -> Result<String, CkTapError> {
86+
let mut card = self.0.lock().await;
87+
let url = card.nfc().await?;
88+
Ok(url)
89+
}
8490
}
8591

8692
pub async fn init(

cktap-swift/Tests/CKTapTests/CKTapTests.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,19 @@ final class CKTapTests: XCTestCase {
2929
XCTAssertEqual(status.ver, "1.0.3")
3030
}
3131
}
32+
func testNfcUrl() async throws {
33+
let cardEmulator = CardEmulator()
34+
let card = try await toCktap(transport: cardEmulator)
35+
switch card {
36+
case .satsCard(let satsCard):
37+
let url: String = try await satsCard.nfc()
38+
print("SatsCard url: \(url)")
39+
case .tapSigner(let tapSigner):
40+
let url: String = try await tapSigner.nfc()
41+
print("TapSigner url: \(url)")
42+
case .satsChip(let satsChip):
43+
let url: String = try await satsChip.nfc()
44+
print("SatsChip url: \(url)")
45+
}
46+
}
3247
}

0 commit comments

Comments
 (0)