diff --git a/app/api/api.ts b/app/api/api.ts index 224ae90..36dbf26 100644 --- a/app/api/api.ts +++ b/app/api/api.ts @@ -20,8 +20,13 @@ async function getTxDetails(txid: string) { return axios.get(api + `/v1/tx/${txid}`); } +async function getFaucetStx(address: string) { + return axios.post(api + `/v1/debug/faucet?address=${address}`, { address }); +} + export const Api = { getAddressBalance, getAddressTransactions, getTxDetails, + getFaucetStx, }; diff --git a/app/components/home/balance-card.tsx b/app/components/home/balance-card.tsx index df85468..fae1472 100644 --- a/app/components/home/balance-card.tsx +++ b/app/components/home/balance-card.tsx @@ -1,14 +1,24 @@ -import React, { FC } from 'react'; +import React, { FC, useState } from 'react'; import { Box, Button, Text, ArrowIcon } from '@blockstack/ui'; import { toHumanReadableStx } from '../../utils/unit-convert'; +import { safeAwait } from '../../utils/safe-await'; +import { delay } from '../../utils/delay'; interface BalanceCardProps { balance: string | null; - onSelectSend: () => void; - onSelectReceive: () => void; + onSelectSend(): void; + onSelectReceive(): void; + onRequestTestnetStx(): Promise; } -export const BalanceCard: FC = ({ balance, onSelectReceive, onSelectSend }) => { +export const BalanceCard: FC = args => { + const { balance, onSelectReceive, onSelectSend, onRequestTestnetStx } = args; + const [requestingTestnetStx, setRequestingTestnetStx] = useState(false); + const requestTestnetStacks = async () => { + setRequestingTestnetStx(true); + await safeAwait(Promise.allSettled([onRequestTestnetStx(), delay(1500)])); + setRequestingTestnetStx(false); + }; return ( @@ -26,6 +36,12 @@ export const BalanceCard: FC = ({ balance, onSelectReceive, on Receive + ); diff --git a/app/modals/transaction/decrypt-wallet-form.tsx b/app/modals/transaction/decrypt-wallet-form.tsx index bcc89d7..6500388 100644 --- a/app/modals/transaction/decrypt-wallet-form.tsx +++ b/app/modals/transaction/decrypt-wallet-form.tsx @@ -1,5 +1,5 @@ import React, { FC } from 'react'; -import { Box, Input, Text, Button } from '@blockstack/ui'; +import { Box, Input, Text } from '@blockstack/ui'; import { ErrorLabel } from '../../components/error-label'; import { ErrorText } from '../../components/error-text'; @@ -31,9 +31,15 @@ export const DecryptWalletForm: Props = args => { )} Forgot password?{' '} - {' '} + {' '} to set a new password. diff --git a/app/modals/transaction/transaction-form.tsx b/app/modals/transaction/transaction-form.tsx index 4cfbc5a..70207e7 100644 --- a/app/modals/transaction/transaction-form.tsx +++ b/app/modals/transaction/transaction-form.tsx @@ -1,5 +1,5 @@ import React, { FC } from 'react'; -import { Flex, Text, Input, Box } from '@blockstack/ui'; +import { Flex, Text, Input, Box, Button } from '@blockstack/ui'; import { ErrorLabel } from '../../components/error-label'; import { ErrorText } from '../../components/error-text'; import { FormikProps } from 'formik'; @@ -9,9 +9,12 @@ import { toHumanReadableStx } from '../../utils/unit-convert'; interface TxModalFormProps { balance: string; form: FormikProps<{ recipient: string; amount: string; memo: string }>; + isCalculatingMaxSpend: boolean; + onSendEntireBalance(): void; } -export const TxModalForm: FC = ({ balance, form }) => { +export const TxModalForm: FC = args => { + const { balance, form, isCalculatingMaxSpend, onSendEntireBalance } = args; return ( diff --git a/app/pages/app.tsx b/app/pages/app.tsx index 218aafa..7f15449 100644 --- a/app/pages/app.tsx +++ b/app/pages/app.tsx @@ -43,7 +43,7 @@ export function App(props: Props) { justifyContent="space-between" pl="90px" height="100%" - backgroundColor={winState === 'focused' ? null : '#FAFAFC'} + backgroundColor={winState === 'focused' ? 'white' : '#FAFAFC'} > { balance={balance} onSelectSend={() => dispatch(homeActions.openTxModal())} onSelectReceive={() => dispatch(homeActions.openReceiveModal())} + onRequestTestnetStx={async () => Api.getFaucetStx(address)} /> ); const stackingPromoCard = ;