import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import React from "react";
import { t } from "ttag";
import Metamask from "../../assets/metamask";
import { useEthereum } from "../../contexts/ethereum";
import Button from "../button";
export const EthSign = ({ message, callback }) => {
    const [pending, setPending] = React.useState(false);
    const { address, sign } = useEthereum();
    const handleClick = React.useCallback(async () => {
        if (address && message) {
            try {
                setPending(true);
                const sig = await sign(message);
                callback(sig?.slice(2));
            }
            catch (e) {
                console.warn(e);
            }
            finally {
                setPending(false);
            }
        }
    }, [address, callback, message, sign]);
    return (_jsxs(Button, { pending: pending, onClick: handleClick, disabled: !address || !message, children: [_jsx(Metamask, { style: { marginRight: 8 } }), t `Sign`] }));
};
//# sourceMappingURL=sign-button.js.map