diff --git a/tests/v2/test_waku_swap.nim b/tests/v2/test_waku_swap.nim index 83869f875..4f0ff6e25 100644 --- a/tests/v2/test_waku_swap.nim +++ b/tests/v2/test_waku_swap.nim @@ -11,7 +11,8 @@ import libp2p/transports/transport, libp2p/transports/tcptransport, eth/keys, - ../../waku/v2/protocol/[waku_store, message_notifier, waku_swap], + ../../waku/v2/protocol/[waku_store, message_notifier], + ../../waku/v2/protocol/waku_swap/waku_swap, ../../waku/v2/node/message_store, ../../waku/v2/node/wakunode2, ../test_helpers, ./utils, diff --git a/waku/v2/node/wakunode2.nim b/waku/v2/node/wakunode2.nim index c178d891a..08bf7c175 100644 --- a/waku/v2/node/wakunode2.nim +++ b/waku/v2/node/wakunode2.nim @@ -10,7 +10,8 @@ import libp2p/protocols/pubsub/pubsub, libp2p/peerinfo, libp2p/standard_setup, - ../protocol/[waku_relay, waku_store, waku_filter, waku_swap, message_notifier], + ../protocol/[waku_relay, waku_store, waku_filter, message_notifier], + ../protocol/waku_swap/waku_swap, ../waku_types, ./message_store diff --git a/waku/v2/protocol/waku_store.nim b/waku/v2/protocol/waku_store.nim index f672f64d9..dfb593e54 100644 --- a/waku/v2/protocol/waku_store.nim +++ b/waku/v2/protocol/waku_store.nim @@ -9,6 +9,7 @@ import libp2p/stream/connection, ./message_notifier, ../node/message_store, + waku_swap/waku_swap, ../waku_types logScope: diff --git a/waku/v2/protocol/waku_swap.nim b/waku/v2/protocol/waku_swap/waku_swap.nim similarity index 97% rename from waku/v2/protocol/waku_swap.nim rename to waku/v2/protocol/waku_swap/waku_swap.nim index 0676ab263..d63cbeb68 100644 --- a/waku/v2/protocol/waku_swap.nim +++ b/waku/v2/protocol/waku_swap/waku_swap.nim @@ -30,10 +30,10 @@ import libp2p/protocols/protocol, libp2p/protobuf/minprotobuf, libp2p/stream/connection, - ./message_notifier, - ../waku_types + ../message_notifier, + waku_swap_types -export waku_types +export waku_swap_types logScope: topics = "wakuswap" diff --git a/waku/v2/protocol/waku_swap/waku_swap_types.nim b/waku/v2/protocol/waku_swap/waku_swap_types.nim new file mode 100644 index 000000000..1e7c76d66 --- /dev/null +++ b/waku/v2/protocol/waku_swap/waku_swap_types.nim @@ -0,0 +1,28 @@ +import + std/tables, + bearssl, + libp2p/protocols/protocol, + libp2p/switch, + libp2p/peerinfo + +type + Beneficiary* = seq[byte] + + # TODO Consider adding payment threshhold and terms field + Handshake* = object + beneficiary*: Beneficiary + + Cheque* = object + beneficiary*: Beneficiary + date*: uint32 + amount*: uint32 + + AccountHandler* = proc (peerId: PeerId, amount: int) {.gcsafe, closure.} + + WakuSwap* = ref object of LPProtocol + switch*: Switch + rng*: ref BrHmacDrbgContext + #peers*: seq[PeerInfo] + text*: string + accounting*: Table[PeerId, int] + accountFor*: AccountHandler diff --git a/waku/v2/waku_types.nim b/waku/v2/waku_types.nim index 7f71e95e3..8ee4f3bc1 100644 --- a/waku/v2/waku_types.nim +++ b/waku/v2/waku_types.nim @@ -11,6 +11,7 @@ import libp2p/switch, libp2p/stream/connection, libp2p/protocols/pubsub/[pubsub, gossipsub], + protocol/waku_swap/waku_swap_types, nimcrypto/sha2, sqlite3_abi @@ -40,7 +41,6 @@ type QueryHandlerFunc* = proc(response: HistoryResponse) {.gcsafe, closure.} - Index* = object ## This type contains the description of an Index used in the pagination of WakuMessages digest*: MDigest[256] @@ -134,16 +134,6 @@ type # @TODO MAYBE MORE INFO? Filters* = Table[string, Filter] - AccountHandler* = proc (peerId: PeerId, amount: int) {.gcsafe, closure.} - - WakuSwap* = ref object of LPProtocol - switch*: Switch - rng*: ref BrHmacDrbgContext - #peers*: seq[PeerInfo] - text*: string - accounting*: Table[PeerId, int] - accountFor*: AccountHandler - # NOTE based on Eth2Node in NBC eth2_network.nim WakuNode* = ref object of RootObj switch*: Switch @@ -169,20 +159,6 @@ type WakuResult*[T] = Result[T, cstring] - Beneficiary* = seq[byte] - - # TODO Consider adding payment threshhold and terms field - Handshake* = object - beneficiary*: Beneficiary - - Cheque* = object - beneficiary*: Beneficiary - date*: uint32 - amount*: uint32 - - AccountUpdateFunc* = proc(peerId: PeerId, amount: int) {.gcsafe.} - - # Encoding and decoding ------------------------------------------------------- # TODO Move out to to waku_message module # Possibly same with util functions