Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@xchainjs/xchain-util

Package Overview
Dependencies
Maintainers
9
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@xchainjs/xchain-util - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

14

CHANGELOG.md

@@ -0,1 +1,15 @@

# v.0.5.0 (2022-02-02)
### Breaking change
- Add `synth` property to `Asset`
### Update
- Support synths in `assetFromString` + `assetToString` helpers
### Add
- `isSynthAsset` helper
# v.0.4.0 (2022-01-19)

@@ -2,0 +16,0 @@

10

lib/asset.d.ts

@@ -187,2 +187,9 @@ import BigNumber from 'bignumber.js';

/**
* Helper to check whether an asset is synth asset
*
* @param {Asset} asset
* @returns {boolean} `true` or `false`
*/
export declare const isSynthAsset: ({ synth }: Asset) => boolean;
/**
* Creates an `Asset` by a given string

@@ -213,2 +220,3 @@ *

* symbol: `BBB-CCC` or `CCC` (if no ticker available)
* symbol (synth): `BBB/CCC` or `CCC` (if no ticker available)
*

@@ -220,3 +228,3 @@ * @see https://docs.thorchain.org/developers/transaction-memos#asset-notation

*/
export declare const assetToString: ({ chain, symbol }: Asset) => string;
export declare const assetToString: ({ chain, symbol, synth }: Asset) => string;
/**

@@ -223,0 +231,0 @@ * Currency symbols currently supported

46

lib/index.esm.js

@@ -354,3 +354,3 @@ import BigNumber from 'bignumber.js';

*/
var AssetBNB = { chain: Chain.Binance, symbol: 'BNB', ticker: 'BNB' };
var AssetBNB = { chain: Chain.Binance, symbol: 'BNB', ticker: 'BNB', synth: false };
/**

@@ -362,3 +362,3 @@ * Base "chain" asset on bitcoin main net.

*/
var AssetBTC = { chain: Chain.Bitcoin, symbol: 'BTC', ticker: 'BTC' };
var AssetBTC = { chain: Chain.Bitcoin, symbol: 'BTC', ticker: 'BTC', synth: false };
/**

@@ -370,3 +370,3 @@ * Base "chain" asset on bitcoin cash main net.

*/
var AssetBCH = { chain: Chain.BitcoinCash, symbol: 'BCH', ticker: 'BCH' };
var AssetBCH = { chain: Chain.BitcoinCash, symbol: 'BCH', ticker: 'BCH', synth: false };
/**

@@ -378,3 +378,3 @@ * Base "chain" asset on litecoin main net.

*/
var AssetLTC = { chain: Chain.Litecoin, symbol: 'LTC', ticker: 'LTC' };
var AssetLTC = { chain: Chain.Litecoin, symbol: 'LTC', ticker: 'LTC', synth: false };
/**

@@ -385,3 +385,3 @@ * Dogecoin asset

*/
var AssetDOGE = { chain: Chain.Doge, symbol: 'DOGE', ticker: 'DOGE' };
var AssetDOGE = { chain: Chain.Doge, symbol: 'DOGE', ticker: 'DOGE', synth: false };
var RUNE_TICKER = 'RUNE';

