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.8.1 to 0.9.0

17

lib/asset.d.ts
import BigNumber from 'bignumber.js';
import { Amount, Asset, AssetAmount, BaseAmount, Denomination } from './types';
export declare type Address = string;
/**

@@ -184,2 +185,4 @@ * Guard to check whether value is a BigNumber.Value or not

export declare const AssetRuneERC20Testnet: Asset;
export declare const AssetAtom: Asset;
export declare const AssetLUNA: Asset;
/**

@@ -216,3 +219,3 @@ * Helper to check whether asset is valid

*/
export declare const assetFromString: (s: string) => Asset | null;
export declare const assetFromString: (s: string) => Asset;
/**

@@ -289,1 +292,13 @@ * Returns an `Asset` as a string using following naming convention:

export declare const eqAsset: (a: Asset, b: Asset) => boolean;
/**
* Checks whether an asset is `AssetRuneNative`
*
* @param {Asset} asset
* @returns {boolean} `true` or `false`
*/
export declare const isAssetRuneNative: (asset: Asset) => boolean;
/**
* Removes `0x` or `0X` from address
*/
export declare const strip0x: (addr: Address) => string;
export declare const getContractAddressFromAsset: (asset: Asset) => Address;

@@ -449,2 +449,4 @@ import BigNumber from 'bignumber.js';

};
const AssetAtom = { chain: Chain.Cosmos, symbol: 'ATOM', ticker: 'ATOM', synth: false };
const AssetLUNA = { chain: Chain.Terra, symbol: 'LUNA', ticker: 'LUNA', synth: false };
/**

@@ -489,3 +491,3 @@ * Helper to check whether asset is valid

if (data.length <= 1 || ((_a = data[1]) === null || _a === void 0 ? void 0 : _a.length) < 1) {
return null;
throw Error('assest string not correct');
}

@@ -495,3 +497,3 @@ const chain = data[0];

if (!chain || !isChain(chain))
return null;
throw Error('assest string not correct');
const symbol = data[1];

@@ -614,4 +616,19 @@ const ticker = symbol.split('-')[0];

const eqAsset = (a, b) => a.chain === b.chain && a.symbol === b.symbol && a.ticker === b.ticker && a.synth === b.synth;
/**
* Checks whether an asset is `AssetRuneNative`
*
* @param {Asset} asset
* @returns {boolean} `true` or `false`
*/
const isAssetRuneNative = (asset) => assetToString(asset) === assetToString(AssetRuneNative);
/**
* Removes `0x` or `0X` from address
*/
const strip0x = (addr) => addr.replace(/^0(x|X)/, '');
const getContractAddressFromAsset = (asset) => {
const assetAddress = asset.symbol.slice(asset.ticker.length + 1);
return strip0x(assetAddress);
};
export { AVAXChain, AssetAVAX, AssetBCH, AssetBNB, AssetBTC, AssetCurrencySymbol, AssetDOGE, AssetETH, AssetLTC, AssetRune67C, AssetRuneB1A, AssetRuneERC20, AssetRuneERC20Testnet, AssetRuneNative, AvalancheChain, BCHChain, BNBChain, BTCChain, Chain, CosmosChain, DOGEChain, Denomination, ETHChain, LTCChain, RUNE_TICKER, THORChain, TerraChain, assetAmount, assetFromString, assetToBase, assetToString, baseAmount, baseToAsset, bn, bnOrZero, chainToString, currencySymbolByAsset, delay, eqAsset, eqChain, fixedBN, formatAssetAmount, formatAssetAmountCurrency, formatBN, formatBNCurrency, formatBaseAmount, formatBaseAsAssetAmount, isAssetAmount, isBaseAmount, isBchChain, isBigNumberValue, isBnbChain, isBtcChain, isChain, isDogeChain, isEnabledChain, isEthChain, isLtcChain, isSynthAsset, isTerraChain, isThorChain, isValidAsset, isValidBN, trimZeros, validBNOrZero };
export { AVAXChain, AssetAVAX, AssetAtom, AssetBCH, AssetBNB, AssetBTC, AssetCurrencySymbol, AssetDOGE, AssetETH, AssetLTC, AssetLUNA, AssetRune67C, AssetRuneB1A, AssetRuneERC20, AssetRuneERC20Testnet, AssetRuneNative, AvalancheChain, BCHChain, BNBChain, BTCChain, Chain, CosmosChain, DOGEChain, Denomination, ETHChain, LTCChain, RUNE_TICKER, THORChain, TerraChain, assetAmount, assetFromString, assetToBase, assetToString, baseAmount, baseToAsset, bn, bnOrZero, chainToString, currencySymbolByAsset, delay, eqAsset, eqChain, fixedBN, formatAssetAmount, formatAssetAmountCurrency, formatBN, formatBNCurrency, formatBaseAmount, formatBaseAsAssetAmount, getContractAddressFromAsset, isAssetAmount, isAssetRuneNative, isBaseAmount, isBchChain, isBigNumberValue, isBnbChain, isBtcChain, isChain, isDogeChain, isEnabledChain, isEthChain, isLtcChain, isSynthAsset, isTerraChain, isThorChain, isValidAsset, isValidBN, strip0x, trimZeros, validBNOrZero };
//# sourceMappingURL=index.esm.js.map

