Skip to content

Commit

Permalink
Add Graphene connector for Peerplays, BitShares and other graphene-ba…
Browse files Browse the repository at this point in the history
…sed blockchains.
  • Loading branch information
squidKid-deluxe committed Jun 16, 2024
1 parent 691913f commit 4383d99
Show file tree
Hide file tree
Showing 22 changed files with 3,238 additions and 9 deletions.
8 changes: 7 additions & 1 deletion hummingbot/client/command/connect_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,16 @@ async def validate_n_connect_connector(
await Security.wait_til_decryption_done()
api_keys = Security.api_keys(connector_name)
network_timeout = float(self.client_config_map.commands_timeout.other_commands_timeout)
graphene_timeout = float(self.client_config_map.commands_timeout.graphene_timeout)
try:
err_msg = await asyncio.wait_for(
UserBalances.instance().add_exchange(connector_name, self.client_config_map, **api_keys),
network_timeout,
(
network_timeout
if connector_name not in
["bitshares", "peerplays", "bitshares testnet", "peerplays testnet"]
else graphene_timeout
),
)
except asyncio.TimeoutError:
self.notify(
Expand Down
2 changes: 2 additions & 0 deletions hummingbot/client/command/exit_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import asyncio
from typing import TYPE_CHECKING

from hummingbot.connector.exchange.graphene.graphene_exchange import kill_metanode
from hummingbot.core.utils.async_utils import safe_ensure_future

if TYPE_CHECKING:
Expand All @@ -12,6 +13,7 @@
class ExitCommand:
def exit(self, # type: HummingbotApplication
force: bool = False):
kill_metanode()
safe_ensure_future(self.exit_loop(force), loop=self.ev_loop)

async def exit_loop(self, # type: HummingbotApplication
Expand Down
14 changes: 13 additions & 1 deletion hummingbot/client/command/status_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,20 @@ async def status_check_all(self, # type: HummingbotApplication
return False

network_timeout = float(self.client_config_map.commands_timeout.other_commands_timeout)
graphene_timeout = float(self.client_config_map.commands_timeout.graphene_timeout)
try:
invalid_conns = await asyncio.wait_for(self.validate_required_connections(), network_timeout)
invalid_conns = await asyncio.wait_for(
self.validate_required_connections(),
(
network_timeout if not any(
[
i in ["bitshares", "peerplays", "bitshares testnet", "peerplays testnet"]
for i in required_exchanges
]
)
else graphene_timeout
)
)
except asyncio.TimeoutError:
self.notify("\nA network error prevented the connection check to complete. See logs for more details.")
raise
Expand Down
12 changes: 11 additions & 1 deletion hummingbot/client/config/client_config_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ class GlobalTokenConfigMap(BaseClientModel):
default="$",
client_data=ClientFieldData(
prompt=lambda
cm: "What is your default display token symbol? (e.g. $,)",
cm: "What is your default display token symbol? (e.g. $, €, ₿, ¤)",
),
)

Expand Down Expand Up @@ -652,13 +652,23 @@ class CommandsTimeoutConfigMap(BaseClientModel):
),
),
)
graphene_timeout: Decimal = Field(
default=Decimal("120"),
gt=Decimal("0"),
client_data=ClientFieldData(
prompt=lambda cm: (
"Network timeout to apply to the starting and status checking of graphene"
),
)
)

class Config:
title = "commands_timeout"

@validator(
"create_command_timeout",
"other_commands_timeout",
"graphene_timeout",
pre=True,
)
def validate_decimals(cls, v: str, field: Field):
Expand Down
13 changes: 7 additions & 6 deletions hummingbot/client/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,9 @@ def add_domain_parameter(self, params: Dict[str, Any]) -> Dict[str, Any]:

def base_name(self) -> str:
if self.is_sub_domain:
return self.parent_name
return self.parent_name if self.parent_name not in ["peerplays", "bitshares", "peerplays testnet", "bitshares testnet"] else "graphene"
else:
return self.name
return self.name if self.name not in ["peerplays", "bitshares", "peerplays testnet", "bitshares testnet"] else "graphene"

def non_trading_connector_instance_with_default_configuration(
self,
Expand Down Expand Up @@ -393,12 +393,13 @@ def create_connector_settings(cls):
util_module = importlib.import_module(util_module_path)
except ModuleNotFoundError:
continue
name = "peerplays" if connector_dir.name == "graphene" else connector_dir.name
trade_fee_settings: List[float] = getattr(util_module, "DEFAULT_FEES", None)
trade_fee_schema: TradeFeeSchema = cls._validate_trade_fee_schema(
connector_dir.name, trade_fee_settings
name, trade_fee_settings
)
cls.all_connector_settings[connector_dir.name] = ConnectorSetting(
name=connector_dir.name,
cls.all_connector_settings[name] = ConnectorSetting(
name=name,
type=ConnectorType[type_dir.name.capitalize()],
centralised=getattr(util_module, "CENTRALIZED", True),
example_pair=getattr(util_module, "EXAMPLE_PAIR", ""),
Expand All @@ -415,7 +416,7 @@ def create_connector_settings(cls):
for domain in other_domains:
trade_fee_settings = getattr(util_module, "OTHER_DOMAINS_DEFAULT_FEES")[domain]
trade_fee_schema = cls._validate_trade_fee_schema(domain, trade_fee_settings)
parent = cls.all_connector_settings[connector_dir.name]
parent = cls.all_connector_settings[name]
cls.all_connector_settings[domain] = ConnectorSetting(
name=domain,
type=parent.type,
Expand Down
1 change: 1 addition & 0 deletions hummingbot/connector/exchange/graphene/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#
Empty file.
2 changes: 2 additions & 0 deletions hummingbot/connector/exchange/graphene/dummy.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cdef class dummy():
pass
2 changes: 2 additions & 0 deletions hummingbot/connector/exchange/graphene/dummy.pyx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cdef class dummy():
pass
Loading

0 comments on commit 4383d99

Please sign in to comment.