Skip to content

Commit fa12c97

Browse files
committed
switch to useelven
1 parent ac71669 commit fa12c97

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+999
-3910
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
### [5.0.0](https://github.com/ElvenTools/elven-tools-dapp/releases/tag/v5.0.0) (2023-02-21)
2+
- switch to [@useelven/core](https://www.useelven.com) when it comes to core functionality
3+
- update dependencies
4+
15
### [4.2.0](https://github.com/ElvenTools/elven-tools-dapp/releases/tag/v4.2.0) (2023-01-28)
26
- rebuilt in-app navigation using Next Link instead ActionButton that should be used only for triggering functions, and not navigation
37
- `useScQuery` can now query more complex data using abi file and result parser from MultiversX sdk-core

components/Footer.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ export const Footer = () => {
4848
{'Elven.js'}
4949
</Text>
5050
<Text fontWeight="hairline"> | </Text>
51+
<Text
52+
as="a"
53+
color="elvenTools.color3.base"
54+
href="https://www.useElven.com"
55+
target="_blank"
56+
rel="noopener noreferrer nofollow"
57+
>
58+
{'useElven'}
59+
</Text>
60+
<Text fontWeight="hairline"> | </Text>
5161
<Text
5262
as="a"
5363
color="elvenTools.color3.base"

components/Hero.tsx

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { Box, Text } from '@chakra-ui/react';
22
import { CollectionInfoBox } from './CollectionInfoBox';
3-
import { getActiveNetworkConfiguration } from '../config/network';
43
import { shortenHash } from '../utils/shortenHash';
5-
import { useElvenScQuery } from '../hooks/interaction/elvenScHooks/useElvenScQuery';
6-
import { SCQueryType } from '../hooks/interaction/useScQuery';
4+
import { useElvenScQuery } from '../hooks/useElvenScQuery';
5+
import { SCQueryType, useConfig } from '@useelven/core';
76

87
const smartContractAddress = process.env.NEXT_PUBLIC_NFT_SMART_CONTRACT;
98

109
export const Hero = () => {
10+
const { explorerAddress } = useConfig();
1111
const { data: collectionSize, isLoading: collectionSizeLoading } =
1212
useElvenScQuery<number>({
1313
funcName: 'getTotalSupply',
@@ -91,9 +91,7 @@ export const Hero = () => {
9191
content={collectionTicker || '-'}
9292
label="Collection ticker. Click for details."
9393
isLoading={collectionTickerLoading}
94-
href={`${
95-
getActiveNetworkConfiguration().explorerAddress
96-
}/collections/${collectionTicker}`}
94+
href={`${explorerAddress}/collections/${collectionTicker}`}
9795
/>
9896
<CollectionInfoBox
9997
content={
@@ -104,9 +102,7 @@ export const Hero = () => {
104102
label={`Minter smart contract. Click for details.`}
105103
href={
106104
smartContractAddress
107-
? `${
108-
getActiveNetworkConfiguration().explorerAddress
109-
}/accounts/${smartContractAddress}`
105+
? `${explorerAddress}/accounts/${smartContractAddress}`
110106
: undefined
111107
}
112108
/>

components/MintForm.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
import { useMintTransaction } from '../hooks/interaction/elvenScHooks/useMintTransaction';
1+
import { useMintTransaction } from '../hooks/useMintTransaction';
22
import { useCallback, FC, useState } from 'react';
33
import { ActionButton } from './ActionButton';
4-
import { ScTransactionCb } from '../hooks/interaction/useScTransaction';
5-
import { useLoginInfo } from '../hooks/auth/useLoginInfo';
6-
import { LoginMethodsEnum } from '../types/enums';
4+
import {
5+
useLoginInfo,
6+
LoginMethodsEnum,
7+
TransactionCallbackParams,
8+
} from '@useelven/core';
79
import {
810
NumberInput,
911
NumberInputField,
@@ -16,12 +18,12 @@ import { TransactionPendingModal } from './core/TransactionPendingModal';
1618

1719
interface MintFormProps {
1820
leftToMintForUser: number;
19-
cb?: (params: ScTransactionCb) => void;
21+
cb?: (params: TransactionCallbackParams) => void;
2022
}
2123

2224
export const MintForm: FC<MintFormProps> = ({ leftToMintForUser, cb }) => {
2325
const [amount, setAmount] = useState(1);
24-
const { mint, pending, transaction, error } = useMintTransaction(cb);
26+
const { mint, pending, txResult, error } = useMintTransaction(cb);
2527
const { loginMethod } = useLoginInfo();
2628

2729
const handleMint = useCallback(() => {
@@ -80,7 +82,7 @@ export const MintForm: FC<MintFormProps> = ({ leftToMintForUser, cb }) => {
8082
</Box>
8183
<TransactionPendingModal
8284
isOpen={pending}
83-
successTxHash={transaction?.getHash().toString()}
85+
successTxHash={txResult?.hash}
8486
txError={error}
8587
additionalMessage={getAdditionalPendingMessage()}
8688
/>

components/MintHero.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ import { Box, Text, useBreakpointValue } from '@chakra-ui/react';
33
import Link from 'next/link';
44
import { useCallback, useEffect } from 'react';
55
import { Address } from '@multiversx/sdk-core';
6-
import { SCQueryType } from '../hooks/interaction/useScQuery';
7-
import { useElvenScQuery } from '../hooks/interaction/elvenScHooks/useElvenScQuery';
6+
import { SCQueryType, useAccount } from '@useelven/core';
7+
import { useElvenScQuery } from '../hooks/useElvenScQuery';
88
import { MintForm } from './MintForm';
99
import { Authenticated } from './core/Authenticated';
10-
import { useAccount } from '../hooks/auth/useAccount';
1110
import { LoginModalButton } from './core/LoginModalButton';
1211
import { NFTLeftToMint } from './NFTLeftToMint';
1312
import { NFTAllowlistEnabled } from './NFTAllowlistEnabled';

components/NFTAllowlistEnabled.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Box, Spinner, Text } from '@chakra-ui/react';
22
import { FC } from 'react';
3-
import { SCQueryType } from '../hooks/interaction/useScQuery';
4-
import { useElvenScQuery } from '../hooks/interaction/elvenScHooks/useElvenScQuery';
3+
import { SCQueryType } from '@useelven/core';
4+
import { useElvenScQuery } from '../hooks/useElvenScQuery';
55

66
interface NFTAllowlistEnabledProps {
77
data?: number;

components/NFTLeftToMint.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Box, Spinner, Text } from '@chakra-ui/react';
22
import { FC } from 'react';
3-
import { useElvenScQuery } from '../hooks/interaction/elvenScHooks/useElvenScQuery';
4-
import { SCQueryType } from '../hooks/interaction/useScQuery';
3+
import { useElvenScQuery } from '../hooks/useElvenScQuery';
4+
import { SCQueryType } from '@useelven/core';
55

66
interface NFTLeftToMintProps {
77
data?: number;

components/NftImageHelper.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@
66
import { FC, CSSProperties, PropsWithChildren } from 'react';
77
import { Box } from '@chakra-ui/react';
88
import Image, { ImageProps } from 'next/image';
9-
import {
10-
customIPFSGateway,
11-
getActiveNetworkConfiguration,
12-
} from '../config/network';
9+
import { useConfig } from '@useelven/core';
10+
import { customIPFSGateway } from '../config/dappCustoms';
1311

1412
const commonImageStyles: CSSProperties = {
1513
objectFit: 'contain',
@@ -39,11 +37,12 @@ const isDefaultThumbnail = (thumbnail: string) => {
3937

4038
const getImageUrlFromIPFS = (
4139
multiversxIPFSGatewayUrl: string,
42-
thumbnail: string
40+
thumbnail: string,
41+
IPFSGateway: string
4342
) => {
4443
if (multiversxIPFSGatewayUrl) {
4544
const CIDandImageFileName = multiversxIPFSGatewayUrl.replace(
46-
getActiveNetworkConfiguration().multiversIPFSGateway,
45+
IPFSGateway,
4746
''
4847
);
4948
return `${customIPFSGateway}${CIDandImageFileName}`;
@@ -81,12 +80,17 @@ export const NftImageHelper: FC<NftImageHelperProps> = ({
8180
multiversxIPFSGatewayUrl,
8281
href,
8382
}) => {
83+
const { IPFSGateway } = useConfig();
8484
return (
8585
<>
86-
{isDefaultThumbnail(thumbnail) ? (
86+
{isDefaultThumbnail(thumbnail) && IPFSGateway ? (
8787
<MaybeWithHref href={href}>
8888
<Image
89-
src={getImageUrlFromIPFS(multiversxIPFSGatewayUrl, thumbnail)}
89+
src={getImageUrlFromIPFS(
90+
multiversxIPFSGatewayUrl,
91+
thumbnail,
92+
IPFSGateway
93+
)}
9094
alt=""
9195
{...commonImagesProps}
9296
/>

components/ProfileNFTsList.tsx

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
import { Box, Stack, Spinner, Card, CardBody, Text } from '@chakra-ui/react';
22
import Link from 'next/link';
3-
import { useAccount } from '../hooks/auth/useAccount';
4-
import { useApiCall } from '../hooks/interaction/useApiCall';
3+
import { useAccount, useApiCall, SCQueryType, useConfig } from '@useelven/core';
54
import { NFT } from '../types/nfts';
6-
import { SCQueryType } from '../hooks/interaction/useScQuery';
7-
import { useElvenScQuery } from '../hooks/interaction/elvenScHooks/useElvenScQuery';
5+
import { useElvenScQuery } from '../hooks/useElvenScQuery';
86
import { NftImageHelper } from './NftImageHelper';
9-
import { getActiveNetworkConfiguration } from '../config/network';
107

118
const SIZE_PER_PAGE = 10000;
129

1310
export const ProfileNFTsList = () => {
1411
const { address } = useAccount();
12+
const { explorerAddress } = useConfig();
1513

1614
const { data: collectionTicker, isLoading: collectionTickerLoading } =
1715
useElvenScQuery<number>({
@@ -71,9 +69,7 @@ export const ProfileNFTsList = () => {
7169
<NftImageHelper
7270
thumbnail={nft.media?.[0].thumbnailUrl}
7371
multiversxIPFSGatewayUrl={nft.url}
74-
href={`${
75-
getActiveNetworkConfiguration().explorerAddress
76-
}/nfts/${nft.identifier}`}
72+
href={`${explorerAddress}/nfts/${nft.identifier}`}
7773
/>
7874
</Stack>
7975
<Box
@@ -83,9 +79,7 @@ export const ProfileNFTsList = () => {
8379
textAlign="center"
8480
>
8581
<a
86-
href={`${
87-
getActiveNetworkConfiguration().explorerAddress
88-
}/nfts/${nft.identifier}`}
82+
href={`${explorerAddress}/nfts/${nft.identifier}`}
8983
rel="noopener noreferrer"
9084
target="_blank"
9185
>
@@ -94,9 +88,7 @@ export const ProfileNFTsList = () => {
9488
</Box>
9589
<Box color="elvenTools.white" textAlign="center">
9690
<a
97-
href={`${
98-
getActiveNetworkConfiguration().explorerAddress
99-
}/nfts/${nft.identifier}`}
91+
href={`${explorerAddress}/nfts/${nft.identifier}`}
10092
rel="noopener noreferrer"
10193
target="_blank"
10294
>

components/ProfileUserData.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { Box, Avatar, Stack, Icon, Tooltip } from '@chakra-ui/react';
22
import { BiLink } from 'react-icons/bi';
3-
import { avatarIdUrl, getActiveNetworkConfiguration } from '../config/network';
3+
import { avatarIdUrl } from '../config/dappCustoms';
44
import { shortenHash } from '../utils/shortenHash';
55
import { Account } from '../types/account';
6-
import { useApiCall } from '../hooks/interaction/useApiCall';
7-
import { useAccount } from '../hooks/auth/useAccount';
6+
import { useApiCall, useAccount, useConfig } from '@useelven/core';
87

98
export const ProfileUserData = () => {
109
const { address } = useAccount();
10+
const { explorerAddress } = useConfig();
1111

1212
const { data: accountData, isLoading: accountDataPending } =
1313
useApiCall<Account>({ url: `/accounts/${address}` });
@@ -58,9 +58,7 @@ export const ProfileUserData = () => {
5858
direction="row"
5959
alignItems="center"
6060
as="a"
61-
href={`${
62-
getActiveNetworkConfiguration().explorerAddress
63-
}/address/${address}`}
61+
href={`${explorerAddress}/address/${address}`}
6462
target="_blank"
6563
rel="noopener noreferrer"
6664
>

0 commit comments

Comments
 (0)