2025-12-22 14:14:37 +02:00
|
|
|
import ffi
|
2026-01-09 11:29:14 +02:00
|
|
|
import src/chat/client
|
2026-05-06 10:49:49 -06:00
|
|
|
import waku/waku_mix/logos_core_client as mix_rln_client
|
2025-12-22 14:14:37 +02:00
|
|
|
|
2026-02-13 20:44:50 +01:00
|
|
|
declareLibrary("logoschat")
|
2025-12-22 14:14:37 +02:00
|
|
|
|
|
|
|
|
proc set_event_callback(
|
2026-01-12 18:16:01 +02:00
|
|
|
ctx: ptr FFIContext[ChatClient],
|
2025-12-22 14:14:37 +02:00
|
|
|
callback: FFICallBack,
|
|
|
|
|
userData: pointer
|
|
|
|
|
) {.dynlib, exportc, cdecl.} =
|
|
|
|
|
ctx[].eventCallback = cast[pointer](callback)
|
|
|
|
|
ctx[].eventUserData = userData
|
|
|
|
|
|
2026-05-06 10:49:49 -06:00
|
|
|
proc chat_set_rln_fetcher(
|
|
|
|
|
ctx: ptr FFIContext[ChatClient], fetcher: mix_rln_client.RlnFetcherFunc, fetcherData: pointer
|
|
|
|
|
) {.dynlib, exportc, cdecl.} =
|
|
|
|
|
if fetcher.isNil:
|
|
|
|
|
echo "error: nil fetcher in chat_set_rln_fetcher"
|
|
|
|
|
return
|
|
|
|
|
mix_rln_client.setRlnFetcher(fetcher, fetcherData)
|
|
|
|
|
|
|
|
|
|
proc chat_set_rln_config(
|
|
|
|
|
ctx: ptr FFIContext[ChatClient], configAccountId: cstring, leafIndex: cint
|
|
|
|
|
): cint {.dynlib, exportc, cdecl.} =
|
|
|
|
|
if configAccountId.isNil:
|
|
|
|
|
return RET_ERR
|
|
|
|
|
mix_rln_client.setRlnConfig($configAccountId, leafIndex.int)
|
|
|
|
|
return RET_OK
|
|
|
|
|
|
|
|
|
|
proc chat_set_rln_identity(
|
|
|
|
|
ctx: ptr FFIContext[ChatClient], idSecretHashHex: cstring
|
|
|
|
|
) {.dynlib, exportc, cdecl.} =
|
|
|
|
|
if idSecretHashHex.isNil:
|
|
|
|
|
return
|
|
|
|
|
mix_rln_client.setRlnIdentity($idSecretHashHex)
|
|
|
|
|
|
|
|
|
|
proc chat_push_roots(
|
|
|
|
|
ctx: ptr FFIContext[ChatClient], rootsJson: cstring
|
|
|
|
|
) {.dynlib, exportc, cdecl.} =
|
|
|
|
|
if rootsJson.isNil:
|
|
|
|
|
return
|
|
|
|
|
mix_rln_client.pushRoots($rootsJson)
|
|
|
|
|
|
|
|
|
|
proc chat_push_proof(
|
|
|
|
|
ctx: ptr FFIContext[ChatClient], proofJson: cstring
|
|
|
|
|
) {.dynlib, exportc, cdecl.} =
|
|
|
|
|
if proofJson.isNil:
|
|
|
|
|
return
|
|
|
|
|
mix_rln_client.pushProof($proofJson)
|
|
|
|
|
|