Skip to content

Commit 4e7032f

Browse files
committed
improve transaction status ui
1 parent 0a79827 commit 4e7032f

File tree

8 files changed

+295
-252
lines changed

8 files changed

+295
-252
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
### [0.14.3](https://github.com/xdevguild/buildo.dev/releases/tag/v0.14.3) (2024-07-06)
2+
- improve transaction status UI
3+
- update dependencies
4+
15
### [0.14.2](https://github.com/xdevguild/buildo.dev/releases/tag/v0.14.2) (2024-06-21)
26
- update useElven to support MultiversX Web wallet hub
37
- update dependencies

components/elven-ui/ledger-accounts-list.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { FC, useCallback, useState, useEffect, useRef } from 'react';
22
import { useRouter } from 'next/navigation';
3-
import { LoginMethodsEnum, useLoginInfo } from '@useelven/core';
3+
import { LoginMethodsEnum } from '@useelven/core';
44
import { Button } from '@/components/ui/button';
55
import { shortenHash } from '@/lib/shorten-hash';
66
import { errorParse } from '@/lib/error-parse';
@@ -29,8 +29,6 @@ export const LedgerAccountsList: FC<LedgerAccountsListProps> = ({
2929
const [error, setError] = useState<string>();
3030
const [chosenAddress, setAddress] = useState<string>();
3131

32-
const { loginToken } = useLoginInfo();
33-
3432
const router = useRouter();
3533

3634
const getAccounts = async (page: number) =>
@@ -151,12 +149,6 @@ export const LedgerAccountsList: FC<LedgerAccountsListProps> = ({
151149
<div className="mt-3 break-words text-center">
152150
<div className="font-bold">Address:</div> {chosenAddress}
153151
</div>
154-
{loginToken && (
155-
<div className="mt-3">
156-
<div className="text-center font-bold">Login token:</div>
157-
<div className="break-words text-center">{loginToken}</div>
158-
</div>
159-
)}
160152
</div>
161153
);
162154
}

components/header.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import { Github, Twitter } from 'lucide-react';
21
import { LoginModalButton } from '@/components/elven-ui/login-modal-button';
32
import { ModeToggle } from '@/components/mode-toggle';
43
import Link from 'next/link';
54
import { Separator } from '@/components/ui/separator';
65
import { HeaderAddress } from '@/components/header-address';
76
import { HeaderChainIndicator } from '@/components/header-chain-indicator';
7+
import GitHubIcon from '/public/github.svg';
8+
import XIcon from '/public/x.svg';
89
import Image from 'next/image';
910

1011
export const Header = () => {
@@ -30,10 +31,21 @@ export const Header = () => {
3031
target="_blank"
3132
title="GitHub"
3233
>
33-
<Github size={25} />
34+
<Image
35+
src={GitHubIcon}
36+
width={20}
37+
height={20}
38+
alt="Buildo GitHub"
39+
/>
3440
</a>
3541
<a href="https://x.com/BuildoDev" target="_blank" title="Twitter">
36-
<Twitter size={25} />
42+
<Image
43+
src={XIcon}
44+
width={18}
45+
height={18}
46+
alt="Buildo X.com"
47+
className="mt-[2px]"
48+
/>
3749
</a>
3850
</div>
3951
<HeaderAddress />

hooks/use-tx-status.tsx

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { useConfig } from '@useelven/core';
1+
import { useConfig, useLoggingIn, useLoginInfo } from '@useelven/core';
22
import { ExternalToast, toast } from 'sonner';
33
import { useEffect, useRef } from 'react';
44
import { Spinner } from '@/components/ui/spinner';
5+
import { SquareArrowOutUpRight } from 'lucide-react';
56

67
type TxStatusProps = {
78
error: string;
@@ -17,33 +18,72 @@ export const useTxStatus = ({
1718
pending,
1819
}: TxStatusProps) => {
1920
const { explorerAddress } = useConfig();
21+
const { loginMethod } = useLoginInfo();
22+
const { loggedIn } = useLoggingIn();
2023

2124
const toastId = useRef<string | number>();
2225

2326
useEffect(() => {
27+
if (!loggedIn) return;
28+
29+
const getLoginMethodName = () => {
30+
switch (loginMethod) {
31+
case 'ledger':
32+
return 'Ledger wallet';
33+
case 'walletconnect':
34+
return 'xPortal wallet';
35+
case 'extension':
36+
return 'Browser extension wallet';
37+
case 'xalias':
38+
return 'xAlias';
39+
case 'hub':
40+
return 'Hub';
41+
default:
42+
return '';
43+
}
44+
};
2445
const toasterOptions: ExternalToast = {
2546
id: toastId?.current,
2647
position: 'top-right',
2748
...(explorerAddress
2849
? {
2950
action: (
3051
<a
31-
className="flex items-center justify-between gap-2 text-xs underline"
52+
className="flex flex-1 items-center justify-end gap-2 text-xs underline"
3253
href={`${explorerAddress}/transactions/${pendingHash || successHash}`}
3354
>
34-
{pending && <Spinner size={20} />}{' '}
35-
<span>Check in the Explorer!</span>
55+
{pending ? (
56+
<>
57+
<Spinner size={20} />
58+
{pendingHash && <SquareArrowOutUpRight size={20} />}
59+
</>
60+
) : (
61+
<span>Check in the Explorer!</span>
62+
)}
3663
</a>
3764
),
3865
}
3966
: {}),
4067
};
4168
if (pending) {
42-
toastId.current = toast.info('Transaction is pending', toasterOptions);
69+
toastId.current = toast.info(
70+
!pendingHash
71+
? `Confirm with ${getLoginMethodName()}`
72+
: 'Transaction is pending',
73+
toasterOptions
74+
);
4375
} else if (successHash) {
4476
toast.success('Transaction success', toasterOptions);
4577
} else if (error) {
4678
toast.error('Transaction error', toasterOptions);
4779
}
48-
}, [successHash, pendingHash, error, explorerAddress, pending]);
80+
}, [
81+
successHash,
82+
pendingHash,
83+
error,
84+
explorerAddress,
85+
pending,
86+
loginMethod,
87+
loggedIn,
88+
]);
4989
};

0 commit comments

Comments
 (0)