@requestnetwork/currency
Advanced tools
Comparing version 0.8.1-next.1512 to 0.8.1-next.1515
@@ -18,9 +18,13 @@ import { StorageCurrency, CurrencyDefinition, CurrencyInput, ICurrencyManager, LegacyTokenMap } from './types'; | ||
/** | ||
* Gets a supported currency from a symbol, symbol-network or address. | ||
* Gets a supported currency from a symbol, symbol-network, currency definition id or address. | ||
* | ||
* @param symbolOrAddress e.g. 'DAI', 'FAU', 'FAU-rinkeby' or '0xFab46E002BbF0b4509813474841E0716E6730136' | ||
* @param currencyIdentifier e.g. 'DAI', 'FAU', 'FAU-rinkeby', 'ETH-rinkeby-rinkeby' or '0xFab46E002BbF0b4509813474841E0716E6730136' | ||
* @param network e.g. rinkeby, mainnet | ||
*/ | ||
from(symbolOrAddress: string | undefined, network?: string): CurrencyDefinition<TMeta> | undefined; | ||
from(currencyIdentifier: string | undefined, network?: string): CurrencyDefinition<TMeta> | undefined; | ||
/** | ||
* Gets a supported currency from its CurrencyDefinition id | ||
*/ | ||
fromId(id: string): CurrencyDefinition<TMeta> | undefined; | ||
/** | ||
* Gets a supported currency from its address and network. | ||
@@ -27,0 +31,0 @@ * If more than 1 currencies are found, undefined is returned |
@@ -39,20 +39,30 @@ "use strict"; | ||
/** | ||
* Gets a supported currency from a symbol, symbol-network or address. | ||
* Gets a supported currency from a symbol, symbol-network, currency definition id or address. | ||
* | ||
* @param symbolOrAddress e.g. 'DAI', 'FAU', 'FAU-rinkeby' or '0xFab46E002BbF0b4509813474841E0716E6730136' | ||
* @param currencyIdentifier e.g. 'DAI', 'FAU', 'FAU-rinkeby', 'ETH-rinkeby-rinkeby' or '0xFab46E002BbF0b4509813474841E0716E6730136' | ||
* @param network e.g. rinkeby, mainnet | ||
*/ | ||
from(symbolOrAddress, network) { | ||
if (!symbolOrAddress) { | ||
from(currencyIdentifier, network) { | ||
if (!currencyIdentifier) { | ||
return; | ||
} | ||
if (ethers_1.utils.isAddress(symbolOrAddress)) { | ||
return this.fromAddress(symbolOrAddress, network); | ||
if (ethers_1.utils.isAddress(currencyIdentifier)) { | ||
return this.fromAddress(currencyIdentifier, network); | ||
} | ||
const parts = symbolOrAddress.split('-'); | ||
return (this.fromSymbol(parts[0], network || parts[1]) || | ||
const parts = currencyIdentifier.split('-'); | ||
const curerncyFromSymbol = this.fromSymbol(parts[0], network || parts[1]) || | ||
// try without splitting the symbol to support currencies like ETH-rinkeby | ||
this.fromSymbol(symbolOrAddress, network)); | ||
this.fromSymbol(currencyIdentifier, network); | ||
if (curerncyFromSymbol) { | ||
return curerncyFromSymbol; | ||
} | ||
return this.fromId(currencyIdentifier); | ||
} | ||
/** | ||
* Gets a supported currency from its CurrencyDefinition id | ||
*/ | ||
fromId(id) { | ||
return this.knownCurrencies.find((knownCurrency) => knownCurrency.id === id); | ||
} | ||
/** | ||
* Gets a supported currency from its address and network. | ||
@@ -59,0 +69,0 @@ * If more than 1 currencies are found, undefined is returned |
{ | ||
"name": "@requestnetwork/currency", | ||
"version": "0.8.1-next.1512+6d72d983", | ||
"version": "0.8.1-next.1515+1e306e4e", | ||
"publishConfig": { | ||
@@ -45,4 +45,4 @@ "access": "public" | ||
"@metamask/contract-metadata": "1.28.0", | ||
"@requestnetwork/types": "0.35.1-next.1512+6d72d983", | ||
"@requestnetwork/utils": "0.35.1-next.1512+6d72d983", | ||
"@requestnetwork/types": "0.35.1-next.1515+1e306e4e", | ||
"@requestnetwork/utils": "0.35.1-next.1515+1e306e4e", | ||
"node-dijkstra": "2.5.0" | ||
@@ -62,3 +62,3 @@ }, | ||
}, | ||
"gitHead": "6d72d983c46e6c2cc7cec0239b6074b6a999ca7b" | ||
"gitHead": "1e306e4e30e7a2e06bec20f2ad8f92cf4b3dcdc9" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
129651
2354