Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed network switch and issue token #44

Merged
merged 5 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- [Fixed network switch and issue token](https://github.com/multiversx/mx-lite-wallet-dapp/pull/44)

## [[1.0.2](https://github.com/multiversx/mx-lite-wallet-dapp/pull/42)] - 2024-08-27

- [Added register sovereign token](https://github.com/multiversx/mx-wallet-dapp/pull/43)
Expand Down
2 changes: 1 addition & 1 deletion src/components/Dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const Dropdown = ({
<div className='py-1' role='none'>
{options.map((option, index) => (
<Button
className='block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 hover:text-gray-900'
className='w-full text-left block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 hover:text-gray-900'
data-testid={option.value}
key={`${option.value}-${index}`}
onClick={handleSelectOption(option)}
Expand Down
12 changes: 0 additions & 12 deletions src/config/config.devnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,6 @@ export const networks: NetworkType[] = [
walletAddress: 'https://devnet-wallet.multiversx.com',
WEGLDid: ''
},
{
default: false,
id: EnvironmentsEnum.devnet,
name: 'Gateway',
apiAddress: '',
gatewayUrl: 'https://devnet-gateway.multiversx.com',
extrasApi: 'https://devnet-extras-api.multiversx.com',
sampleAuthenticatedDomains: [''],
sovereignContractAddress: '',
walletAddress: 'https://devnet-wallet.multiversx.com',
WEGLDid: ''
},
{
default: false,
id: EnvironmentsEnum.mainnet,
Expand Down
12 changes: 0 additions & 12 deletions src/config/config.mainnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,6 @@ export const networks: NetworkType[] = [
walletAddress: 'https://devnet-wallet.multiversx.com',
WEGLDid: ''
},
{
default: false,
id: EnvironmentsEnum.devnet,
name: 'Gateway',
apiAddress: '',
gatewayUrl: 'https://devnet-gateway.multiversx.com',
extrasApi: 'https://devnet-extras-api.multiversx.com',
sampleAuthenticatedDomains: [''],
sovereignContractAddress: '',
walletAddress: 'https://devnet-wallet.multiversx.com',
WEGLDid: ''
},
{
default: true,
id: EnvironmentsEnum.mainnet,
Expand Down
12 changes: 0 additions & 12 deletions src/config/config.sovereign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,6 @@ export const networks: NetworkType[] = [
walletAddress: 'https://devnet-wallet.multiversx.com',
WEGLDid: ''
},
{
default: false,
id: EnvironmentsEnum.devnet,
name: 'Gateway',
apiAddress: '',
gatewayUrl: 'https://devnet-gateway.multiversx.com',
extrasApi: 'https://devnet-extras-api.multiversx.com',
sampleAuthenticatedDomains: [''],
sovereignContractAddress: '',
walletAddress: 'https://devnet-wallet.multiversx.com',
WEGLDid: ''
},
{
default: false,
id: EnvironmentsEnum.mainnet,
Expand Down
12 changes: 0 additions & 12 deletions src/config/config.testnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,6 @@ export const networks: NetworkType[] = [
walletAddress: 'https://devnet-wallet.multiversx.com',
WEGLDid: ''
},
{
default: false,
id: EnvironmentsEnum.devnet,
name: 'Gateway',
apiAddress: '',
gatewayUrl: 'https://devnet-gateway.multiversx.com',
extrasApi: 'https://devnet-extras-api.multiversx.com',
sampleAuthenticatedDomains: [''],
sovereignContractAddress: '',
walletAddress: 'https://devnet-wallet.multiversx.com',
WEGLDid: ''
},
{
default: false,
id: EnvironmentsEnum.mainnet,
Expand Down
7 changes: 6 additions & 1 deletion src/pages/IssueToken/hooks/useIssueTokenForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {

import { DECIMALS } from 'localConstants';
import { IssueTokenFieldsEnum } from '../types';
import BigNumber from 'bignumber.js';
razvantomegea marked this conversation as resolved.
Show resolved Hide resolved

export const useIssueTokenForm = () => {
const { address } = useGetAccount();
Expand Down Expand Up @@ -74,7 +75,11 @@ export const useIssueTokenForm = () => {
sender: new Address(address),
tokenName: values.tokenName,
tokenTicker: values.tokenTicker.toUpperCase(),
initialSupply: BigInt(values.mintedValue),
initialSupply: BigInt(
new BigNumber(values.mintedValue)
.pow(10, values.numDecimals)
.toNumber()
),
numDecimals: BigInt(values.numDecimals),
canFreeze: true,
canWipe: true,
Expand Down
9 changes: 5 additions & 4 deletions src/pages/RegisterToken/hooks/useRegisterTokenForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import { getRegisterTokenTransaction } from '../helpers';
import { RegisterTokenFormFieldsEnum } from '../types';

const defaultChain = {
label: capitalize(EnvironmentsEnum.devnet),
value: DEVNET_CHAIN_ID
label: capitalize(EnvironmentsEnum.testnet),
value: TESTNET_CHAIN_ID
razvantomegea marked this conversation as resolved.
Show resolved Hide resolved
};

const NetworkChainIdMap: Record<string, EnvironmentsEnum> = {
Expand All @@ -43,7 +43,8 @@ export const useRegisterTokenForm = () => {
const [sendType, setSendType] = useState(SendTypeEnum.esdt);
const isNFT = sendType === SendTypeEnum.nft;
const { tokenOptions, isLoading, tokens } = useTokenOptions({
sendType
sendType,
skipAddEgld: true
});

const refreshNativeAuthTokenForNetwork =
Expand Down Expand Up @@ -98,7 +99,7 @@ export const useRegisterTokenForm = () => {
await switchNetwork(NetworkChainIdMap[transaction.chainID]);
await sleep(1000);
const { nonce } = accountSelector(sdkDappStore.getState());
transaction.setNonce(nonce + 1);
transaction.setNonce(nonce);
await sendTransactions([transaction]);
navigate(routeNames.dashboard);
}
Expand Down
Loading