@ignore tries to convert the provided networkCode(which is expected to be an unified network code) to a network id. In order to achieve self, derived class needs to have 'options->networks' defined. :param str networkCode: unified network code :param str currencyCode: unifi
(self, networkCode: str, currencyCode: Str = None)
| 5102 | return [networkCode, networkCode] |
| 5103 | |
| 5104 | def network_code_to_id(self, networkCode: str, currencyCode: Str = None): |
| 5105 | """ |
| 5106 | @ignore |
| 5107 | tries to convert the provided networkCode(which is expected to be an unified network code) to a network id. In order to achieve self, derived class needs to have 'options->networks' defined. |
| 5108 | :param str networkCode: unified network code |
| 5109 | :param str currencyCode: unified currency code, but self argument is not required by default, unless there is an exchange(like huobi) that needs an override of the method to be able to pass currencyCode argument additionally |
| 5110 | :returns str|None: exchange-specific network id |
| 5111 | """ |
| 5112 | if networkCode is None: |
| 5113 | return None |
| 5114 | networkIdsByCodes = self.safe_dict(self.options, 'networks', {}) |
| 5115 | # try the preferred form first, fall back to its alternative(e.g. when only 'ETH' or only 'ERC20' is defined) |
| 5116 | preferredChain, alternativeChain = self.prioritized_network_aliases(networkCode, currencyCode, False) |
| 5117 | networkId = self.safe_string_2(networkIdsByCodes, preferredChain, alternativeChain) |
| 5118 | if networkId is not None: |
| 5119 | return networkId |
| 5120 | # fall back to scanning loaded currencies |
| 5121 | currenciesToCheck = [] |
| 5122 | if currencyCode is None: |
| 5123 | currenciesToCheck = list(self.currencies.keys()) |
| 5124 | else: |
| 5125 | currenciesToCheck = [self.safe_dict(self.currencies, currencyCode)] |
| 5126 | for i in range(0, len(currenciesToCheck)): |
| 5127 | networks = self.safe_dict(currenciesToCheck[i], 'networks', {}) |
| 5128 | if networkCode in networks: |
| 5129 | return self.safe_string(networks[networkCode], 'id') |
| 5130 | return networkCode |
| 5131 | |
| 5132 | def network_id_to_code(self, networkId: Str = None, currencyCode: Str = None): |
| 5133 | """ |