Skip to content

Commit

Permalink
fix: faucet request fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
BLuEScioN committed Dec 18, 2024
1 parent 54b42ed commit 300a596
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
7 changes: 1 addition & 6 deletions src/app/sandbox/faucet/PageClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,8 @@
import { NextPage } from 'next';
import React from 'react';

import { Badge } from '../../../common/components/Badge';
import { DropIcon } from '../../../common/components/icons/drop';
import { useFaucet } from '../../../common/queries/useFaucet';
import { Box } from '../../../ui/Box';
import { Button } from '../../../ui/Button';
import { Flex } from '../../../ui/Flex';
import { Grid } from '../../../ui/Grid';
import { HStack } from '../../../ui/HStack';
import { Icon } from '../../../ui/Icon';
import { Stack } from '../../../ui/Stack';
Expand Down Expand Up @@ -44,7 +39,7 @@ const Faucet: NextPage = () => {
if (stackingIndex <= 3) {
setIndex(i => ++i);
if (stackingIndex === 3 && !!stxAddress) {
void runFaucetStx({ address: stxAddress, staking: true });
void runFaucetStx({ address: stxAddress, stacking: true });
}
}
};
Expand Down
16 changes: 13 additions & 3 deletions src/common/queries/useFaucet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,21 @@ import { useApiClient } from '../../api/useApiClient';
export function useFaucet() {
const apiClient = useApiClient();
return useMutation({
mutationFn: async ({ address, staking }: { address: string; staking?: boolean }) => {
mutationFn: async ({ address, stacking }: { address: string; stacking?: boolean }) => {
if (!address) return undefined;
const { data, error } = await apiClient.POST('/extended/v1/faucets/stx', {
body: { address, ...(staking ? { staking: true } : {}) },
const { data, error } = await apiClient.POST(`/extended/v1/faucets/stx`, {
params: {
query: {
address,
stacking,
},
},
body: {
// @ts-expect-error
content: 'application/json',
},
});

if (error) {
throw new Error(getErrorMessage(error));
}
Expand Down

0 comments on commit 300a596

Please sign in to comment.