|
162 | 162 | currency = undefined; |
163 | 163 | filteredSettlementCurrencies = []; |
164 | 164 | network = undefined; |
165 | | - networks = []; |
| 165 | +
|
| 166 | + const availableNetworks = new Set( |
| 167 | + currencyManager.knownCurrencies.map((currency) => currency.network) |
| 168 | + ); |
166 | 169 |
|
167 | 170 | if (invoiceCurrency.type === Types.RequestLogic.CURRENCY.ISO4217) { |
168 | | - networks = (getCurrencySupportedNetworksForConversion( |
169 | | - invoiceCurrency.hash, |
170 | | - currencyManager |
171 | | - ) ?? []) as string[]; |
| 171 | + const conversionNetworks = new Set( |
| 172 | + getCurrencySupportedNetworksForConversion( |
| 173 | + invoiceCurrency.hash, |
| 174 | + currencyManager |
| 175 | + ) |
| 176 | + ); |
| 177 | +
|
| 178 | + networks = [...availableNetworks].filter( |
| 179 | + (network) => |
| 180 | + conversionNetworks.has(network) && |
| 181 | + (config.supportedNetworks |
| 182 | + ? config.supportedNetworks.includes(network) |
| 183 | + : true) |
| 184 | + ); |
| 185 | +
|
| 186 | + console.log("networks: ", networks); |
172 | 187 | } else { |
173 | 188 | const baseSymbol = invoiceCurrency.symbol.split("-")[0]; |
174 | | - networks = currencyManager.knownCurrencies |
175 | | - .filter((currency) => { |
176 | | - const currencyBaseSymbol = currency.symbol.split("-")[0]; |
177 | | - return currencyBaseSymbol === baseSymbol; |
178 | | - }) |
179 | | - .map((currency) => currency.network); |
| 189 | + networks = [...availableNetworks].filter((network) => { |
| 190 | + const hasToken = currencyManager.knownCurrencies.some( |
| 191 | + (currency) => |
| 192 | + currency.network === network && |
| 193 | + currency.symbol.split("-")[0] === baseSymbol |
| 194 | + ); |
| 195 | +
|
| 196 | + return ( |
| 197 | + hasToken && |
| 198 | + (config.supportedNetworks |
| 199 | + ? config.supportedNetworks.includes(network) |
| 200 | + : true) |
| 201 | + ); |
| 202 | + }); |
180 | 203 | } |
| 204 | +
|
| 205 | + networks = [...new Set(networks)]; |
181 | 206 | } |
182 | 207 | }; |
183 | 208 |
|
|
0 commit comments