Skip to content

Commit

Permalink
Create ibc_protocol.py
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Aug 7, 2024
1 parent 5a628ae commit 22d67f1
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions projects/DAPIO/interoperability/ibc/ibc_protocol.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import json

class IBCProtocol:
def __init__(self, connector: IBCConnector):
self.connector = connector

def send_request(self, request: dict) -> dict:
message = json.dumps(request)
self.connector.send_message(message, self.connector.establish_connection())
response = self.connector.receive_message(self.connector.establish_connection())
return json.loads(response)

def receive_request(self) -> dict:
message = self.connector.receive_message(self.connector.establish_connection())
return json.loads(message)

def send_response(self, response: dict) -> None:
message = json.dumps(response)
self.connector.send_message(message, self.connector.establish_connection())

0 comments on commit 22d67f1

Please sign in to comment.