Skip to content
This repository was archived by the owner on Jan 19, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "bluefin_v2_client"
version = "2.5.0"
version = "2.5.1"
description = "Library to interact with Bluefin exchange protocol including its off-chain api-gateway and on-chain contracts"
readme = "README.md"
requires-python = ">=3.8"
Expand Down
74 changes: 42 additions & 32 deletions src/bluefin_v2_client/api_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,28 @@ async def close_session(self):

async def get(self, service_url, query={}, auth_required=False):
"""
Makes a GET request and returns the results
Inputs:
- service_url(str): the url to make the request to.
- query(dict): the get query.
- auth_required(bool): indicates whether authorization is required for the call or not.
Makes a GET request and returns the results
Inputs:
- service_url(str): the url to make the request to.
- query(dict): the get query.
- auth_required(bool): indicates whether authorization is required for the call or not.
"""

url = self._create_url(service_url)

response = None
if auth_required:
headers = {
'Authorization': 'Bearer {}'.format(self.auth_token),
'x-api-token': self.api_token or ''
}
if self.uuid:
headers['x-mm-id'] = self.uuid

response = await self.client.get(
url,
params=query,
headers={
"Authorization": "Bearer {}".format(self.auth_token)
if self.auth_token
else "",
"x-api-token": self.api_token or "",
"x-mm-id": self.uuid or "",
},
headers=headers
)
else:
response = await self.client.get(url, params=query)
Expand All @@ -51,22 +53,23 @@ async def get(self, service_url, query={}, auth_required=False):

async def post(self, service_url, data, auth_required=False, contentType=""):
"""
Makes a POST request and returns the results
Inputs:
- service_url(str): the url to make the request to.
- data(dict): the data to post with POST request.
- auth_required(bool): indicates whether authorization is required for the call or not.
Makes a POST request and returns the results
Inputs:
- service_url(str): the url to make the request to.
- data(dict): the data to post with POST request.
- auth_required(bool): indicates whether authorization is required for the call or not.
"""
url = self._create_url(service_url)
response = None
if auth_required:
headers = {
"Authorization": "Bearer {}".format(self.auth_token),
"x-mm-id": self.uuid or "",
'Authorization': 'Bearer {}'.format(self.auth_token)
}
if self.uuid:
headers['x-mm-id'] = self.uuid

if contentType is not "":
headers["Content-type"] = contentType
headers['Content-type'] = contentType

response = await self.client.post(url=url, data=data, headers=headers)
else:
Expand All @@ -78,35 +81,39 @@ async def post(self, service_url, data, auth_required=False, contentType=""):
else:
return response
except:
raise Exception("Error while posting to {}: {}".format(url, response))
raise Exception(
"Error while posting to {}: {}".format(url, response))

async def delete(self, service_url, data, auth_required=False):
"""
Makes a DELETE request and returns the results
Inputs:
- service_url(str): the url to make the request to.
- data(dict): the data to post with POST request.
- auth_required(bool): indicates whether authorization is required for the call or not.
Makes a DELETE request and returns the results
Inputs:
- service_url(str): the url to make the request to.
- data(dict): the data to post with POST request.
- auth_required(bool): indicates whether authorization is required for the call or not.
"""
url = self._create_url(service_url)

response = None
if auth_required:
headers = {
'Authorization': 'Bearer {}'.format(self.auth_token)
}
if self.uuid:
headers['x-mm-id'] = self.uuid

response = await self.client.delete(
url=url,
data=data,
headers={
"Authorization": "Bearer {}".format(self.auth_token),
"x-mm-id": self.uuid or "",
},
)
headers=headers)
else:
response = await self.client.delete(url=url, data=data)

try:
return await response.json()
except:
raise Exception("Error while posting to {}: {}".format(url, response))
raise Exception(
"Error while posting to {}: {}".format(url, response))

"""
Private methods
Expand All @@ -117,3 +124,6 @@ def _create_url(self, path):
Appends namespace to server url
"""
return "{}{}".format(self.server_url, path)

def set_uuid(self, uuid):
self.uuid = uuid
6 changes: 6 additions & 0 deletions src/bluefin_v2_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ async def onboard_user(self, token: str = None):

return user_auth_token


def set_uuid(self, uuid):
self.apis.set_uuid(uuid)
self.dms_api.set_uuid(uuid)


async def authorize_signed_hash(self, signed_hash: str):
"""
Registers user as an authorized user on server and returns authorization token.
Expand Down
11 changes: 11 additions & 0 deletions src/bluefin_v2_client/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"dmsURL": "https://api.sui-staging.bluefin.io/dead-man-switch",
"webSocketURL": "wss://notifications.api.sui-staging.bluefin.io",
"onboardingUrl": "https://testnet.bluefin.io",
"UUID": ""
},
"SUI_PROD": {
"url": "https://fullnode.testnet.sui.io:443",
Expand All @@ -14,6 +15,16 @@
"dmsURL": "https://api.sui-prod.bluefin.io/dead-man-switch",
"webSocketURL": "wss://notifications.api.sui-prod.bluefin.io",
"onboardingUrl": "https://trade-sui.bluefin.exchange",
"UUID": ""
},
"SUI_PROD_INTERNAL": {
"url": "https://fullnode.testnet.sui.io:443",
"apiGateway": "https://dapi.api.sui-prod.int.bluefin.io",
"socketURL": "wss://dapi.api.sui-prod.int.bluefin.io",
"dmsURL": "https://api.sui-prod.int.bluefin.io/dead-man-switch",
"webSocketURL": "wss://notifications.api.sui-prod.int.bluefin.io",
"onboardingUrl": "https://trade-sui.bluefin.exchange",
"UUID": ""
},
}

Expand Down