@@ -394,3 +394,3 @@ /**

*/
var AssetETH = { chain: Chain.Ethereum, symbol: 'ETH', ticker: 'ETH' };
var AssetETH = { chain: Chain.Ethereum, symbol: 'ETH', ticker: 'ETH', synth: false };
/**

@@ -402,3 +402,3 @@ * Base "chain" asset for RUNE-67C on Binance test net.

*/
var AssetRune67C = { chain: Chain.Binance, symbol: 'RUNE-67C', ticker: RUNE_TICKER };
var AssetRune67C = { chain: Chain.Binance, symbol: 'RUNE-67C', ticker: RUNE_TICKER, synth: false };
/**

@@ -410,3 +410,3 @@ * Base "chain" asset for RUNE-B1A on Binance main net.

*/
var AssetRuneB1A = { chain: Chain.Binance, symbol: 'RUNE-B1A', ticker: RUNE_TICKER };
var AssetRuneB1A = { chain: Chain.Binance, symbol: 'RUNE-B1A', ticker: RUNE_TICKER, synth: false };
/**

@@ -418,3 +418,3 @@ * Base "chain" asset on thorchain main net.

*/
var AssetRuneNative = { chain: Chain.THORChain, symbol: RUNE_TICKER, ticker: RUNE_TICKER };
var AssetRuneNative = { chain: Chain.THORChain, symbol: RUNE_TICKER, ticker: RUNE_TICKER, synth: false };
/**

@@ -430,2 +430,3 @@ * Base "chain" asset for RUNE on ethereum main net.

ticker: RUNE_TICKER,
synth: false,
};

@@ -442,2 +443,3 @@ /**

ticker: RUNE_TICKER,
synth: false,
};

@@ -452,2 +454,14 @@ /**

/**
* Helper to check whether an asset is synth asset
*
* @param {Asset} asset
* @returns {boolean} `true` or `false`
*/
var isSynthAsset = function (_a) {
var synth = _a.synth;
return synth;
};
var SYNTH_DELIMITER = '/';
var NON_SYNTH_DELIMITER = '.';
/**
* Creates an `Asset` by a given string

@@ -471,3 +485,5 @@ *

var _a;
var data = s.split('.');
var isSynth = s.includes(SYNTH_DELIMITER);
var delimiter = isSynth ? SYNTH_DELIMITER : NON_SYNTH_DELIMITER;
var data = s.split(delimiter);
if (data.length <= 1 || ((_a = data[1]) === null || _a === void 0 ? void 0 : _a.length) < 1) {

@@ -482,3 +498,3 @@ return null;

var ticker = symbol.split('-')[0];
return { chain: chain, symbol: symbol, ticker: ticker };
return { chain: chain, symbol: symbol, ticker: ticker, synth: isSynth };
};

@@ -493,2 +509,3 @@ /**

* symbol: `BBB-CCC` or `CCC` (if no ticker available)
* symbol (synth): `BBB/CCC` or `CCC` (if no ticker available)
*

@@ -501,4 +518,5 @@ * @see https://docs.thorchain.org/developers/transaction-memos#asset-notation

var assetToString = function (_a) {
var chain = _a.chain, symbol = _a.symbol;
return chain + "." + symbol;
var chain = _a.chain, symbol = _a.symbol, synth = _a.synth;
var delimiter = synth ? SYNTH_DELIMITER : NON_SYNTH_DELIMITER;
return "" + chain + delimiter + symbol;
};

@@ -598,3 +616,3 @@ /**

export { AssetBCH, AssetBNB, AssetBTC, AssetCurrencySymbol, AssetDOGE, AssetETH, AssetLTC, AssetRune67C, AssetRuneB1A, AssetRuneERC20, AssetRuneERC20Testnet, AssetRuneNative, BCHChain, BNBChain, BTCChain, Chain, CosmosChain, DOGEChain, Denomination, ETHChain, LTCChain, PolkadotChain, RUNE_TICKER, THORChain, assetAmount, assetFromString, assetToBase, assetToString, baseAmount, baseToAsset, bn, bnOrZero, chainToString, currencySymbolByAsset, delay, fixedBN, formatAssetAmount, formatAssetAmountCurrency, formatBN, formatBNCurrency, formatBaseAmount, formatBaseAsAssetAmount, isAssetAmount, isBaseAmount, isBigNumberValue, isChain, isValidAsset, isValidBN, trimZeros, validBNOrZero };
export { AssetBCH, AssetBNB, AssetBTC, AssetCurrencySymbol, AssetDOGE, AssetETH, AssetLTC, AssetRune67C, AssetRuneB1A, AssetRuneERC20, AssetRuneERC20Testnet, AssetRuneNative, BCHChain, BNBChain, BTCChain, Chain, CosmosChain, DOGEChain, Denomination, ETHChain, LTCChain, PolkadotChain, RUNE_TICKER, THORChain, assetAmount, assetFromString, assetToBase, assetToString, baseAmount, baseToAsset, bn, bnOrZero, chainToString, currencySymbolByAsset, delay, fixedBN, formatAssetAmount, formatAssetAmountCurrency, formatBN, formatBNCurrency, formatBaseAmount, formatBaseAsAssetAmount, isAssetAmount, isBaseAmount, isBigNumberValue, isChain, isSynthAsset, isValidAsset, isValidBN, trimZeros, validBNOrZero };
//# sourceMappingURL=index.esm.js.map

@@ -360,3 +360,3 @@ 'use strict';

*/
var AssetBNB = { chain: exports.Chain.Binance, symbol: 'BNB', ticker: 'BNB' };
var AssetBNB = { chain: exports.Chain.Binance, symbol: 'BNB', ticker: 'BNB', synth: false };
/**

@@ -368,3 +368,3 @@ * Base "chain" asset on bitcoin main net.

*/
var AssetBTC = { chain: exports.Chain.Bitcoin, symbol: 'BTC', ticker: 'BTC' };
var AssetBTC = { chain: exports.Chain.Bitcoin, symbol: 'BTC', ticker: 'BTC', synth: false };
/**

@@ -376,3 +376,3 @@ * Base "chain" asset on bitcoin cash main net.

*/
var AssetBCH = { chain: exports.Chain.BitcoinCash, symbol: 'BCH', ticker: 'BCH' };
var AssetBCH = { chain: exports.Chain.BitcoinCash, symbol: 'BCH', ticker: 'BCH', synth: false };
/**

@@ -384,3 +384,3 @@ * Base "chain" asset on litecoin main net.

*/
var AssetLTC = { chain: exports.Chain.Litecoin, symbol: 'LTC', ticker: 'LTC' };
var AssetLTC = { chain: exports.Chain.Litecoin, symbol: 'LTC', ticker: 'LTC', synth: false };
/**

@@ -391,3 +391,3 @@ * Dogecoin asset

*/
var AssetDOGE = { chain: exports.Chain.Doge, symbol: 'DOGE', ticker: 'DOGE' };
var AssetDOGE = { chain: exports.Chain.Doge, symbol: 'DOGE', ticker: 'DOGE', synth: false };
var RUNE_TICKER = 'RUNE';

