UNPKG

@abstract-foundation/agw-react

Version:
36 lines 1.46 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useAbstractClient = void 0; const agw_client_1 = require("@abstract-foundation/agw-client"); const react_query_1 = require("@tanstack/react-query"); const wagmi_1 = require("wagmi"); const useGlobalWalletSignerClient_js_1 = require("./useGlobalWalletSignerClient.js"); const useAbstractClient = ({ customPaymasterHandler, } = {}) => { const { data: signer, status, error } = (0, useGlobalWalletSignerClient_js_1.useGlobalWalletSignerClient)(); const [chain] = (0, wagmi_1.useChains)(); const config = (0, wagmi_1.useConfig)(); return (0, react_query_1.useQuery)({ gcTime: 0, queryKey: ['abstractClient'], queryFn: async () => { if (error) { throw error; } if (!signer) { throw new Error('No signer found'); } const client = (0, agw_client_1.createAbstractClient)({ signer: signer.account, chain, transport: (0, wagmi_1.custom)(signer.transport), isPrivyCrossApp: true, publicTransport: config?._internal.transports[chain.id], customPaymasterHandler, }); return client; }, enabled: status !== 'pending', }); }; exports.useAbstractClient = useAbstractClient; //# sourceMappingURL=useAbstractClient.js.map