Skip to content

Commit

Permalink
replace multiversx npm libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
juliancwirko committed Jan 15, 2023
1 parent ac12361 commit 45a3ab0
Show file tree
Hide file tree
Showing 25 changed files with 2,460 additions and 1,976 deletions.
4 changes: 2 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ NEXT_PUBLIC_MULTIVERSX_CHAIN = devnet
# You have three options:
#
# 1. By commenting this out the dapp will use the default
# MultiversX api endpoint (e.g. https://devnet-api.elrond.com)
# MultiversX api endpoint (e.g. https://devnet-api.multiversx.com)
#
# Note: MULTIVERSX_PRIVATE_API needs to be removed/commented out.
#
Expand Down Expand Up @@ -48,7 +48,7 @@ NEXT_PUBLIC_MINT_BASE_GAS_LIMIT = 13000000
# This can be either a custom api endpoint or the default MultiversX api endpoint.
# You will have to delete this or comment this out, if you don't wanna
# mask / proxy your MultiversX api endpoint.
# MULTIVERSX_PRIVATE_API = https://devnet-api.elrond.com
# MULTIVERSX_PRIVATE_API = https://devnet-api.multiversx.com

# Only this host will be allowed to consume the API (optional)
# It will work only inside the Dapp, no one will be able to use the endpoint, even in browser
Expand Down
9 changes: 6 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
### [4.0.1](https://github.com/ElvenTools/elven-tools-dapp/releases/tag/v4.0.1) (2023-01-01)
- fix for nfts list image fallback
- dependencies update
### [4.1.0](https://github.com/ElvenTools/elven-tools-dapp/releases/tag/v4.1.0) (2023-01-15)
- rebrand to multiversx (continuation)
- npm packages are replaced
- public api/explorer endpoints are replaced
- update dependencies
- **Breaking:** `useElrondNetworkSync` is now `useNetworkSync`

