@reservoir0x/relay-kit-ui
Version:
Relay is the Fastest and Cheapest Way to Bridge and Transact Across Chains.
37 lines • 2.27 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const jsx_runtime_1 = require("react/jsx-runtime");
const index_js_1 = require("../primitives/index.js");
const index_js_2 = require("../../hooks/index.js");
const events_js_1 = require("../../constants/events.js");
const SwapButton = ({ transactionModalOpen, depositAddressModalOpen, isValidFromAddress, isValidToAddress, context, showHighPriceImpactWarning, onConnectWallet, quote, address, hasInsufficientBalance, isInsufficientLiquidityError, debouncedInputAmountValue, debouncedOutputAmountValue, isSameCurrencySameRecipientSwap, fromChainWalletVMSupported, recipientWalletSupportsChain, onClick, ctaCopy, onAnalyticEvent, isFetchingQuote }) => {
const isMounted = (0, index_js_2.useMounted)();
if (isMounted && (address || !fromChainWalletVMSupported)) {
const invalidAmount = !quote ||
Number(debouncedInputAmountValue) === 0 ||
Number(debouncedOutputAmountValue) === 0;
return ((0, jsx_runtime_1.jsx)(index_js_1.Button, { css: { justifyContent: 'center' }, color: showHighPriceImpactWarning ? 'error' : 'primary', "aria-label": context, disabled: isFetchingQuote ||
(isValidToAddress &&
(isValidFromAddress || !fromChainWalletVMSupported) &&
(invalidAmount ||
hasInsufficientBalance ||
isInsufficientLiquidityError ||
transactionModalOpen ||
depositAddressModalOpen ||
isSameCurrencySameRecipientSwap ||
!recipientWalletSupportsChain)), onClick: () => {
onClick();
}, children: ctaCopy }));
}
return ((0, jsx_runtime_1.jsx)(index_js_1.Button, { css: { justifyContent: 'center' }, "aria-label": "Connect wallet", onClick: () => {
if (!onConnectWallet) {
throw 'Missing onWalletConnect function';
}
onConnectWallet();
onAnalyticEvent?.(events_js_1.EventNames.CONNECT_WALLET_CLICKED, {
context
});
}, children: "Connect Wallet" }));
};
exports.default = SwapButton;
//# sourceMappingURL=SwapButton.js.map