@@ -455,2 +455,4 @@ 'use strict';

};
const AssetAtom = { chain: exports.Chain.Cosmos, symbol: 'ATOM', ticker: 'ATOM', synth: false };
const AssetLUNA = { chain: exports.Chain.Terra, symbol: 'LUNA', ticker: 'LUNA', synth: false };
/**

@@ -495,3 +497,3 @@ * Helper to check whether asset is valid

if (data.length <= 1 || ((_a = data[1]) === null || _a === void 0 ? void 0 : _a.length) < 1) {
return null;
throw Error('assest string not correct');
}

@@ -501,3 +503,3 @@ const chain = data[0];

if (!chain || !isChain(chain))
return null;
throw Error('assest string not correct');
const symbol = data[1];

@@ -616,5 +618,21 @@ const ticker = symbol.split('-')[0];

const eqAsset = (a, b) => a.chain === b.chain && a.symbol === b.symbol && a.ticker === b.ticker && a.synth === b.synth;
/**
* Checks whether an asset is `AssetRuneNative`
*
* @param {Asset} asset
* @returns {boolean} `true` or `false`
*/
const isAssetRuneNative = (asset) => assetToString(asset) === assetToString(AssetRuneNative);
/**
* Removes `0x` or `0X` from address
*/
const strip0x = (addr) => addr.replace(/^0(x|X)/, '');
const getContractAddressFromAsset = (asset) => {
const assetAddress = asset.symbol.slice(asset.ticker.length + 1);
return strip0x(assetAddress);
};
exports.AVAXChain = AVAXChain;
exports.AssetAVAX = AssetAVAX;
exports.AssetAtom = AssetAtom;
exports.AssetBCH = AssetBCH;

@@ -626,2 +644,3 @@ exports.AssetBNB = AssetBNB;

exports.AssetLTC = AssetLTC;
exports.AssetLUNA = AssetLUNA;
exports.AssetRune67C = AssetRune67C;

@@ -663,3 +682,5 @@ exports.AssetRuneB1A = AssetRuneB1A;

exports.formatBaseAsAssetAmount = formatBaseAsAssetAmount;
exports.getContractAddressFromAsset = getContractAddressFromAsset;
exports.isAssetAmount = isAssetAmount;
exports.isAssetRuneNative = isAssetRuneNative;
exports.isBaseAmount = isBaseAmount;

@@ -680,4 +701,5 @@ exports.isBchChain = isBchChain;

exports.isValidBN = isValidBN;
exports.strip0x = strip0x;
exports.trimZeros = trimZeros;
exports.validBNOrZero = validBNOrZero;
//# sourceMappingURL=index.js.map

2

package.json
{
"name": "@xchainjs/xchain-util",
"version": "0.8.1",
"version": "0.9.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