@xchainjs/xchain-util
Advanced tools
Comparing version
# v.x.x.x | ||
# v.0.2.3 (2021-02-09) | ||
### Fix | ||
- Added strict checks for undefined values at `formatAssetAmountCurrency` and `formatAssetAmount` | ||
### Update | ||
- Add `AssetBCH` | ||
# v.0.2.2 (2021-01-30) | ||
### Fix | ||
- Clear lib folder on build | ||
@@ -6,0 +18,0 @@ - Fixes linting from redeclaring Litecoin in chain consts twice |
@@ -100,2 +100,9 @@ import BigNumber from 'bignumber.js'; | ||
/** | ||
* Base "chain" asset on bitcoin cash main net. | ||
* | ||
* Based on definition in Thorchain `common` | ||
* @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24 | ||
*/ | ||
export declare const AssetBCH: Asset; | ||
/** | ||
* Base "chain" asset on litecoin main net. | ||
@@ -137,2 +144,16 @@ * | ||
/** | ||
* Base "chain" asset for RUNE on ethereum main net. | ||
* | ||
* Based on definition in Thorchain `common` | ||
* @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24 | ||
*/ | ||
export declare const AssetRuneERC20: Asset; | ||
/** | ||
* Base "chain" asset for RUNE on ethereum main net. | ||
* | ||
* Based on definition in Thorchain `common` | ||
* @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24 | ||
*/ | ||
export declare const AssetRuneERC20Testnet: Asset; | ||
/** | ||
* Helper to check whether asset is valid | ||
@@ -139,0 +160,0 @@ * |
@@ -303,3 +303,4 @@ import BigNumber from 'bignumber.js'; | ||
var amount = _a.amount, decimal = _a.decimal, _b = _a.trimZeros, trimZeros$1 = _b === void 0 ? false : _b; | ||
var formatted = formatBN(amount.amount(), decimal || amount.decimal); | ||
// strict check for `undefined` value as negate of 0 will return true and passed decimal value will be ignored | ||
var formatted = formatBN(amount.amount(), decimal === undefined ? amount.decimal : decimal); | ||
// Note: `trimZeros` wins over `decimal` | ||
@@ -330,2 +331,9 @@ return trimZeros$1 ? trimZeros(formatted) : formatted; | ||
/** | ||
* Base "chain" asset on bitcoin cash main net. | ||
* | ||
* Based on definition in Thorchain `common` | ||
* @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24 | ||
*/ | ||
var AssetBCH = { chain: BCHChain, symbol: 'BCH', ticker: 'BCH' }; | ||
/** | ||
* Base "chain" asset on litecoin main net. | ||
@@ -367,2 +375,24 @@ * | ||
/** | ||
* Base "chain" asset for RUNE on ethereum main net. | ||
* | ||
* Based on definition in Thorchain `common` | ||
* @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24 | ||
*/ | ||
var AssetRuneERC20 = { | ||
chain: ETHChain, | ||
symbol: RUNE_TICKER + "-0x3155ba85d5f96b2d030a4966af206230e46849cb", | ||
ticker: RUNE_TICKER, | ||
}; | ||
/** | ||
* Base "chain" asset for RUNE on ethereum main net. | ||
* | ||
* Based on definition in Thorchain `common` | ||
* @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24 | ||
*/ | ||
var AssetRuneERC20Testnet = { | ||
chain: ETHChain, | ||
symbol: RUNE_TICKER + "-0xd601c6A3a36721320573885A8d8420746dA3d7A0", | ||
ticker: RUNE_TICKER, | ||
}; | ||
/** | ||
* Helper to check whether asset is valid | ||
@@ -469,3 +499,8 @@ * | ||
var amount = _a.amount, asset = _a.asset, decimal = _a.decimal, _c = _a.trimZeros, shouldTrimZeros = _c === void 0 ? false : _c; | ||
var amountFormatted = formatAssetAmount({ amount: amount, decimal: decimal || amount.decimal, trimZeros: shouldTrimZeros }); | ||
var amountFormatted = formatAssetAmount({ | ||
amount: amount, | ||
// strict check for `undefined` value as negate of 0 will return true and passed decimal value will be ignored | ||
decimal: decimal === undefined ? amount.decimal : decimal, | ||
trimZeros: shouldTrimZeros, | ||
}); | ||
var ticker = (_b = asset === null || asset === void 0 ? void 0 : asset.ticker) !== null && _b !== void 0 ? _b : ''; | ||
@@ -513,3 +548,3 @@ if (ticker) { | ||
export { AssetBNB, AssetBTC, AssetCurrencySymbol, AssetETH, AssetLTC, AssetRune67C, AssetRuneB1A, AssetRuneNative, BCHChain, BNBChain, BTCChain, CosmosChain, Denomination, ETHChain, LTCChain, PolkadotChain, RUNE_TICKER, THORChain, assetAmount, assetFromString, assetToBase, assetToString, baseAmount, baseToAsset, bn, bnOrZero, chainToString, chains, currencySymbolByAsset, delay, fixedBN, formatAssetAmount, formatAssetAmountCurrency, formatBN, formatBNCurrency, formatBaseAmount, formatBaseAsAssetAmount, isAssetAmount, isBaseAmount, isChain, isValidAsset, isValidBN, trimZeros, validBNOrZero }; | ||
export { AssetBCH, AssetBNB, AssetBTC, AssetCurrencySymbol, AssetETH, AssetLTC, AssetRune67C, AssetRuneB1A, AssetRuneERC20, AssetRuneERC20Testnet, AssetRuneNative, BCHChain, BNBChain, BTCChain, CosmosChain, Denomination, ETHChain, LTCChain, PolkadotChain, RUNE_TICKER, THORChain, assetAmount, assetFromString, assetToBase, assetToString, baseAmount, baseToAsset, bn, bnOrZero, chainToString, chains, currencySymbolByAsset, delay, fixedBN, formatAssetAmount, formatAssetAmountCurrency, formatBN, formatBNCurrency, formatBaseAmount, formatBaseAsAssetAmount, isAssetAmount, isBaseAmount, isChain, isValidAsset, isValidBN, trimZeros, validBNOrZero }; | ||
//# sourceMappingURL=index.esm.js.map |
@@ -310,3 +310,4 @@ 'use strict'; | ||
var amount = _a.amount, decimal = _a.decimal, _b = _a.trimZeros, trimZeros$1 = _b === void 0 ? false : _b; | ||
var formatted = formatBN(amount.amount(), decimal || amount.decimal); | ||
// strict check for `undefined` value as negate of 0 will return true and passed decimal value will be ignored | ||
var formatted = formatBN(amount.amount(), decimal === undefined ? amount.decimal : decimal); | ||
// Note: `trimZeros` wins over `decimal` | ||
@@ -337,2 +338,9 @@ return trimZeros$1 ? trimZeros(formatted) : formatted; | ||
/** | ||
* Base "chain" asset on bitcoin cash main net. | ||
* | ||
* Based on definition in Thorchain `common` | ||
* @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24 | ||
*/ | ||
var AssetBCH = { chain: BCHChain, symbol: 'BCH', ticker: 'BCH' }; | ||
/** | ||
* Base "chain" asset on litecoin main net. | ||
@@ -374,2 +382,24 @@ * | ||
/** | ||
* Base "chain" asset for RUNE on ethereum main net. | ||
* | ||
* Based on definition in Thorchain `common` | ||
* @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24 | ||
*/ | ||
var AssetRuneERC20 = { | ||
chain: ETHChain, | ||
symbol: RUNE_TICKER + "-0x3155ba85d5f96b2d030a4966af206230e46849cb", | ||
ticker: RUNE_TICKER, | ||
}; | ||
/** | ||
* Base "chain" asset for RUNE on ethereum main net. | ||
* | ||
* Based on definition in Thorchain `common` | ||
* @see https://gitlab.com/thorchain/thornode/-/blob/master/common/asset.go#L12-24 | ||
*/ | ||
var AssetRuneERC20Testnet = { | ||
chain: ETHChain, | ||
symbol: RUNE_TICKER + "-0xd601c6A3a36721320573885A8d8420746dA3d7A0", | ||
ticker: RUNE_TICKER, | ||
}; | ||
/** | ||
* Helper to check whether asset is valid | ||
@@ -472,3 +502,8 @@ * | ||
var amount = _a.amount, asset = _a.asset, decimal = _a.decimal, _c = _a.trimZeros, shouldTrimZeros = _c === void 0 ? false : _c; | ||
var amountFormatted = formatAssetAmount({ amount: amount, decimal: decimal || amount.decimal, trimZeros: shouldTrimZeros }); | ||
var amountFormatted = formatAssetAmount({ | ||
amount: amount, | ||
// strict check for `undefined` value as negate of 0 will return true and passed decimal value will be ignored | ||
decimal: decimal === undefined ? amount.decimal : decimal, | ||
trimZeros: shouldTrimZeros, | ||
}); | ||
var ticker = (_b = asset === null || asset === void 0 ? void 0 : asset.ticker) !== null && _b !== void 0 ? _b : ''; | ||
@@ -516,2 +551,3 @@ if (ticker) { | ||
exports.AssetBCH = AssetBCH; | ||
exports.AssetBNB = AssetBNB; | ||
@@ -523,2 +559,4 @@ exports.AssetBTC = AssetBTC; | ||
exports.AssetRuneB1A = AssetRuneB1A; | ||
exports.AssetRuneERC20 = AssetRuneERC20; | ||
exports.AssetRuneERC20Testnet = AssetRuneERC20Testnet; | ||
exports.AssetRuneNative = AssetRuneNative; | ||
@@ -525,0 +563,0 @@ exports.BCHChain = BCHChain; |
{ | ||
"name": "@xchainjs/xchain-util", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"description": "Helper utilities for XChain clients", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
110720
6.68%1546
6.47%