Skip to content

Commit

Permalink
update dependencies and code adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
juliancwirko committed Jun 18, 2023
1 parent 78ac4dd commit 87c5b1f
Show file tree
Hide file tree
Showing 4 changed files with 963 additions and 1,053 deletions.
34 changes: 13 additions & 21 deletions components/containers/Deposit.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { Box, Spinner, Input, Stack, Text, Heading } from '@chakra-ui/react';
import { useCallback, useState } from 'react';
import { BigUIntValue } from '@multiversx/sdk-core';
import {
ContractFunction,
BigUIntValue,
BytesValue,
ContractCallPayloadBuilder,
} from '@multiversx/sdk-core';
import { useConfig, useTransaction } from '@useelven/core';
useConfig,
useTokenTransfer,
ScTokenTransferType,
} from '@useelven/core';
import { ActionButton } from '../tools/ActionButton';
import { shortenHash } from '../../utils/shortenHash';

Expand All @@ -24,7 +23,7 @@ export const Deposit = () => {
const [tokenId, setTokenId] = useState('');
const [amount, setAmount] = useState('');
const [maxAmountPerDay, setMaxAmountPerDay] = useState('');
const { pending, triggerTx, transaction } = useTransaction();
const { pending, transfer, transaction } = useTokenTransfer({});

const handleDepositTx = useCallback(() => {
if (
Expand All @@ -34,27 +33,20 @@ export const Deposit = () => {
!maxAmountPerDay
)
return;
// Prepare data payload for smart contract using MultiversX JS SDK core tools
const data = new ContractCallPayloadBuilder()
.setFunction(new ContractFunction('ESDTTransfer'))
.setArgs([
BytesValue.fromUTF8(tokenId),
new BigUIntValue(amount),
BytesValue.fromUTF8('setLimit'),
new BigUIntValue(maxAmountPerDay),
])
.build();

triggerTx({
transfer({
type: ScTokenTransferType.ESDTTransfer,
tokenId,
address: process.env.NEXT_PUBLIC_FAUCET_SMART_CONTRACT_ADDRESS,
amount,
gasLimit: 3000000,
value: 0,
data,
endpointName: 'setLimit',
endpointArgs: [new BigUIntValue(maxAmountPerDay)],
});
setTokenId('');
setAmount('');
setMaxAmountPerDay('');
}, [amount, maxAmountPerDay, tokenId, triggerTx]);
}, [amount, maxAmountPerDay, tokenId, transfer]);

const handleTokenChange = (event: React.ChangeEvent<HTMLInputElement>) =>
setTokenId(event.target.value);
Expand Down
4 changes: 1 addition & 3 deletions components/tools/LoginComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import { ActionButton } from './ActionButton';
import { LedgerAccountsList } from './LedgerAccountsList';

export const LoginComponent = memo(() => {
// If you need the auth signature and token pas your unique token in useLogin
// For the demo purposes here is a dummy token, you should probably use MX Native Auth token
const {
login,
isLoggedIn,
Expand All @@ -20,7 +18,7 @@ export const LoginComponent = memo(() => {
walletConnectPairings,
walletConnectPairingLogin,
walletConnectRemovePairing,
} = useLogin({ token: 'token_just_for_testing_purposes' });
} = useLogin();

const [loginMethod, setLoginMethod] = useState<LoginMethodsEnum>();

Expand Down
Loading

0 comments on commit 87c5b1f

Please sign in to comment.