From 2ae9f080508a3f4a4122887d6de6a9fa9a4452e4 Mon Sep 17 00:00:00 2001 From: apri-me Date: Mon, 31 Jul 2023 16:16:26 +0330 Subject: [PATCH 1/2] adding the support for new versions --- python_1inch/main.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/python_1inch/main.py b/python_1inch/main.py index 362aae3..7b3a58a 100644 --- a/python_1inch/main.py +++ b/python_1inch/main.py @@ -4,7 +4,7 @@ class OneInchExchange: - base_url = 'https://api.1inch.exchange' + base_url = 'https://api.1inch.io' chains = dict( ethereum = '1', @@ -31,12 +31,12 @@ class OneInchExchange: protocols = [] protocols_images = [] - def __init__(self, address, chain='ethereum'): + def __init__(self, address, chain='ethereum', version="v5.2"): self.address = address - self.version = 'v2.1' + self.version = version self.chain_id = self.chains[chain] self.chain = chain - # self.get_tokens() + self.get_tokens() # self.get_protocols() # self.get_protocols_images() @@ -62,8 +62,13 @@ def health_check(self): return result return result['status'] - def get_tokens(self): + if not self.tokens: + return self.tokens + else: + return self.fetch_tokens() + + def fetch_tokens(self): url = '{}/{}/{}/tokens'.format( self.base_url, self.version, self.chain_id) result = self._get(url) @@ -75,7 +80,6 @@ def get_tokens(self): self.tokens[token['symbol']] = token return self.tokens - def get_protocols(self): url = '{}/{}/{}/protocols'.format( self.base_url, self.version, self.chain_id) From f358cc6dfbbfeb7ecd8c353abd2788783b0429a3 Mon Sep 17 00:00:00 2001 From: apri-me Date: Wed, 2 Aug 2023 13:55:10 +0330 Subject: [PATCH 2/2] chain ids updated --- python_1inch/main.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/python_1inch/main.py b/python_1inch/main.py index 7b3a58a..517d665 100644 --- a/python_1inch/main.py +++ b/python_1inch/main.py @@ -8,7 +8,12 @@ class OneInchExchange: chains = dict( ethereum = '1', - binance = '56' + binance = '56', + fantom = "250", + avalanche = '43114', + polygon = '137', + arbitrum = '42161', + optimism = '10' ) versions = dict(