From 9e999527e577749fdd8edfffb8615092565b5cae Mon Sep 17 00:00:00 2001 From: Jazz Turner-Baggs <473256+jazzz@users.noreply.github.com> Date: Wed, 17 Dec 2025 19:15:47 -0800 Subject: [PATCH] Update API Delivery Service (#44) * Remove WakuCfg from Client * Update examples --- examples/bot_echo.nim | 5 ++--- examples/pingpong.nim | 10 ++++------ src/chat/client.nim | 5 ++--- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/examples/bot_echo.nim b/examples/bot_echo.nim index fa59987..0e78481 100644 --- a/examples/bot_echo.nim +++ b/examples/bot_echo.nim @@ -7,10 +7,9 @@ import chat import content_types proc main() {.async.} = - - let dsConfig = DefaultConfig() + let waku = initWakuClient(DefaultConfig()) let ident = createIdentity("EchoBot") - var chatClient = newClient(dsConfig, ident) + var chatClient = newClient(waku, ident) chatClient.onNewMessage(proc(convo: Conversation, msg: ReceivedMessage) {.async.} = info "New Message: ", convoId = convo.id(), msg= msg diff --git a/examples/pingpong.nim b/examples/pingpong.nim index 83a457a..8f07f19 100644 --- a/examples/pingpong.nim +++ b/examples/pingpong.nim @@ -25,17 +25,15 @@ proc fromBytes(bytes: seq[byte]): ContentFrame = proc main() {.async.} = # Create Configurations - var cfg_saro = DefaultConfig() - var cfg_raya = DefaultConfig() + var waku_saro = initWakuClient(DefaultConfig()) + var waku_raya = initWakuClient(DefaultConfig()) let sKey = loadPrivateKeyFromBytes(@[45u8, 216, 160, 24, 19, 207, 193, 214, 98, 92, 153, 145, 222, 247, 101, 99, 96, 131, 149, 185, 33, 187, 229, 251, 100, 158, 20, 131, 111, 97, 181, 210]).get() let rKey = loadPrivateKeyFromBytes(@[43u8, 12, 160, 51, 212, 90, 199, 160, 154, 164, 129, 229, 147, 69, 151, 17, 239, 51, 190, 33, 86, 164, 50, 105, 39, 250, 182, 116, 138, 132, 114, 234]).get() - let sIdent = Identity(name: "saro", privateKey: sKey) - # Create Clients - var saro = newClient(cfg_saro, sIdent) - var raya = newClient(cfg_raya, Identity(name: "raya", privateKey: rKey)) + var saro = newClient(waku_saro, Identity(name: "saro", privateKey: sKey)) + var raya = newClient(waku_raya, Identity(name: "raya", privateKey: rKey)) var ri = 0 # Wire Callbacks diff --git a/src/chat/client.nim b/src/chat/client.nim index 02e2c73..b561a62 100644 --- a/src/chat/client.nim +++ b/src/chat/client.nim @@ -64,11 +64,10 @@ type Client* = ref object # Constructors ################################################# -proc newClient*(cfg: WakuConfig, ident: Identity): Client {.raises: [IOError, +proc newClient*(ds: WakuClient, ident: Identity): Client {.raises: [IOError, ValueError, SerializationError].} = ## Creates new instance of a `Client` with a given `WakuConfig` try: - let waku = initWakuClient(cfg) let rm = newReliabilityManager().valueOr: raise newException(ValueError, fmt"SDS InitializationError") @@ -76,7 +75,7 @@ proc newClient*(cfg: WakuConfig, ident: Identity): Client {.raises: [IOError, var q = QueueRef(queue: newAsyncQueue[ChatPayload](10)) var c = Client(ident: ident, - ds: waku, + ds: ds, keyStore: initTable[string, KeyEntry](), conversations: initTable[string, Conversation](), inboundQueue: q,