@coin-voyage/paykit
Version:
Seamless crypto payments. Onboard users from any chain, any coin into your app with one click.
42 lines • 1.36 kB
JavaScript
/**
* This is a wrapper around wagmi's useConnect hook that adds some
* additional functionality.
*/
import { useConnect as wagmiUseConnect, } from "wagmi";
import usePayContext from "../components/contexts/pay/index";
export function useConnect({ ...props } = {}) {
const context = usePayContext();
const { connect, connectAsync, connectors, ...rest } = wagmiUseConnect({
...props,
mutation: {
...props.mutation,
onError(err) {
if (err.message) {
if (err.message !== "User rejected request") {
context.log(err.message, err);
}
}
else {
context.log("Could not connect.", err);
}
},
},
});
return {
connect: ({ connector, chainId, mutation, }) => {
return connect({
connector,
chainId: chainId ?? context.options?.initialChainId,
}, mutation);
},
connectAsync: async ({ connector, chainId, mutation, }) => {
return connectAsync({
connector,
chainId: chainId ?? context.options?.initialChainId,
}, mutation);
},
connectors,
...rest,
};
}
//# sourceMappingURL=useConnect.js.map