@clerk/clerk-react
Version:
Clerk.dev React library
26 lines • 1.35 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SignInWithMetamaskButton = void 0;
const tslib_1 = require("tslib");
const react_1 = (0, tslib_1.__importDefault)(require("react"));
const contexts_1 = require("../contexts");
const utils_1 = require("../utils");
exports.SignInWithMetamaskButton = (0, contexts_1.withClerk)((_a) => {
var { clerk, children } = _a, props = (0, tslib_1.__rest)(_a, ["clerk", "children"]);
const { identifier, redirectUrl } = props, rest = (0, tslib_1.__rest)(props, ["identifier", "redirectUrl"]);
children = (0, utils_1.normalizeWithDefaultValue)(children, 'Sign in with Metamask');
const child = (0, utils_1.assertSingleChild)(children)('SignInWithMetamaskButton');
const clickHandler = async () => {
async function authenticate() {
await clerk.authenticateWithMetamask({ identifier, redirectUrl });
}
void authenticate();
};
const wrappedChildClickHandler = async (e) => {
await (0, utils_1.safeExecute)(child.props.onClick)(e);
return clickHandler();
};
const childProps = Object.assign(Object.assign({}, rest), { onClick: wrappedChildClickHandler });
return react_1.default.cloneElement(child, childProps);
}, 'SignInWithMetamask');
//# sourceMappingURL=SignInWithMetamaskButton%20copy.js.map