Skip to content

Commit

Permalink
Update sdk-dapp to LTS and add useIsWebProvider hook (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgavrila authored Dec 28, 2023
1 parent 12e276b commit de3886b
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"@fortawesome/free-solid-svg-icons": "6.4.0",
"@fortawesome/react-fontawesome": "0.2.0",
"@multiversx/sdk-core": "12.16.0",
"@multiversx/sdk-dapp": "2.25.2",
"@multiversx/sdk-dapp": "2.26.2",
"@multiversx/sdk-network-providers": "2.2.0",
"axios": "1.6.2",
"classnames": "2.3.2",
Expand Down
1 change: 1 addition & 0 deletions src/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from './sdkDappHooks';
export * from './withPageTitle';
export * from './transactions';
export * from './useScrollToElement';
export * from './useIsWebProvider';
9 changes: 9 additions & 0 deletions src/hooks/useIsWebProvider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { LoginMethodsEnum } from 'types/sdkDappTypes';
import { useGetAccountProvider } from './sdkDappHooks';

export const useIsWebProvider = () => {
const { providerType } = useGetAccountProvider();
const isWebProvider = providerType === LoginMethodsEnum.wallet;

return { isWebProvider };
};
10 changes: 5 additions & 5 deletions src/pages/Dashboard/components/Widget.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Card } from 'components/Card';
import { getCallbackRoute } from 'utils/getCallbackRoute';
import { WidgetType } from 'types/widget.types';
import { LoginMethodsEnum } from 'types/sdkDappTypes';
import { useGetAccountProvider } from 'hooks/sdkDappHooks';
import { useIsWebProvider } from 'hooks';

export const Widget = ({
title,
Expand All @@ -12,9 +11,10 @@ export const Widget = ({
widget: MxWidget,
props = {}
}: WidgetType) => {
const { providerType } = useGetAccountProvider();
const isWebWallet = providerType === LoginMethodsEnum.wallet;
const callbackRoute = anchor ? getCallbackRoute({ anchor, isWebWallet }) : '';
const { isWebProvider } = useIsWebProvider();
const callbackRoute = anchor
? getCallbackRoute({ anchor, isWebProvider })
: '';

return (
<Card
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Dashboard/widgets/SignMessage/SignMessage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useMemo, useState } from 'react';
import { useState } from 'react';
import type { MouseEvent } from 'react';
import {
faFileSignature,
Expand Down
6 changes: 3 additions & 3 deletions src/utils/getCallbackRoute.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
type GetCallbackRouteProps = {
anchor?: string;
isWebWallet?: boolean;
isWebProvider?: boolean;
};

export const getCallbackRoute = ({
anchor,
isWebWallet
isWebProvider
}: GetCallbackRouteProps) => {
if (!isWebWallet) {
if (!isWebProvider) {
return '';
}

Expand Down
9 changes: 4 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -924,16 +924,15 @@
keccak "3.0.2"
protobufjs "7.2.4"

"@multiversx/sdk-dapp@2.25.2":
version "2.25.2"
resolved "https://registry.yarnpkg.com/@multiversx/sdk-dapp/-/sdk-dapp-2.25.2.tgz#64ce52b9c9c7adeff0ec24aa2d2bfeca0d188eb8"
integrity sha512-mWd25A/mznIXkJn6LmSMX8IotpJHCGixLjWO+4Lxok0cztnQ3pQWzimJ5Mfiu/k0eYJxv53X3C1YO11DnWvjWA==
"@multiversx/sdk-dapp@2.26.2":
version "2.26.2"
resolved "https://registry.yarnpkg.com/@multiversx/sdk-dapp/-/sdk-dapp-2.26.2.tgz#eec7be64e735485dfa6fe9dfd5504055fae90d6b"
integrity sha512-vzHoIy9Sg+ptvcqH0S8amO9rmF8vB1K3tqBzhAk75ekHo4Nnrw/mmhqJClH7IwqTpp6/CFSXM/RBVaPVh1wiqA==
dependencies:
"@multiversx/sdk-core" "12.16.0"
"@multiversx/sdk-extension-provider" "3.0.0"
"@multiversx/sdk-hw-provider" "6.4.0"
"@multiversx/sdk-native-auth-client" "1.0.6"
"@multiversx/sdk-network-providers" "2.2.0"
"@multiversx/sdk-opera-provider" "1.0.0-alpha.1"
"@multiversx/sdk-wallet" "4.2.0"
"@multiversx/sdk-wallet-connect-provider" "4.0.4"
Expand Down

0 comments on commit de3886b

Please sign in to comment.