From 2ef89854b1da99fc70bda7e7a1e25018d546f240 Mon Sep 17 00:00:00 2001 From: nick8319 Date: Thu, 29 Jun 2023 16:34:36 +0200 Subject: [PATCH] feat: add RSK Mainnet and Testnet support --- requirements.txt | 3 ++- .../tokens/clients/coingecko_client.py | 3 +++ safe_transaction_service/tokens/services/price_service.py | 8 ++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 6d847e7f..814abcc2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -32,5 +32,6 @@ psycogreen==1.0.2 psycopg2==2.9.7 redis==5.0.0 requests==2.31.0 -safe-eth-py[django]==5.8.0 +git+https://github.com/protofire/safe-eth-py.git@rsk#egg=safe-eth-py +#safe-eth-py[django]==5.8.0 web3==6.9.0 diff --git a/safe_transaction_service/tokens/clients/coingecko_client.py b/safe_transaction_service/tokens/clients/coingecko_client.py index a327930c..fa631073 100644 --- a/safe_transaction_service/tokens/clients/coingecko_client.py +++ b/safe_transaction_service/tokens/clients/coingecko_client.py @@ -148,5 +148,8 @@ def get_kcs_usd_price(self) -> float: def get_metis_usd_price(self) -> float: return self.get_price("metis-token") + def get_btc_usd_price(self) -> float: + return self.get_price("bitcoin") + def get_mtr_usd_price(self) -> float: return self.get_price("meter-stable") diff --git a/safe_transaction_service/tokens/services/price_service.py b/safe_transaction_service/tokens/services/price_service.py index 56f2077c..eb76e3f4 100644 --- a/safe_transaction_service/tokens/services/price_service.py +++ b/safe_transaction_service/tokens/services/price_service.py @@ -200,6 +200,9 @@ def get_kcs_usd_price(self) -> float: except CannotGetPrice: return self.coingecko_client.get_kcs_usd_price() + def get_btc_usd_price(self) -> float: + return self.coingecko_client.get_btc_usd_price() + def get_mtr_usd_price(self) -> float: return self.coingecko_client.get_mtr_usd_price() @@ -305,6 +308,11 @@ def get_native_coin_usd_price(self) -> float: EthereumNetwork.FANTOM_TESTNET, ): return self.get_ftm_usd_price() + elif self.ethereum_network in ( + EthereumNetwork.RSK_MAINNET, + EthereumNetwork.RSK_TESTNET, + ): + return self.get_btc_usd_price() else: return self.get_ether_usd_price()