Skip to content

Commit

Permalink
Merge pull request #1330 from multiversx/development
Browse files Browse the repository at this point in the history
3.0.20
  • Loading branch information
arhtudormorar authored Nov 28, 2024
2 parents cc1c8b1 + 7e1029e commit 85348ba
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 21 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [[v3.0.20](https://github.com/multiversx/mx-sdk-dapp/pull/1330)] - 2024-11-28

- [Fixed EGLD-000000 token is not found](https://github.com/multiversx/mx-sdk-dapp/pull/1329)
- [Fixed address is not shown on ledger login](https://github.com/multiversx/mx-sdk-dapp/pull/1328)
- [Added support for custom web socket url](https://github.com/multiversx/mx-sdk-dapp/pull/1327)

## [[v3.0.19](https://github.com/multiversx/mx-sdk-dapp/pull/1326)] - 2024-11-28

- [Fix wallet hub webview](https://github.com/multiversx/mx-sdk-dapp/pull/1325)
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",
"version": "3.0.19",
"version": "3.0.20",
"description": "A library to hold the main logic for a dapp on the MultiversX blockchain",
"author": "MultiversX",
"license": "GPL-3.0-or-later",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import React from 'react';
import classNames from 'classnames';

import { DECIMALS } from 'constants/index';
import { withStyles } from 'hocs/withStyles';
import { useGetEgldPrice, useGetTokenDetails } from 'hooks';
import { ActiveLedgerTransactionType } from 'types';
import { NftEnumType } from 'types/tokens.types';
import { LoadingDots } from 'UI/LoadingDots';

import { getEgldLabel } from 'utils';
import { WithStylesImportType } from '../../../../../../hocs/useStyles';

import {
Expand Down Expand Up @@ -37,12 +39,27 @@ const ConfirmAmountComponent = ({
});

const { price: egldPrice } = useGetEgldPrice();

// TODO: Remove when EGLD-000000 is available on API
const egldTokenDetails = {
type: undefined,
isLoading: false,
esdtPrice: egldPrice,
identifier: 'EGLD-000000',
tokenAvatar: '',
tokenDecimals: DECIMALS,
tokenLabel: getEgldLabel()
};

const usedTokenDetails =
tokenId === egldTokenDetails.identifier ? egldTokenDetails : tokenDetails;

const {
type,
esdtPrice,
isLoading: isTokenDetailsLoading,
identifier
} = tokenDetails;
} = usedTokenDetails;

const isEgld = !tokenId;
const tokenPrice = isEgld ? egldPrice : esdtPrice;
Expand Down Expand Up @@ -82,7 +99,7 @@ const ConfirmAmountComponent = ({
<ConfirmAmountNftSft
amount={amount}
type={type}
tokenDetails={tokenDetails}
tokenDetails={usedTokenDetails}
/>
) : (
<ConfirmAmountData
Expand All @@ -91,7 +108,7 @@ const ConfirmAmountComponent = ({
amount={amount}
handleReference={handleAmountReference}
currentTransaction={currentTransaction}
tokenDetails={tokenDetails}
tokenDetails={usedTokenDetails}
tokenPrice={tokenPrice}
/>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,19 @@ const ConfirmAmountDataComponent = ({
addCommas
});

// TODO: Remove when EGLD-000000 is available on API
const usedIsEgld = isEgld || tokenDetails.identifier === 'EGLD-000000';
const formattedAmount = getFormattedAmount({ addCommas: true });
const rawAmount = getFormattedAmount({ addCommas: false });

return (
<div className={styles?.confirmAmountData}>
<div className={styles?.confirmAmountDataWrapper}>
{!isEgld && tokenAvatar && (
{!usedIsEgld && tokenAvatar && (
<img src={tokenAvatar} className={styles?.confirmAmountDataIcon} />
)}

{!isEgld && !tokenAvatar && (
{!usedIsEgld && !tokenAvatar && (
<div
className={classNames(
styles?.confirmAmountDataIcon,
Expand All @@ -77,11 +79,11 @@ const ConfirmAmountDataComponent = ({
>
<Balance
amount={formattedAmount}
egldIcon={isEgld}
egldIcon={usedIsEgld}
data-testid={DataTestIdsEnum.confirmAmount}
showTokenLabel
showTokenLabelSup
tokenLabel={isEgld ? network.egldLabel : identifier}
tokenLabel={usedIsEgld ? network.egldLabel : identifier}
className={styles?.confirmAmountDataBalance}
/>
</div>
Expand Down
16 changes: 9 additions & 7 deletions src/UI/TransactionData/TransactionData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ const TransactionDataComponent = ({
const [encodedScCall, ...remainingDataFields] =
highlight && isScCall ? highlight.split('@') : [];

const isHighlightedData = data && highlight;
const occurrences = isHighlightedData ? allOccurences(data, highlight) : [];
const isHighlightedData = decodedData && highlight;
const occurrences = isHighlightedData
? allOccurences(decodedData, highlight)
: [];
const showHighlight = isHighlightedData && occurrences.length > 0;

const handleElementReference = (element: HTMLElement | null) => {
Expand All @@ -83,7 +85,7 @@ const TransactionDataComponent = ({
if (showHighlight) {
switch (true) {
case decodedData.startsWith(highlight): {
const [, rest] = data.split(highlight);
const [, rest] = decodedData.split(highlight);

output = (
<>
Expand All @@ -93,8 +95,8 @@ const TransactionDataComponent = ({
);
break;
}
case data.endsWith(highlight): {
const [rest] = data.split(highlight);
case decodedData.endsWith(highlight): {
const [rest] = decodedData.split(highlight);

output = (
<>
Expand All @@ -114,7 +116,7 @@ const TransactionDataComponent = ({
const { start, end } = getUnHighlightedDataFieldParts({
occurrences,
transactionIndex,
data: data,
data: decodedData,
highlight
});

Expand Down Expand Up @@ -165,7 +167,7 @@ const TransactionDataComponent = ({
{decodedScCall}
</span>

{data && (
{decodedData && (
<CopyButton
text={decodedScCall}
className={styles?.transactionDataValueCopy}
Expand Down
6 changes: 2 additions & 4 deletions src/UI/TransactionData/components/TransactionDataDecode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,10 @@ export const TransactionDataDecode = ({
}, [method, data]);

return (
<div
data-testid={DataTestIdsEnum.transactionDataDecode}
className={classNames('transaction-data-decode', className)}
>
<div className={classNames('transaction-data-decode', className)}>
<select
className='transaction-data-decode-select'
data-testid={DataTestIdsEnum.transactionDataDecode}
value={method.value}
onChange={handleSelect}
>
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/login/useLedgerLogin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ export const useLedgerLogin = ({
);
}

await loginUser();
setIsLoading(false);
await loginUser();
} catch (err) {
onLoginFailed(err);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ export function useInitializeWebsocketConnection() {
// To avoid multiple connections to the same endpoint, we have to guard the initialization before the logic started
websocketConnection.status = WebsocketConnectionStatusEnum.PENDING;

const websocketUrl = await getWebsocketUrl(network.apiAddress);
const websocketUrl =
network.websocketUrl ?? (await getWebsocketUrl(network.apiAddress));

if (websocketUrl == null) {
console.warn('Can not get websocket url');
Expand Down
2 changes: 2 additions & 0 deletions src/types/network.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface BaseNetworkType {
xAliasAddress?: string;
roundDuration: number;
metamaskSnapWalletAddress?: string;
websocketUrl?: string;
}

export interface AccountInfoSliceNetworkType extends BaseNetworkType {
Expand Down Expand Up @@ -47,6 +48,7 @@ export interface CustomNetworkType {
walletConnectV2ProjectId?: string;
walletConnectV2Options?: any;
metamaskSnapWalletAddress?: string;
websocketUrl?: string;
}

export interface ApiNetworkConfigType {
Expand Down

0 comments on commit 85348ba

Please sign in to comment.