Skip to content

Commit

Permalink
show tx hash before finalizing, update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
juliancwirko committed Feb 25, 2024
1 parent 31c0332 commit 16249f4
Show file tree
Hide file tree
Showing 7 changed files with 1,221 additions and 641 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### [7.5.0](https://github.com/ElvenTools/elven-tools-dapp/releases/tag/v7.5.0) (2024-02-25)
- update useElven - changes in callback urls naming, configuration for tx watcher timeout and patience
- add transaction hash in UI even when the transaction is not finalized yet

### [7.4.2](https://github.com/ElvenTools/elven-tools-dapp/releases/tag/v7.4.2) (2024-01-11)
- update useElven and dependencies

Expand Down
10 changes: 6 additions & 4 deletions components/MintForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ interface MintFormProps {

export const MintForm: FC<MintFormProps> = ({ leftToMintForUser, cb }) => {
const [amount, setAmount] = useState(1);
const { mint, pending, txResult, error } = useMintTransaction(cb);
const { mint, pending, transaction, txResult, error } =
useMintTransaction(cb);
const { loginMethod } = useLoginInfo();

const handleMint = useCallback(() => {
Expand All @@ -37,12 +38,12 @@ export const MintForm: FC<MintFormProps> = ({ leftToMintForUser, cb }) => {

const getAdditionalPendingMessage = () => {
if (loginMethod === LoginMethodsEnum.walletconnect) {
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.';
return 'Sign the transaction using xPortal mobile app. It will take some time to finish. You can always close this message. You can check the transaction in the explorer.';
}
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.';
return 'Sign the transaction using Ledger HW. It will take some time to finish. You can always close this message. You can check the transaction in the explorer.';
}
return 'It will take some time to finish. You can always close this message. You will get the transaction hash when finished.';
return 'It will take some time to finish. You can always close this message. You can check the transaction in the explorer.';
};

return (
Expand Down Expand Up @@ -83,6 +84,7 @@ export const MintForm: FC<MintFormProps> = ({ leftToMintForUser, cb }) => {
<TransactionPendingModal
isOpen={pending}
successTxHash={txResult?.hash}
txHash={transaction?.getHash().hex()}
txError={error}
additionalMessage={getAdditionalPendingMessage()}
/>
Expand Down
16 changes: 16 additions & 0 deletions components/core/TransactionPendingModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ interface TransactionPendingModalProps {
isOpen: boolean;
successTxHash?: string;
txError?: string;
txHash?: string;
additionalMessage?: string;
}

Expand All @@ -29,6 +30,7 @@ export const TransactionPendingModal: FC<TransactionPendingModalProps> = ({
isOpen = false,
successTxHash,
txError,
txHash,
additionalMessage,
}) => {
const { explorerAddress } = useConfig();
Expand Down Expand Up @@ -81,6 +83,20 @@ export const TransactionPendingModal: FC<TransactionPendingModalProps> = ({
<Text textAlign="center" fontWeight="semibold" fontSize="xl">
{txTitle()}
</Text>
{txHash && !successTxHash ? (
<Text
as="a"
textAlign="center"
textDecoration="underline"
display="inline-block"
width="100%"
mt={5}
href={`${explorerAddress}/transactions/${txHash}`}
target="_blank"
>
{shortenHash(txHash, 12)}
</Text>
) : null}

{!txError && (
<Flex alignItems="center" justifyContent="center" mt={8}>
Expand Down
5 changes: 4 additions & 1 deletion hooks/useMintTransaction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ export function useMintTransaction(
type: SCQueryType.NUMBER,
});

const { pending, triggerTx, txResult, error } = useTransaction({ cb });
const { pending, triggerTx, transaction, txResult, error } = useTransaction({
cb,
});

const mint = async (tokensAmount: number) => {
const tokens = tokensAmount || 1;
Expand Down Expand Up @@ -73,6 +75,7 @@ export function useMintTransaction(
pending,
mint,
txResult,
transaction,
error,
};
}
8 changes: 8 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,22 @@ const nextConfig = {
{
protocol: 'https',
hostname: '**.elrond.com',
port: '',
},
{
protocol: 'https',
hostname: '**.multiversx.com',
port: '',
},
{
protocol: 'https',
hostname: '**.nftstorage.link',
port: '',
},
{
protocol: 'https',
hostname: 'nftstorage.link',
port: '',
},
],
},
Expand Down
Loading

0 comments on commit 16249f4

Please sign in to comment.