@@ -400,3 +400,3 @@ /**

*/
var AssetETH = { chain: exports.Chain.Ethereum, symbol: 'ETH', ticker: 'ETH' };
var AssetETH = { chain: exports.Chain.Ethereum, symbol: 'ETH', ticker: 'ETH', synth: false };
/**

@@ -408,3 +408,3 @@ * Base "chain" asset for RUNE-67C on Binance test net.

*/
var AssetRune67C = { chain: exports.Chain.Binance, symbol: 'RUNE-67C', ticker: RUNE_TICKER };
var AssetRune67C = { chain: exports.Chain.Binance, symbol: 'RUNE-67C', ticker: RUNE_TICKER, synth: false };
/**

@@ -416,3 +416,3 @@ * Base "chain" asset for RUNE-B1A on Binance main net.

*/
var AssetRuneB1A = { chain: exports.Chain.Binance, symbol: 'RUNE-B1A', ticker: RUNE_TICKER };
var AssetRuneB1A = { chain: exports.Chain.Binance, symbol: 'RUNE-B1A', ticker: RUNE_TICKER, synth: false };
/**

@@ -424,3 +424,3 @@ * Base "chain" asset on thorchain main net.

*/
var AssetRuneNative = { chain: exports.Chain.THORChain, symbol: RUNE_TICKER, ticker: RUNE_TICKER };
var AssetRuneNative = { chain: exports.Chain.THORChain, symbol: RUNE_TICKER, ticker: RUNE_TICKER, synth: false };
/**

@@ -436,2 +436,3 @@ * Base "chain" asset for RUNE on ethereum main net.

ticker: RUNE_TICKER,
synth: false,
};

@@ -448,2 +449,3 @@ /**

ticker: RUNE_TICKER,
synth: false,
};

@@ -458,2 +460,14 @@ /**

/**
* Helper to check whether an asset is synth asset
*
* @param {Asset} asset
* @returns {boolean} `true` or `false`
*/
var isSynthAsset = function (_a) {
var synth = _a.synth;
return synth;
};
var SYNTH_DELIMITER = '/';
var NON_SYNTH_DELIMITER = '.';
/**
* Creates an `Asset` by a given string

@@ -477,3 +491,5 @@ *

var _a;
var data = s.split('.');
var isSynth = s.includes(SYNTH_DELIMITER);
var delimiter = isSynth ? SYNTH_DELIMITER : NON_SYNTH_DELIMITER;
var data = s.split(delimiter);
if (data.length <= 1 || ((_a = data[1]) === null || _a === void 0 ? void 0 : _a.length) < 1) {

@@ -488,3 +504,3 @@ return null;

var ticker = symbol.split('-')[0];
return { chain: chain, symbol: symbol, ticker: ticker };
return { chain: chain, symbol: symbol, ticker: ticker, synth: isSynth };
};

@@ -499,2 +515,3 @@ /**

* symbol: `BBB-CCC` or `CCC` (if no ticker available)
* symbol (synth): `BBB/CCC` or `CCC` (if no ticker available)
*

@@ -507,4 +524,5 @@ * @see https://docs.thorchain.org/developers/transaction-memos#asset-notation

var assetToString = function (_a) {
var chain = _a.chain, symbol = _a.symbol;
return chain + "." + symbol;
var chain = _a.chain, symbol = _a.symbol, synth = _a.synth;
var delimiter = synth ? SYNTH_DELIMITER : NON_SYNTH_DELIMITER;
return "" + chain + delimiter + symbol;
};

@@ -643,2 +661,3 @@ (function (AssetCurrencySymbol) {

exports.isChain = isChain;
exports.isSynthAsset = isSynthAsset;
exports.isValidAsset = isValidAsset;

@@ -645,0 +664,0 @@ exports.isValidBN = isValidBN;

@@ -6,2 +6,3 @@ import { Chain } from '../chain';

ticker: string;
synth: boolean;
};
{
"name": "@xchainjs/xchain-util",
"version": "0.4.0",
"version": "0.5.0",
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc