Update API Delivery Service (#44)

* Remove WakuCfg from Client

* Update examples
This commit is contained in:
Jazz Turner-Baggs 2025-12-17 19:15:47 -08:00 committed by GitHub
parent 3eefe3ba5c
commit 9e999527e5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 12 deletions

View File

@ -7,10 +7,9 @@ import chat
import content_types import content_types
proc main() {.async.} = proc main() {.async.} =
let waku = initWakuClient(DefaultConfig())
let dsConfig = DefaultConfig()
let ident = createIdentity("EchoBot") let ident = createIdentity("EchoBot")
var chatClient = newClient(dsConfig, ident) var chatClient = newClient(waku, ident)
chatClient.onNewMessage(proc(convo: Conversation, msg: ReceivedMessage) {.async.} = chatClient.onNewMessage(proc(convo: Conversation, msg: ReceivedMessage) {.async.} =
info "New Message: ", convoId = convo.id(), msg= msg info "New Message: ", convoId = convo.id(), msg= msg

View File

@ -25,17 +25,15 @@ proc fromBytes(bytes: seq[byte]): ContentFrame =
proc main() {.async.} = proc main() {.async.} =
# Create Configurations # Create Configurations
var cfg_saro = DefaultConfig() var waku_saro = initWakuClient(DefaultConfig())
var cfg_raya = 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 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 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 # Create Clients
var saro = newClient(cfg_saro, sIdent) var saro = newClient(waku_saro, Identity(name: "saro", privateKey: sKey))
var raya = newClient(cfg_raya, Identity(name: "raya", privateKey: rKey)) var raya = newClient(waku_raya, Identity(name: "raya", privateKey: rKey))
var ri = 0 var ri = 0
# Wire Callbacks # Wire Callbacks

View File

@ -64,11 +64,10 @@ type Client* = ref object
# Constructors # Constructors
################################################# #################################################
proc newClient*(cfg: WakuConfig, ident: Identity): Client {.raises: [IOError, proc newClient*(ds: WakuClient, ident: Identity): Client {.raises: [IOError,
ValueError, SerializationError].} = ValueError, SerializationError].} =
## Creates new instance of a `Client` with a given `WakuConfig` ## Creates new instance of a `Client` with a given `WakuConfig`
try: try:
let waku = initWakuClient(cfg)
let rm = newReliabilityManager().valueOr: let rm = newReliabilityManager().valueOr:
raise newException(ValueError, fmt"SDS InitializationError") 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 q = QueueRef(queue: newAsyncQueue[ChatPayload](10))
var c = Client(ident: ident, var c = Client(ident: ident,
ds: waku, ds: ds,
keyStore: initTable[string, KeyEntry](), keyStore: initTable[string, KeyEntry](),
conversations: initTable[string, Conversation](), conversations: initTable[string, Conversation](),
inboundQueue: q, inboundQueue: q,