Socket
Socket
Sign inDemoInstall

@swapkit/helpers

Package Overview
Dependencies
Maintainers
1
Versions
203
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@swapkit/helpers - npm Package Compare versions

Comparing version 1.0.0-rc.65 to 1.0.0-rc.66

26

dist/index.es.js

@@ -16,6 +16,6 @@ var ye = Object.defineProperty;

l.INVALID_INPUT_PARAMETERS + "", l.UNKNOWN_PROVIDERS + "", l.CANNOT_FIND_INBOUND_ADDRESS + "", l.NO_INBOUND_ADDRESSES + "", l.CHAIN_HALTED_OR_UNSUPPORTED + "", l.MISSING_INPUT_PARAMETER + "", l.INVALID_TYPE_GENERIC + "", l.INVALID_NUMBER_STRING + "", l.INVALID_NUMBER + "", l.INVALID_BOOLEAN + "", l.INVALID_OBJECT + "", l.INVALID_ARRAY + "", l.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER + "", l.SELL_BUY_ASSETS_ARE_THE_SAME + "", l.MISSING_SOURCE_ADDRESS_FOR_SYNTH + "", l.AFF_ADDRESS_AND_BPS_OR_NEITHER + "", l.AFF_ADDRESS_TOO_LONG + "", l.AFF_BPS_INTEGER_MAX_500 + "", l.SOURCE_ADDRESS_INVALID_FOR_SELL_CHAIN + "", l.DESTINATION_ADDRESS_INVALID_FOR_BUY_CHAIN + "", l.PREFERRED_PROVIDER_NOT_SUPPORTED + "", l.SOURCE_ADDRESS_SMART_CONTRACT + "", l.DESTINATION_ADDRESS_SMART_CONTRACT + "", l.BUY_AMOUNT_MUST_BE_POSITIVE_INTEGER + "", l.INVALID_PROVIDER + "", l.MISSING_CROSS_CHAIN_PROVIDER + "", l.MISSING_AVAX_PROVIDER + "", l.MISSING_BSC_PROVIDER + "", l.MISSING_ETH_PROVIDER + "", l.MISSING_ARB_PROVIDER + "", l.INVALID_PROVIDER_FOR_SWAP_OUT + "", l.INVALID_CHAIN + "", l.INVALID_ASSET + "", l.UNSUPPORTED_CHAIN + "", l.UNSUPPORTED_ASSET + "", l.UNSUPPORTED_ASSET_FOR_SWAPOUT + "", l.THORNODE_QUOTE_GENERIC_ERROR + "", l.INVALID_SOURCE_ADDRESS + "", l.INVALID_DESTINATION_ADDRESS + "", l.NOT_ENOUGH_SYNTH_BALANCE + "", l.SYNTH_MINTING_CAP_REACHED + "", l.INVALID_QUOTE_MODE + "", l.NO_QUOTES + "", l.SERVICE_UNAVAILABLE_GENERIC + "", l.MISSING_GAS_DATA_GENERIC + "", l.MISSING_TOKEN_INFO_GENERIC + "", l.CANT_FIND_TOKEN_LIST + "", l.NO_PRICE + "", l.PRICE_IS_STALE + "", l.ADDRESS_NOT_WHITELISTED + "", l.ADDRESS_ALREADY_CLAIMED + "";
var j = /* @__PURE__ */ ((e) => (e.Arbitrum = "ARB", e.Avalanche = "AVAX", e.Binance = "BNB", e.BinanceSmartChain = "BSC", e.Bitcoin = "BTC", e.BitcoinCash = "BCH", e.Cosmos = "GAIA", e.Dogecoin = "DOGE", e.Ethereum = "ETH", e.Kujira = "KUJI", e.Litecoin = "LTC", e.Maya = "MAYA", e.Optimism = "OP", e.Polygon = "MATIC", e.THORChain = "THOR", e))(j || {}), te = /* @__PURE__ */ ((e) => (e.Arbitrum = "42161", e.ArbitrumHex = "0xa4b1", e.Avalanche = "43114", e.AvalancheHex = "0xa86a", e.Binance = "Binance-Chain-Tigris", e.BinanceSmartChain = "56", e.BinanceSmartChainHex = "0x38", e.Bitcoin = "bitcoin", e.BitcoinCash = "bitcoincash", e.Cosmos = "cosmoshub-4", e.Dogecoin = "dogecoin", e.Kujira = "kaiyo-1", e.Ethereum = "1", e.EthereumHex = "0x1", e.Litecoin = "litecoin", e.Maya = "mayachain-mainnet-v1", e.MayaStagenet = "mayachain-stagenet-v1", e.Optimism = "10", e.OptimismHex = "0xa", e.Polygon = "137", e.PolygonHex = "0x89", e.THORChain = "thorchain-mainnet-v1", e.THORChainStagenet = "thorchain-stagenet-v2", e))(te || {}), de = /* @__PURE__ */ ((e) => (e.Arbitrum = "https://arb1.arbitrum.io/rpc", e.Avalanche = "https://node-router.thorswap.net/avalanche-c", e.Binance = "", e.BinanceSmartChain = "https://bsc-dataseed.binance.org", e.Bitcoin = "https://node-router.thorswap.net/bitcoin", e.BitcoinCash = "https://node-router.thorswap.net/bitcoin-cash", e.Cosmos = "https://node-router.thorswap.net/cosmos/rpc", e.Kujira = "https://rpc-kujira.synergynodes.com/", e.Dogecoin = "https://node-router.thorswap.net/dogecoin", e.Ethereum = "https://node-router.thorswap.net/ethereum", e.Litecoin = "https://node-router.thorswap.net/litecoin", e.Maya = "https://tendermint.mayachain.info", e.MayaStagenet = "https://stagenet.tendermint.mayachain.info", e.Optimism = "https://mainnet.optimism.io", e.Polygon = "https://polygon-rpc.com", e.THORChain = "https://rpc.thorswap.net", e.THORChainStagenet = "https://stagenet-rpc.ninerealms.com", e))(de || {}), R = /* @__PURE__ */ ((e) => (e.Cosmos = "https://node-router.thorswap.net/cosmos/rest", e.Kujira = "https://lcd-kujira.synergynodes.com/", e.MayanodeMainnet = "https://mayanode.mayachain.info", e.MayanodeStagenet = "https://stagenet.mayanode.mayachain.info", e.ThornodeMainnet = "https://thornode.thorswap.net", e.ThornodeStagenet = "https://stagenet-thornode.ninerealms.com", e.ThorswapApi = "https://api.thorswap.net", e.ThorswapStatic = "https://static.thorswap.net", e))(R || {});
const q = Object.values(j), ve = Object.keys(j), ne = q.reduce(
var k = /* @__PURE__ */ ((e) => (e.Arbitrum = "ARB", e.Avalanche = "AVAX", e.Binance = "BNB", e.BinanceSmartChain = "BSC", e.Bitcoin = "BTC", e.BitcoinCash = "BCH", e.Cosmos = "GAIA", e.Dogecoin = "DOGE", e.Ethereum = "ETH", e.Kujira = "KUJI", e.Litecoin = "LTC", e.Maya = "MAYA", e.Optimism = "OP", e.Polygon = "MATIC", e.THORChain = "THOR", e))(k || {}), te = /* @__PURE__ */ ((e) => (e.Arbitrum = "42161", e.ArbitrumHex = "0xa4b1", e.Avalanche = "43114", e.AvalancheHex = "0xa86a", e.Binance = "Binance-Chain-Tigris", e.BinanceSmartChain = "56", e.BinanceSmartChainHex = "0x38", e.Bitcoin = "bitcoin", e.BitcoinCash = "bitcoincash", e.Cosmos = "cosmoshub-4", e.Dogecoin = "dogecoin", e.Kujira = "kaiyo-1", e.Ethereum = "1", e.EthereumHex = "0x1", e.Litecoin = "litecoin", e.Maya = "mayachain-mainnet-v1", e.MayaStagenet = "mayachain-stagenet-v1", e.Optimism = "10", e.OptimismHex = "0xa", e.Polygon = "137", e.PolygonHex = "0x89", e.THORChain = "thorchain-mainnet-v1", e.THORChainStagenet = "thorchain-stagenet-v2", e))(te || {}), de = /* @__PURE__ */ ((e) => (e.Arbitrum = "https://arb1.arbitrum.io/rpc", e.Avalanche = "https://node-router.thorswap.net/avalanche-c", e.Binance = "", e.BinanceSmartChain = "https://bsc-dataseed.binance.org", e.Bitcoin = "https://node-router.thorswap.net/bitcoin", e.BitcoinCash = "https://node-router.thorswap.net/bitcoin-cash", e.Cosmos = "https://node-router.thorswap.net/cosmos/rpc", e.Kujira = "https://rpc-kujira.synergynodes.com/", e.Dogecoin = "https://node-router.thorswap.net/dogecoin", e.Ethereum = "https://node-router.thorswap.net/ethereum", e.Litecoin = "https://node-router.thorswap.net/litecoin", e.Maya = "https://tendermint.mayachain.info", e.MayaStagenet = "https://stagenet.tendermint.mayachain.info", e.Optimism = "https://mainnet.optimism.io", e.Polygon = "https://polygon-rpc.com", e.THORChain = "https://rpc.thorswap.net", e.THORChainStagenet = "https://stagenet-rpc.ninerealms.com", e))(de || {}), R = /* @__PURE__ */ ((e) => (e.Cosmos = "https://node-router.thorswap.net/cosmos/rest", e.Kujira = "https://lcd-kujira.synergynodes.com/", e.MayanodeMainnet = "https://mayanode.mayachain.info", e.MayanodeStagenet = "https://stagenet.mayanode.mayachain.info", e.ThornodeMainnet = "https://thornode.thorswap.net", e.ThornodeStagenet = "https://stagenet-thornode.ninerealms.com", e.ThorswapApi = "https://api.thorswap.net", e.ThorswapStatic = "https://static.thorswap.net", e))(R || {});
const q = Object.values(k), ve = Object.keys(k), ne = q.reduce(
(e, t) => {
const n = ve.find((r) => j[r] === t);
const n = ve.find((r) => k[r] === t);
return n && (e[t] = n), e;

@@ -136,5 +136,5 @@ },

duplex: !0
}, ke = (e) => pe.includes(e) ? e.toUpperCase() : e, je = ["get", "put", "head", "delete", "options", "trace"], qe = [408, 413, 429, 500, 502, 503, 504], me = [413, 429, 503], ce = {
}, je = (e) => pe.includes(e) ? e.toUpperCase() : e, ke = ["get", "put", "head", "delete", "options", "trace"], qe = [408, 413, 429, 500, 502, 503, 504], me = [413, 429, 503], ce = {
limit: 2,
methods: je,
methods: ke,
statusCodes: qe,

@@ -266,3 +266,3 @@ afterStatusCodes: me,

}, n.hooks),
method: ke(n.method ?? this._input.method),
method: je(n.method ?? this._input.method),
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing

