Skip to content

Commit

Permalink
Merge pull request #39 from multiversx/development
Browse files Browse the repository at this point in the history
Removed onlySafeTokens
  • Loading branch information
tdumitrache authored Nov 12, 2024
2 parents d43991b + 61f9e92 commit ef86363
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 26 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [[2.1.2](https://github.com/multiversx/mx-sdk-dapp-swap/pull/39)] - 2024-11-12

- [Removed onlySafeTokens](https://github.com/multiversx/mx-sdk-dapp-swap/pull/39)

## [[2.1.1](https://github.com/multiversx/mx-sdk-dapp-swap/pull/37)] - 2024-10-24

- [Fixed tests](https://github.com/multiversx/mx-sdk-dapp-swap/pull/37)
- [Remove network-providers dependency](https://github.com/multiversx/mx-sdk-dapp-swap/pull/35)

## [[2.1.0](https://github.com/multiversx/mx-sdk-dapp-swap/pull/34)] - 2024-10-21

- [Upgrade sdk-dapp](https://github.com/multiversx/mx-sdk-dapp-swap/pull/31)

## [[2.0.0](https://github.com/multiversx/mx-sdk-dapp-swap/pull/33)] - 2024-10-18
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiversx/sdk-dapp-swap",
"version": "2.1.1",
"version": "2.1.2",
"description": "A library to hold the main logic for swapping between tokens on the MultiversX blockchain",
"author": "MultiversX",
"license": "GPL-3.0-or-later",
Expand Down
15 changes: 1 addition & 14 deletions src/hooks/useTokens.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useMemo, useState } from 'react';
import { useAuthorizationContext } from 'components/SwapAuthorizationProvider';
import { GET_TOKENS, GET_TOKENS_AND_BALANCE, TokensType } from 'queries';
import { EsdtType, FactoryType, TokenTypesEnum, UserEsdtType } from 'types';
import { EsdtType, FactoryType, UserEsdtType } from 'types';
import { getSortedTokensByUsdValue } from 'utils';
import { useFetchTokenPrices } from './useFetchTokenPrices';
import { useLazyQueryWrapper } from './useLazyQueryWrapper';
Expand All @@ -10,20 +10,17 @@ const DEFAULT_OFFSET = 0;
const DEFAULT_LIMIT = 500;
const DEFAULT_ENABLED_SWAPS = true;
const DEFAULT_PRICE_POLLING = false;
const DEFAULT_ONLY_SAFE_TOKENS = true;
const DEFAULT_IDENTIFIERS: string[] = [];

interface GetTokensType {
limit?: number;
offset?: number;
identifiers?: string[];
enabledSwaps?: boolean;
onlySafeTokens?: boolean;
}

interface UseTokensType {
pricePolling?: boolean;
onlySafeTokens?: boolean;
}

export const useTokens = (options?: UseTokensType) => {
Expand All @@ -34,7 +31,6 @@ export const useTokens = (options?: UseTokensType) => {
}

const pricePolling = options?.pricePolling ?? DEFAULT_PRICE_POLLING;
const onlySafeTokens = options?.onlySafeTokens ?? DEFAULT_ONLY_SAFE_TOKENS;

const [tokens, setTokens] = useState<UserEsdtType[]>([]);
const [wrappedEgld, setWrappedEgld] = useState<EsdtType>();
Expand Down Expand Up @@ -84,15 +80,6 @@ export const useTokens = (options?: UseTokensType) => {
wrappedEgld: newWrappedEgld
});

if (onlySafeTokens) {
const safeTokens = sortedTokensWithBalance.filter(
({ type }) => type !== TokenTypesEnum.experimental
);

setTokens(safeTokens);
return;
}

setTokens(sortedTokensWithBalance);
};

Expand Down
3 changes: 1 addition & 2 deletions src/types/pairs.types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EsdtType, NftCollectionType, TokenTypesEnum } from './tokens.types';
import { EsdtType, NftCollectionType } from './tokens.types';

export enum PairStatesEnum {
active = 'Active',
Expand Down Expand Up @@ -26,7 +26,6 @@ export interface PairType {
address: string;
firstToken: EsdtType;
secondToken: EsdtType;
type: TokenTypesEnum;
feesAPR: string;
totalFeePercent: number;
specialFeePercent: number;
Expand Down
10 changes: 1 addition & 9 deletions src/types/tokens.types.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
export enum TokenTypesEnum {
core = 'Core',
ecosystem = 'Ecosystem',
community = 'Community',
experimental = 'Experimental',
unlisted = 'Unlisted'
}

export interface AssetsType {
website?: string;
description?: string;
Expand All @@ -27,7 +19,7 @@ export interface EsdtType extends TokenBaseType {
identifier: string;
owner: string;
price?: string;
type?: TokenTypesEnum | 'FungibleESDT-LP';
type?: 'FungibleESDT-LP';
previous24hPrice?: string;
previous7dPrice?: string;
}
Expand Down

0 comments on commit ef86363

Please sign in to comment.