@daimo/pay
Version:
Seamless crypto payments. Onboard users from any chain, any coin into your app with one click.
50 lines (47 loc) • 1.61 kB
JavaScript
import { useConnect as useConnect$1 } from 'wagmi';
import { usePayContext } from './usePayContext.js';
/**
* This is a wrapper around wagmi's useConnect hook that adds some
* additional functionality.
*/
function useConnect({ ...props } = {}) {
const context = usePayContext();
const { connect, connectAsync, connectors, ...rest } = useConnect$1({
...props,
mutation: {
...props.mutation,
onError(err) {
if (err.message) {
if (err.message === "Proposal expired") {
context.log("[CONNECT] Connection request timed out. Please try again.", err);
return;
}
if (err.message !== "User rejected request") {
context.log(`[CONNECT] ${err.message}`, err);
}
}
else {
context.log(`[CONNECT] 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,
};
}
export { useConnect };
//# sourceMappingURL=useConnect.js.map