@@ -744,3 +744,3 @@ prefixUrl: String(n.prefixUrl || ""),

}
var C, y, f, D, k, Ne, U, z, L, Z;
var C, y, f, D, j, Ne, U, z, L, Z;
const se = class se {

@@ -750,3 +750,3 @@ constructor(t) {

O(this, f);
O(this, k);
O(this, j);
O(this, U);

@@ -758,3 +758,3 @@ O(this, L);

const n = ee(t), r = typeof t == "object";
this.decimal = r ? t.decimal : void 0, this.decimalMultiplier = r && "decimalMultiplier" in t ? t.decimalMultiplier : N(Math.max(_e($(n)), this.decimal || 0)), T(this, k, Ne).call(this, n);
this.decimal = r ? t.decimal : void 0, this.decimalMultiplier = r && "decimalMultiplier" in t ? t.decimalMultiplier : N(Math.max(_e($(n)), this.decimal || 0)), T(this, j, Ne).call(this, n);
}

@@ -942,3 +942,3 @@ static fromBigInt(t, n) {

}
}, k = new WeakSet(), Ne = function(t) {
}, j = new WeakSet(), Ne = function(t) {
const n = $(t) || "0";

@@ -1117,9 +1117,9 @@ this.bigIntValue = T(this, L, Z).call(this, n);

throw new Error("Invalid asset identifier");
const s = e.includes(".") && !t ? e : `${a.THORChain}.${r}`, [i, o] = s.split("."), [u, c] = (t ? r : o).split("-");
const s = e.includes(".") && !t ? e : `${a.THORChain}.${r}`, [i, ...o] = s.split("."), [u, c] = (t ? r : o.join(".")).split("-"), _ = t ? r : o.join(".");
return {
address: c == null ? void 0 : c.toLowerCase(),
chain: i,
isGasAsset: fe({ chain: i, symbol: o }),
isGasAsset: fe({ chain: i, symbol: _ }),
isSynthetic: t,
symbol: (t ? `${n}/` : "") + (c ? `${u}-${(c == null ? void 0 : c.toLowerCase()) ?? ""}` : o),
symbol: (t ? `${n}/` : "") + (c ? `${u}-${(c == null ? void 0 : c.toLowerCase()) ?? ""}` : _),
ticker: u

@@ -1126,0 +1126,0 @@ };

@@ -45,3 +45,3 @@ {

"types": "./dist/index.d.ts",
"version": "1.0.0-rc.65",
"version": "1.0.0-rc.66",
"scripts": {

@@ -48,0 +48,0 @@ "build": "vite build",

@@ -257,2 +257,21 @@ import { BaseDecimal, Chain } from '@swapkit/types';

});
test('returns proper avax string with address from `@swapkit/tokens` lists', async () => {
await AssetValue.loadStaticAssets();
const avaxBTCb = 'AVAX.BTC.b-0x152b9d0fdc40c096757f570a51e494bd4b943e50';
const AvaxBTCb = AssetValue.fromStringSync(avaxBTCb);
expect(AvaxBTCb).toBeDefined();
expect(AvaxBTCb).toEqual(
expect.objectContaining({
address: '0x152b9d0fdc40c096757f570a51e494bd4b943e50',
chain: Chain.Avalanche,
decimal: 8,
isGasAsset: false,
isSynthetic: false,
symbol: 'BTC.b-0x152b9d0fdc40c096757f570a51e494bd4b943e50',
ticker: 'BTC.b',
}),
);
});
});

@@ -259,0 +278,0 @@

@@ -111,2 +111,3 @@ import { BaseDecimal, Chain, ChainToChainId } from '@swapkit/types';

};
return new AssetValue({

@@ -235,4 +236,6 @@ tax,

// TODO refactor & split into smaller functions
function getAssetInfo(identifier: string) {
const isSynthetic = identifier.slice(0, 14).includes('/');
const [synthChain, synthSymbol] =

@@ -248,4 +251,8 @@ identifier.split('.')[0].toUpperCase() === Chain.THORChain

const [chain, symbol] = adjustedIdentifier.split('.') as [Chain, string];
const [ticker, address] = (isSynthetic ? synthSymbol : symbol).split('-') as [string, string?];
const [chain, ...rest] = adjustedIdentifier.split('.') as [Chain, string];
const [ticker, address] = (isSynthetic ? synthSymbol : rest.join('.')).split('-') as [
string,
string?,
];
const symbol = isSynthetic ? synthSymbol : rest.join('.');

@@ -252,0 +259,0 @@ return {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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