Ivan FB e59703fad7
Migrate FFI to nim-ffi v0.2.0-rc.3 (typed procs, direct params)
Rewrite the C FFI over the new per-layer APIs using nim-ffi v0.2.0 typed
{.ffiCtor.}/{.ffiDtor.}/{.ffi.}/{.ffiEvent.} + CBOR, replacing the
hand-written cstring/JSON bridge and the declare/lifecycle scaffolding.

Final API shape from the start (no intermediate request wrappers):
- every {.ffi.} proc takes its parameters directly; the macro bundles them
  into the per-proc CBOR request, so no `*Request` objects are needed
- WakuMessage rides the wire directly (its fields are CBOR-serializable)
- multi-parameter {.ffiEvent.} via the rc.3 envelope synthesis
- events are fed by internal nim-broker listeners (no AppCallbacks)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-25 13:14:40 +02:00

35 lines
1.2 KiB
Nim

import std/json
import logos_delivery/waku/factory/waku_state_info
import tools/confutils/[cli_args, config_option_meta]
proc get_available_node_info_ids*(
self: LogosDelivery
): Future[Result[string, string]] {.ffi.} =
## All node-info item ids that can be queried with `get_node_info`.
return ok($self.waku.stateInfo.getAllPossibleInfoItemIds())
proc get_node_info*(
self: LogosDelivery, nodeInfoId: string
): Future[Result[string, string]] {.ffi.} =
let infoItemIdEnum =
try:
parseEnum[NodeInfoId](nodeInfoId)
except ValueError:
return err("Invalid node info id: " & nodeInfoId)
return ok(self.waku.stateInfo.getNodeInfoItem(infoItemIdEnum))
proc get_available_configs*(
self: LogosDelivery
): Future[Result[string, string]] {.ffi.} =
let optionMetas: seq[ConfigOptionMeta] = extractConfigOptionMeta(WakuNodeConf)
var configOptionDetails = newJArray()
for meta in optionMetas:
configOptionDetails.add(
%*{
meta.fieldName: meta.typeName & "(" & meta.defaultValue & ")", "desc": meta.desc
}
)
var jsonNode = newJObject()
jsonNode["configOptions"] = configOptionDetails
return ok(pretty(jsonNode))