* Add guides, update NFT cards * New account permmissions page * New account page and fix distribute native on split for non-supported api chains * Stuff * Fix build * Fix typo * New images * Change order
24 lines
688 B
TypeScript
24 lines
688 B
TypeScript
import { useQueryClient, useMutation } from "@tanstack/react-query";
|
|
import { useSDK } from "@thirdweb-dev/react";
|
|
import invariant from "tiny-invariant";
|
|
import { walletKeys } from "../cache-keys";
|
|
|
|
type TransferInput = {
|
|
address: string;
|
|
amount: string;
|
|
};
|
|
|
|
export function useTransferNativeToken() {
|
|
const sdk = useSDK();
|
|
const queryClient = useQueryClient();
|
|
return useMutation({
|
|
mutationFn: async (input: TransferInput) => {
|
|
invariant(sdk, "SDK is not initialized");
|
|
await sdk.wallet.transfer(input.address, input.amount);
|
|
},
|
|
onSuccess: (_, variables) => {
|
|
queryClient.invalidateQueries(walletKeys.balances(variables.address));
|
|
},
|
|
});
|
|
}
|