Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add api v2 methods #6

Merged
merged 1 commit into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion keycard_go.nim
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ proc keycardCancelFlow*(): string =
defer: go_shim.free(funcOut)
return $funcOut

proc keycardInitializeRPC*(): string =
var funcOut = go_shim.keycardInitializeRPC()
defer: go_shim.free(funcOut)
return $funcOut

proc keycardCallRPC*(params: string): string =
var funcOut = go_shim.keycardCallRPC(params.cstring)
defer: go_shim.free(funcOut)
return $funcOut

proc setSignalEventCallback*(callback: KeycardSignalCallback) =
go_shim.setSignalEventCallback(callback)

Expand Down Expand Up @@ -49,4 +59,4 @@ proc mockedLibKeycardInserted*(cardIndex: int): string =
proc mockedLibKeycardRemoved*(): string =
var funcOut = go_shim.mockedLibKeycardRemoved()
defer: go_shim.free(funcOut)
return $funcOut
return $funcOut
6 changes: 5 additions & 1 deletion keycard_go/impl.nim
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# go functions do not raise nim exceptions and do not interact with the Nim gc
{.push raises: [], gcsafe.}

# NOTE: Methods here begin with "Keycard" to avoid name conflicts with status-go

type KeycardSignalCallback* = proc(signal: cstring): void {.cdecl, gcsafe, raises: [].}

proc free*(param: pointer) {.importc: "Free".}
Expand All @@ -10,10 +12,12 @@ proc keycardInitFlow*(storageDir: cstring): cstring {.importc: "KeycardInitFlow"
proc keycardStartFlow*(flowType: cint, jsonParams: cstring): cstring {.importc: "KeycardStartFlow".}
proc keycardResumeFlow*(jsonParams: cstring): cstring {.importc: "KeycardResumeFlow".}
proc keycardCancelFlow*(): cstring {.importc: "KeycardCancelFlow".}
proc keycardInitializeRPC*(): cstring {.importc: "KeycardInitializeRPC".}
proc keycardCallRPC*(params: cstring): cstring {.importc: "KeycardCallRPC".}

# availale in test mode only
proc mockedLibRegisterKeycard*(cardIndex: cint, readerState: cint, keycardState: cint, mockedKeycard: cstring, mockedKeycardHelper: cstring): cstring {.importc: "MockedLibRegisterKeycard".}
proc mockedLibReaderPluggedIn*(): cstring {.importc: "MockedLibReaderPluggedIn".}
proc mockedLibReaderUnplugged*(): cstring {.importc: "MockedLibReaderUnplugged".}
proc mockedLibKeycardInserted*(cardIndex: cint): cstring {.importc: "MockedLibKeycardInserted".}
proc mockedLibKeycardRemoved*(): cstring {.importc: "MockedLibKeycardRemoved".}
proc mockedLibKeycardRemoved*(): cstring {.importc: "MockedLibKeycardRemoved".}