@daimo/pay
Version:
Seamless crypto payments. Onboard users from any chain, any coin into your app with one click.
41 lines (38 loc) • 1.11 kB
JavaScript
import { useState, useEffect } from 'react';
function useSolanaPaymentOptions({
trpc,
address,
usdRequired,
isDepositFlow,
showSolanaPaymentMethod
}) {
const [options, setOptions] = useState(null);
const [isLoading, setIsLoading] = useState(false);
useEffect(() => {
if (!showSolanaPaymentMethod) return;
const refreshWalletPaymentOptions = async () => {
if (address == null || usdRequired == null) return;
setOptions(null);
setIsLoading(true);
try {
const newOptions = await trpc.getSolanaPaymentOptions.query({
pubKey: address,
// API expects undefined for deposit flow.
usdRequired: isDepositFlow ? void 0 : usdRequired
});
setOptions(newOptions);
} catch (error) {
console.error(error);
} finally {
setIsLoading(false);
}
};
refreshWalletPaymentOptions();
}, [address, usdRequired, isDepositFlow, showSolanaPaymentMethod]);
return {
options,
isLoading
};
}
export { useSolanaPaymentOptions };
//# sourceMappingURL=useSolanaPaymentOptions.js.map