diff --git a/components/activity.tsx b/components/activity.tsx index fee9880..57e81c9 100644 --- a/components/activity.tsx +++ b/components/activity.tsx @@ -73,6 +73,10 @@ export function Activity() {
{transfers.data.map((tx: any, index: number) => { const isIncoming = tx.type === "wallets.transfer.in"; + const explorerUrl = tx.onChain?.explorerLink ?? null; + const counterpartyAddress = isIncoming + ? tx.sender?.address + : tx.recipient?.address; return (
- {isIncoming - ? `From ${formatAddress(tx.sender?.address ?? "")}` - : `To ${formatAddress( - tx.recipient?.address ?? "" - )}`} + {isIncoming ? "From" : "To"}{" "} + + {counterpartyAddress ? formatAddress(counterpartyAddress) : ""} +
diff --git a/components/transfer.tsx b/components/transfer.tsx index 8bde12f..70f8c8d 100644 --- a/components/transfer.tsx +++ b/components/transfer.tsx @@ -10,7 +10,7 @@ export function TransferFunds() { const [amount, setAmount] = useState(null); const [amountInput, setAmountInput] = useState(""); const [isLoading, setIsLoading] = useState(false); - const [explorerLink, setExplorerLink] = useState(null); + const isStaging = process.env.NEXT_PUBLIC_CROSSMINT_API_KEY?.includes("staging"); async function handleOnTransfer() { if (wallet == null || recipient == null || amount == null) { @@ -18,10 +18,17 @@ export function TransferFunds() { return; } + if (recipient === wallet.address) { + alert("You cannot send funds to your own wallet."); + return; + } + try { setIsLoading(true); - const txn = await wallet.send(recipient, "usdxm", amount.toString()); - setExplorerLink(txn.explorerLink); + await wallet.send(recipient, "usdxm", amount.toString()); + setRecipient(null); + setAmount(null); + setAmountInput(""); } catch (err) { console.error("Transfer: ", err); if (err instanceof Error && err.name === "AuthRejectedError") { @@ -38,7 +45,20 @@ export function TransferFunds() {
-

Transfer funds

+
+

Transfer funds

+ {isStaging && ( +
+
+ i +
+
+ This environment uses devnet blockchain. To complete a transfer, the recipient must have a devnet wallet. +
+
+
+ )} +

Send funds to another wallet

@@ -88,7 +108,7 @@ export function TransferFunds() { />
- {/* Transfer Button */} + {/* Transfer Button */}
);