Skip to content

Commit 8e9c51e

Browse files
committed
send server wallet txn for native transfer fix (#8701)
<!-- start pr-codex --> ## PR-Codex overview This PR focuses on normalizing the token address in the `SendProjectWalletModalContent` function to ensure consistency when interacting with the contract. It simplifies the handling of the native token address and adjusts how data is passed to the mutation. ### Detailed summary - Added `normalizedTokenAddress` to handle token address normalization. - Adjusted the condition to check `normalizedTokenAddress` instead of `values.tokenAddress`. - Updated the contract call to use `normalizedTokenAddress`. - Modified the mutation to include `normalizedTokenAddress` only if it exists. - Changed the mutation call from `void sendMutation.mutateAsync(values)` to `sendMutation.mutate(values)`. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved native token handling in the project wallet so native tokens are correctly recognized for balance display and transfers. * More reliable token decimal detection to ensure accurate balance reads. * Fixed send flow to reduce submission issues and make fund transfers more dependable. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 01a20cb commit 8e9c51e

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/components/project-wallet/project-wallet-details.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
createThirdwebClient,
2121
Engine,
2222
getContract,
23+
NATIVE_TOKEN_ADDRESS,
2324
readContract,
2425
type ThirdwebClient,
2526
toUnits,
@@ -889,11 +890,16 @@ function SendProjectWalletModalContent(props: SendProjectWalletModalProps) {
889890

890891
const sendMutation = useMutation({
891892
mutationFn: async (values: SendFormValues) => {
893+
const normalizedTokenAddress =
894+
values.tokenAddress?.toLowerCase() ===
895+
NATIVE_TOKEN_ADDRESS.toLowerCase()
896+
? undefined
897+
: values.tokenAddress;
892898
let decimals = 18;
893-
if (values.tokenAddress) {
899+
if (normalizedTokenAddress) {
894900
const decimalsRpc = await readContract({
895901
contract: getContract({
896-
address: values.tokenAddress,
902+
address: normalizedTokenAddress,
897903
chain: selectedChain,
898904
client,
899905
}),
@@ -914,7 +920,9 @@ function SendProjectWalletModalContent(props: SendProjectWalletModalProps) {
914920
teamId,
915921
walletAddress,
916922
secretKey: secretKeyValue,
917-
...(values.tokenAddress ? { tokenAddress: values.tokenAddress } : {}),
923+
...(normalizedTokenAddress
924+
? { tokenAddress: normalizedTokenAddress }
925+
: {}),
918926
...(vaultAccessTokenValue
919927
? { vaultAccessToken: vaultAccessTokenValue }
920928
: {}),
@@ -956,7 +964,7 @@ function SendProjectWalletModalContent(props: SendProjectWalletModalProps) {
956964
<Form {...form}>
957965
<form
958966
onSubmit={form.handleSubmit((values) => {
959-
void sendMutation.mutateAsync(values);
967+
sendMutation.mutate(values);
960968
})}
961969
>
962970
<div className="space-y-4 px-4 pb-8 lg:px-6">

0 commit comments

Comments
 (0)