Skip to content

Commit 4839173

Browse files
committed
[TOOL-4354] Nebula: Configure erc20Value for swap prepared transaction (#6926)
<!-- ## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes" If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000): ## Notes for the reviewer Anything important to call out? Be sure to also clarify these in your comments. ## How to test Unit tests, playground, etc. --> <!-- start pr-codex --> --- ## PR-Codex overview This PR introduces logic to handle transactions involving native tokens in the `SwapTransactionCardLayout` component. It determines if the transaction involves selling a native token and adjusts the transaction data accordingly. ### Detailed summary - Added a constant `isSellingNativeToken` to check if the transaction involves selling the native token. - Updated the transaction object to conditionally set `erc20Value` based on whether the native token is being sold. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent 1e82083 commit 4839173

File tree

1 file changed

+11
-0
lines changed
  • apps/dashboard/src/app/nebula-app/(app)/components/Swap

1 file changed

+11
-0
lines changed

apps/dashboard/src/app/nebula-app/(app)/components/Swap/SwapCards.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ import { TransactionButton } from "components/buttons/TransactionButton";
22
import { useV5DashboardChain } from "lib/v5-adapter";
33
import { ArrowRightLeftIcon, CheckIcon } from "lucide-react";
44
import {
5+
NATIVE_TOKEN_ADDRESS,
56
type PreparedTransaction,
67
type ThirdwebClient,
8+
getAddress,
79
prepareTransaction,
810
toTokens,
911
} from "thirdweb";
@@ -39,6 +41,9 @@ export function SwapTransactionCardLayout(props: {
3941
const { swapData } = props;
4042
const txChain = useV5DashboardChain(swapData.transaction.chainId);
4143

44+
const isSellingNativeToken =
45+
getAddress(swapData.from.address) === getAddress(NATIVE_TOKEN_ADDRESS);
46+
4247
return (
4348
<div className="max-w-lg">
4449
<div className="rounded-xl border bg-card">
@@ -102,6 +107,12 @@ export function SwapTransactionCardLayout(props: {
102107
client: props.client,
103108
data: swapData.transaction.data,
104109
to: swapData.transaction.to,
110+
erc20Value: isSellingNativeToken
111+
? undefined
112+
: {
113+
amountWei: BigInt(swapData.from.amount),
114+
tokenAddress: swapData.from.address,
115+
},
105116
});
106117

107118
props.sendTx(tx);

0 commit comments

Comments
 (0)