### [4.0.0](https://github.com/ElvenTools/elven-tools-dapp/releases/tag/v4.0.0) (2022-12-24)
- breaking: env vars naming changes and API proxy is now optional, check for more in the docs
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Check detailed docs on it here: [How to start with the Dapp](https://www.elven.t
### Main assumption for the dapp:

- it works on Nextjs
- it uses the newest version of erdjs without the dapp-core library.
- it uses the newest version of [sdk-core](https://github.com/multiversx/mx-sdk-js-core) without the [sdk-dapp](https://github.com/multiversx/mx-sdk-dapp) library.
it uses backend-side rewrites to hide the API endpoint. The only exposed one is `/api`
- it uses .env file - there is an example in the repo
- it uses chakra-ui
Expand Down
37 changes: 31 additions & 6 deletions components/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Container, Box, Text } from '@chakra-ui/react';
import { Container, Box, Text, Stack } from '@chakra-ui/react';
import packageJson from '../package.json';

export const Footer = () => {
Expand All @@ -22,17 +22,42 @@ export const Footer = () => {
world about it. Attribution is not required but welcomed in the form
of a backlink.
</Box>
<Box fontSize="xs" fontWeight="bold">
<Stack
fontSize="xs"
fontWeight="bold"
direction="row"
justifyContent="center"
>
<Text
as="a"
color="elvenTools.color3.base"
href="https://www.elven.tools"
target="_blank"
rel="noopener noreferrer"
>
elven.tools
</Text>{' '}
{' '}
Elven Tools ⚡
</Text>
<Text fontWeight="hairline"> | </Text>
<Text
as="a"
color="elvenTools.color3.base"
href="https://www.elvenjs.com"
target="_blank"
rel="noopener noreferrer nofollow"
>
{'Elven.js'}
</Text>
<Text fontWeight="hairline"> | </Text>
<Text
as="a"
color="elvenTools.color3.base"
href="https://github.com/xdevguild/buildo-begins"
target="_blank"
rel="noopener noreferrer nofollow"
>
{'Buildo Begins'}
</Text>
<Text fontWeight="hairline"> | </Text>
<Text
as="a"
color="elvenTools.color3.base"
Expand All @@ -42,7 +67,7 @@ export const Footer = () => {
>
julian.io
</Text>
</Box>
</Stack>
</Container>
</Box>
);
Expand Down
2 changes: 1 addition & 1 deletion components/MintForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const MintForm: FC<MintFormProps> = ({ leftToMintForUser, cb }) => {

const getAdditionalPendingMessage = () => {
if (loginMethod === LoginMethodsEnum.walletconnect) {
return 'Sign the transaction using Maiar mobile app. It will take some time to finish. You can always close this message. You will get the transaction hash when finished.';
return 'Sign the transaction using xPortal mobile app. It will take some time to finish. You can always close this message. You will get the transaction hash when finished.';
}
if (loginMethod === LoginMethodsEnum.ledger) {
return 'Sign the transaction using Ledger HW. It will take some time to finish. You can always close this message. You will get the transaction hash when finished.';
Expand Down
2 changes: 1 addition & 1 deletion components/MintHero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { Box, Text, useBreakpointValue } from '@chakra-ui/react';
import Link from 'next/link';
import { useCallback, useEffect } from 'react';
import { Address } from '@elrondnetwork/erdjs';
import { Address } from '@multiversx/sdk-core';
import { SCQueryType } from '../hooks/interaction/useScQuery';
import { useElvenScQuery } from '../hooks/interaction/elvenScHooks/useElvenScQuery';
import { MintForm } from './MintForm';
Expand Down
14 changes: 7 additions & 7 deletions components/NftImageHelper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const commonImagesProps = {

interface NftImageHelperProps {
thumbnail: string;
elrondIPFSGatewayUrl: string;
multiversxIPFSGatewayUrl: string;
href?: string;
}

Expand All @@ -38,12 +38,12 @@ const isDefaultThumbnail = (thumbnail: string) => {
};

const getImageUrlFromIPFS = (
elrondIPFSGatewayUrl: string,
multiversxIPFSGatewayUrl: string,
thumbnail: string
) => {
if (elrondIPFSGatewayUrl) {
const CIDandImageFileName = elrondIPFSGatewayUrl.replace(
getActiveNetworkConfiguration().elrondIPFSGateway,
if (multiversxIPFSGatewayUrl) {
const CIDandImageFileName = multiversxIPFSGatewayUrl.replace(
getActiveNetworkConfiguration().multiversIPFSGateway,
''
);
return `${customIPFSGateway}${CIDandImageFileName}`;
Expand Down Expand Up @@ -78,15 +78,15 @@ const MaybeWithHref: FC<PropsWithChildren<WithHrefProps>> = ({

export const NftImageHelper: FC<NftImageHelperProps> = ({
thumbnail,
elrondIPFSGatewayUrl,
multiversxIPFSGatewayUrl,
href,
}) => {
return (
<>
{isDefaultThumbnail(thumbnail) ? (
<MaybeWithHref href={href}>
<Image
src={getImageUrlFromIPFS(elrondIPFSGatewayUrl, thumbnail)}
src={getImageUrlFromIPFS(multiversxIPFSGatewayUrl, thumbnail)}
alt=""
{...commonImagesProps}
/>
Expand Down
2 changes: 1 addition & 1 deletion components/ProfileNFTsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const ProfileNFTsList = () => {
<Stack height={280} position="relative">
<NftImageHelper
thumbnail={nft.media?.[0].thumbnailUrl}
elrondIPFSGatewayUrl={nft.url}
multiversxIPFSGatewayUrl={nft.url}
href={`${
getActiveNetworkConfiguration().explorerAddress
}/nfts/${nft.identifier}`}
Expand Down
6 changes: 3 additions & 3 deletions components/core/LoginComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@ export const LoginComponent = memo(() => {
isFullWidth
onClick={handleLogin(LoginMethodsEnum.wallet)}
>
Elrond Web Wallet
Web Wallet
</ActionButton>
<ActionButton
isFullWidth
onClick={handleLogin(LoginMethodsEnum.extension)}
>
Maiar Browser Extension
Browser Extension
</ActionButton>
<ActionButton
isFullWidth
onClick={handleLogin(LoginMethodsEnum.walletconnect)}
>
Maiar Mobile App
xPortal App
</ActionButton>
<ActionButton isFullWidth onClick={handleLedgerAccountsList}>
Ledger
Expand Down
2 changes: 1 addition & 1 deletion components/core/MobileLoginQR.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const MobileLoginQR: FunctionComponent<MobileLoginQRProps> = ({
rel="noopener noreferrer nofollow"
target="_blank"
>
Maiar Login
xPortal Login
</Box>
</Flex>
) : null}
Expand Down
31 changes: 16 additions & 15 deletions config/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ export const networkConfig: Record<string, NetworkType> = {
decimals: '4',
gasPerDataByte: '1500',
walletConnectDeepLink:
'https://maiar.page.link/?apn=com.elrond.maiar.wallet&isi=1519405832&ibi=com.elrond.maiar.wallet&link=https://maiar.com/',
'https://maiar.page.link/?apn=com.elrond.maiar.wallet&isi=1519405832&ibi=com.elrond.maiar.wallet&link=https://xportal.com/',
walletConnectBridgeAddresses: ['https://bridge.walletconnect.org'],
walletAddress: 'https://devnet-wallet.elrond.com',
walletAddress: 'https://devnet-wallet.multiversx.com',
apiAddress:
process.env.NEXT_PUBLIC_MULTIVERSX_API || 'https://devnet-api.elrond.com',
explorerAddress: 'https://devnet-explorer.elrond.com',
elrondIPFSGateway: 'https://devnet-media.elrond.com/nfts/asset/',
process.env.NEXT_PUBLIC_MULTIVERSX_API ||
'https://devnet-api.multiversx.com',
explorerAddress: 'https://devnet-explorer.multiversx.com',
multiversIPFSGateway: 'https://devnet-media.multiversx.com/nfts/asset/',
apiTimeout: '10000',
},

Expand All @@ -44,14 +45,14 @@ export const networkConfig: Record<string, NetworkType> = {
decimals: '4',
gasPerDataByte: '1500',
walletConnectDeepLink:
'https://maiar.page.link/?apn=com.elrond.maiar.wallet&isi=1519405832&ibi=com.elrond.maiar.wallet&link=https://maiar.com/',
'https://maiar.page.link/?apn=com.elrond.maiar.wallet&isi=1519405832&ibi=com.elrond.maiar.wallet&link=https://xportal.com/',
walletConnectBridgeAddresses: ['https://bridge.walletconnect.org'],
walletAddress: 'https://testnet-wallet.elrond.com',
walletAddress: 'https://testnet-wallet.multiversx.com',
apiAddress:
process.env.NEXT_PUBLIC_MULTIVERSX_API ||
'https://testnet-api.elrond.com',
explorerAddress: 'https://testnet-explorer.elrond.com',
elrondIPFSGateway: 'https://testnet-media.elrond.com/nfts/asset/',
'https://testnet-api.multiversx.com',
explorerAddress: 'https://testnet-explorer.multiversx.com',
multiversIPFSGateway: 'https://testnet-media.multiversx.com/nfts/asset/',
apiTimeout: '10000',
},

Expand All @@ -64,13 +65,13 @@ export const networkConfig: Record<string, NetworkType> = {
decimals: '4',
gasPerDataByte: '1500',
walletConnectDeepLink:
'https://maiar.page.link/?apn=com.elrond.maiar.wallet&isi=1519405832&ibi=com.elrond.maiar.wallet&link=https://maiar.com/',
'https://maiar.page.link/?apn=com.elrond.maiar.wallet&isi=1519405832&ibi=com.elrond.maiar.wallet&link=https://xportal.com/',
walletConnectBridgeAddresses: ['https://bridge.walletconnect.org'],
walletAddress: 'https://wallet.elrond.com',
walletAddress: 'https://wallet.multiversx.com',
apiAddress:
process.env.NEXT_PUBLIC_MULTIVERSX_API || 'https://api.elrond.com',
explorerAddress: 'https://explorer.elrond.com',
elrondIPFSGateway: 'https://media.elrond.com/nfts/asset/',
process.env.NEXT_PUBLIC_MULTIVERSX_API || 'https://api.multiversx.com',
explorerAddress: 'https://explorer.multiversx.com',
multiversIPFSGateway: 'https://media.multiversx.com/nfts/asset/',
apiTimeout: '10000',
},
};
Expand Down
6 changes: 3 additions & 3 deletions hooks/auth/useExtensionLogin.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Address, Account } from '@elrondnetwork/erdjs';
import { ExtensionProvider } from '@elrondnetwork/erdjs-extension-provider';
import { Address, Account } from '@multiversx/sdk-core';
import { ExtensionProvider } from '@multiversx/sdk-extension-provider';
import { LoginMethodsEnum } from '../../types/enums';
import { optionalRedirect } from '../../utils/optionalRedirect';
import {
Expand All @@ -12,7 +12,7 @@ import { getNewLoginExpiresTimestamp } from '../../utils/expiresAt';
import { useLogout } from './useLogout';
import { Login } from '../../types/account';
import { useLoggingIn } from './useLoggingIn';
import { ApiNetworkProvider } from '@elrondnetwork/erdjs-network-providers';
import { ApiNetworkProvider } from '@multiversx/sdk-network-providers';
import { errorParse } from '../../utils/errorParse';

export const useExtensionLogin = (params?: Login) => {
Expand Down
6 changes: 3 additions & 3 deletions hooks/auth/useLedgerLogin.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Address, Account } from '@elrondnetwork/erdjs';
import { HWProvider } from '@elrondnetwork/erdjs-hw-provider';
import { ApiNetworkProvider } from '@elrondnetwork/erdjs-network-providers';
import { Address, Account } from '@multiversx/sdk-core';
import { HWProvider } from '@multiversx/sdk-hw-provider';
import { ApiNetworkProvider } from '@multiversx/sdk-network-providers';
import { LoginMethodsEnum } from '../../types/enums';
import { optionalRedirect } from '../../utils/optionalRedirect';
import {
Expand Down
6 changes: 3 additions & 3 deletions hooks/auth/useMobileAppLogin.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable react-hooks/exhaustive-deps */
import { Account, Address } from '@elrondnetwork/erdjs';
import { ApiNetworkProvider } from '@elrondnetwork/erdjs-network-providers';
import { WalletConnectProvider } from '@elrondnetwork/erdjs-wallet-connect-provider';
import { Account, Address } from '@multiversx/sdk-core';
import { ApiNetworkProvider } from '@multiversx/sdk-network-providers';
import { WalletConnectProvider } from '@multiversx/sdk-wallet-connect-provider';
import { useState, useRef } from 'react';
import { getActiveNetworkConfiguration } from '../../config/network';
import { LoginMethodsEnum } from '../../types/enums';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import {
setLoginInfoState,
} from '../../store/auth';
import * as network from '../../store/network';
import { Address, Account } from '@elrondnetwork/erdjs';
import { WalletProvider } from '@elrondnetwork/erdjs-web-wallet-provider';
import { WalletConnectProvider } from '@elrondnetwork/erdjs-wallet-connect-provider';
import { ExtensionProvider } from '@elrondnetwork/erdjs-extension-provider';
import { HWProvider } from '@elrondnetwork/erdjs-hw-provider';
import { ApiNetworkProvider } from '@elrondnetwork/erdjs-network-providers';
import { Address, Account } from '@multiversx/sdk-core';
import { WalletProvider } from '@multiversx/sdk-web-wallet-provider';
import { WalletConnectProvider } from '@multiversx/sdk-wallet-connect-provider';
import { ExtensionProvider } from '@multiversx/sdk-extension-provider';
import { HWProvider } from '@multiversx/sdk-hw-provider';
import { ApiNetworkProvider } from '@multiversx/sdk-network-providers';
import {
DAPP_INIT_ROUTE,
getActiveNetworkConfiguration,
Expand All @@ -31,7 +31,7 @@ import { clearAuthStates } from '../../store/auth';
import { DappProvider } from '../../types/network';
import { errorParse } from '../../utils/errorParse';

export const useElrondNetworkSync = () => {
export const useNetworkSync = () => {
const { logout } = useLogout();
const [accountDone, setAccountDone] = useState(false);
const [loginInfoDone, setLoginInfoDone] = useState(false);
Expand Down Expand Up @@ -135,7 +135,7 @@ export const useElrondNetworkSync = () => {

if (!dappProvider) {
switch (loginMethod) {
// Browser extension auth (Maiar defi wallet)
// Browser extension auth (MultiversX defi wallet)
case LoginMethodsEnum.extension:
dappProvider = ExtensionProvider.getInstance();
try {
Expand All @@ -152,7 +152,7 @@ export const useElrondNetworkSync = () => {
console.warn("Can't initialize the Dapp Provider!");
}
break;
// Maiar mobile app auth
// xPortal mobile app auth
case LoginMethodsEnum.walletconnect:
const providerHandlers = {
onClientLogin: () =>
Expand All @@ -176,7 +176,7 @@ export const useElrondNetworkSync = () => {
await dappProvider.init();
if (!dappProvider.isInitialized()) {
console.warn(
'Something went wrong trying to sync with the Maiar app!'
'Something went wrong trying to sync with the xPortal app!'
);
} else {
network.setNetworkState('dappProvider', dappProvider);
Expand Down
2 changes: 1 addition & 1 deletion hooks/auth/useWebWalletLogin.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { WalletProvider } from '@elrondnetwork/erdjs-web-wallet-provider';
import { WalletProvider } from '@multiversx/sdk-web-wallet-provider';
import { LoginMethodsEnum } from '../../types/enums';
import { getNewLoginExpiresTimestamp } from '../../utils/expiresAt';
import {
Expand Down
2 changes: 1 addition & 1 deletion hooks/interaction/elvenScHooks/useMintTransaction.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ContractFunction, TokenPayment, U32Value } from '@elrondnetwork/erdjs';
import { ContractFunction, TokenPayment, U32Value } from '@multiversx/sdk-core';
import BigNumber from 'bignumber.js';
import { useScTransaction, ScTransactionCb } from '../useScTransaction';
import { useElvenScQuery } from '../elvenScHooks/useElvenScQuery';
Expand Down
12 changes: 6 additions & 6 deletions hooks/interaction/useScTransaction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import {
TokenPayment,
TransactionWatcher,
ContractCallPayloadBuilder,
} from '@elrondnetwork/erdjs';
import { ApiNetworkProvider } from '@elrondnetwork/erdjs-network-providers';
} from '@multiversx/sdk-core';
import { ApiNetworkProvider } from '@multiversx/sdk-network-providers';
import {
WalletProvider,
WALLET_PROVIDER_CALLBACK_PARAM,
WALLET_PROVIDER_CALLBACK_PARAM_TX_SIGNED,
} from '@elrondnetwork/erdjs-web-wallet-provider';
} from '@multiversx/sdk-web-wallet-provider';
import { useSnapshot } from 'valtio';
import {
accountState,
Expand All @@ -27,9 +27,9 @@ import { LoginMethodsEnum } from '../../types/enums';
import { DappProvider } from '../../types/network';
import { getParamFromUrl } from '../../utils/getParamFromUrl';
import { useEffect, useState, useCallback } from 'react';
import { ExtensionProvider } from '@elrondnetwork/erdjs-extension-provider/out';
import { WalletConnectProvider } from '@elrondnetwork/erdjs-wallet-connect-provider/out';
import { HWProvider } from '@elrondnetwork/erdjs-hw-provider/out';
import { ExtensionProvider } from '@multiversx/sdk-extension-provider';
import { WalletConnectProvider } from '@multiversx/sdk-wallet-connect-provider';
import { HWProvider } from '@multiversx/sdk-hw-provider';
import { errorParse } from '../../utils/errorParse';

interface ScTransactionParams {
Expand Down
Loading

0 comments on commit 45a3ab0

Please sign in to comment.