"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var __typeError = (msg) => { throw TypeError(msg); }; var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg); var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)); var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value); var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value); var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method); // src/actions/createSmartAccount.ts var _connectsdk4337 = require('@cometh/connect-sdk-4337'); var _wagmi = require('wagmi'); async function createSmartAccount(config) { const { bundlerUrl, paymasterUrl, apiKey, chain, rpcUrl, baseUrl, comethSignerConfig, safeContractConfig, smartAccountAddress } = config; const account = await _connectsdk4337.createSafeSmartAccount.call(void 0, { apiKey, chain, rpcUrl, baseUrl, smartAccountAddress, entryPoint: _connectsdk4337.ENTRYPOINT_ADDRESS_V07, comethSignerConfig, safeContractConfig }); let client; if (paymasterUrl) { const paymasterClient = await _connectsdk4337.createComethPaymasterClient.call(void 0, { transport: _wagmi.http.call(void 0, paymasterUrl), chain, entryPoint: _connectsdk4337.ENTRYPOINT_ADDRESS_V07, rpcUrl }); client = _connectsdk4337.createSmartAccountClient.call(void 0, { account, entryPoint: _connectsdk4337.ENTRYPOINT_ADDRESS_V07, chain, bundlerTransport: _wagmi.http.call(void 0, bundlerUrl), middleware: { sponsorUserOperation: paymasterClient.sponsorUserOperation, gasPrice: paymasterClient.gasPrice }, rpcUrl }); } else { client = _connectsdk4337.createSmartAccountClient.call(void 0, { account, entryPoint: _connectsdk4337.ENTRYPOINT_ADDRESS_V07, chain, bundlerTransport: _wagmi.http.call(void 0, bundlerUrl), rpcUrl }); } const address = client.account.address; return { client, address }; } // src/providers/ConnectProvider.tsx var _react = require('react'); var React2 = _interopRequireWildcard(_react); var React3 = _interopRequireWildcard(_react); var React4 = _interopRequireWildcard(_react); var React5 = _interopRequireWildcard(_react); var React6 = _interopRequireWildcard(_react); var React7 = _interopRequireWildcard(_react); var CHAIN_STORAGE_KEY = "currentChain"; var ConnectContext = _react.createContext.call(void 0, { queryClient: void 0, smartAccountClient: null, smartAccountAddress: void 0, updateSmartAccountClient: async () => { }, disconnectSmartAccount: async () => { }, networksConfig: void 0 }); var ConnectProvider = ({ children, config, queryClient }) => { const [smartAccountClient, setSmartAccountClient] = _react.useState.call(void 0, null); const [smartAccountAddress, setSmartAccountAddress] = _react.useState.call(void 0, void 0); const updateSmartAccountClient = _react.useCallback.call(void 0, async (params = {}) => { const chain = _nullishCoalesce(_nullishCoalesce(params.chain, () => ( JSON.parse(_nullishCoalesce(localStorage.getItem(CHAIN_STORAGE_KEY), () => ( "null"))))), () => ( config.networksConfig[0].chain)); const bundlerUrl = _optionalChain([config, 'access', _2 => _2.networksConfig, 'access', _3 => _3.find, 'call', _4 => _4( (network) => _optionalChain([network, 'access', _5 => _5.chain, 'optionalAccess', _6 => _6.id]) === chain.id ), 'optionalAccess', _7 => _7.bundlerUrl]); const paymasterUrl = _optionalChain([config, 'access', _8 => _8.networksConfig, 'access', _9 => _9.find, 'call', _10 => _10( (network) => _optionalChain([network, 'access', _11 => _11.chain, 'optionalAccess', _12 => _12.id]) === chain.id ), 'optionalAccess', _13 => _13.paymasterUrl]); const rpcUrl = _optionalChain([config, 'access', _14 => _14.networksConfig, 'access', _15 => _15.find, 'call', _16 => _16( (network) => _optionalChain([network, 'access', _17 => _17.chain, 'optionalAccess', _18 => _18.id]) === chain.id ), 'optionalAccess', _19 => _19.rpcUrl]); if (!bundlerUrl) throw new Error("Bundler url not found"); try { const { client, address: newAddress } = await createSmartAccount({ ...config, chain, bundlerUrl, paymasterUrl, rpcUrl, smartAccountAddress: params.address, comethSignerConfig: { ...config.comethSignerConfig, passKeyName: params.passKeyName } }); setSmartAccountClient(client); setSmartAccountAddress(newAddress); localStorage.setItem(CHAIN_STORAGE_KEY, JSON.stringify(chain)); } catch (e) { console.log(e); } }, [config] ); const disconnectSmartAccount = _react.useCallback.call(void 0, async () => { setSmartAccountClient(null); setSmartAccountAddress(void 0); localStorage.removeItem(CHAIN_STORAGE_KEY); }, []); _react.useEffect.call(void 0, () => { if (config.smartAccountAddress) { updateSmartAccountClient({ address: config.smartAccountAddress }); } }, [config.smartAccountAddress, updateSmartAccountClient]); const value = _react.useMemo.call(void 0, () => ({ queryClient, smartAccountClient, smartAccountAddress, updateSmartAccountClient, disconnectSmartAccount, networksConfig: config.networksConfig }), [ queryClient, smartAccountClient, smartAccountAddress, updateSmartAccountClient, disconnectSmartAccount, config.networksConfig ] ); return /* @__PURE__ */ React2.default.createElement(ConnectContext.Provider, { value }, children); }; // src/hooks/useAccount.ts var useAccount = () => { const context = _react.useContext.call(void 0, ConnectContext); if (context === void 0) { throw new Error("useAccount must be used within a ConnectProvider"); } const { smartAccountClient, smartAccountAddress } = context; const { chain, chainId } = _react.useMemo.call(void 0, () => ({ chain: _optionalChain([smartAccountClient, 'optionalAccess', _20 => _20.chain]), chainId: _optionalChain([smartAccountClient, 'optionalAccess', _21 => _21.chain, 'optionalAccess', _22 => _22.id]) }), [smartAccountClient] ); const isConnected = _react.useMemo.call(void 0, () => !!smartAccountClient && !!smartAccountAddress, [smartAccountClient, smartAccountAddress] ); const status = _react.useMemo.call(void 0, () => { return isConnected ? "connected" : "disconnected"; }, [isConnected]); return { address: smartAccountAddress, smartAccountClient, isConnected, isDisconnected: !isConnected, status, chain, chainId }; }; // src/hooks/useSmartAccount.ts var useSmartAccount = () => { const context = _react.useContext.call(void 0, ConnectContext); if (context === void 0) { throw new Error("Hooks must be used within a SmartAccountProvider"); } return context; }; // ../../node_modules/@tanstack/query-core/build/modern/subscribable.js var Subscribable = class { constructor() { this.listeners = /* @__PURE__ */ new Set(); this.subscribe = this.subscribe.bind(this); } subscribe(listener) { this.listeners.add(listener); this.onSubscribe(); return () => { this.listeners.delete(listener); this.onUnsubscribe(); }; } hasListeners() { return this.listeners.size > 0; } onSubscribe() { } onUnsubscribe() { } }; // ../../node_modules/@tanstack/query-core/build/modern/utils.js var isServer = typeof window === "undefined" || "Deno" in globalThis; function noop() { return void 0; } function isValidTimeout(value) { return typeof value === "number" && value >= 0 && value !== Infinity; } function timeUntilStale(updatedAt, staleTime) { return Math.max(updatedAt + (staleTime || 0) - Date.now(), 0); } function resolveStaleTime(staleTime, query) { return typeof staleTime === "function" ? staleTime(query) : staleTime; } function resolveEnabled(enabled, query) { return typeof enabled === "function" ? enabled(query) : enabled; } function hashKey(queryKey) { return JSON.stringify( queryKey, (_, val) => isPlainObject(val) ? Object.keys(val).sort().reduce((result, key) => { result[key] = val[key]; return result; }, {}) : val ); } function replaceEqualDeep(a, b) { if (a === b) { return a; } const array = isPlainArray(a) && isPlainArray(b); if (array || isPlainObject(a) && isPlainObject(b)) { const aItems = array ? a : Object.keys(a); const aSize = aItems.length; const bItems = array ? b : Object.keys(b); const bSize = bItems.length; const copy = array ? [] : {}; let equalItems = 0; for (let i = 0; i < bSize; i++) { const key = array ? i : bItems[i]; if ((!array && aItems.includes(key) || array) && a[key] === void 0 && b[key] === void 0) { copy[key] = void 0; equalItems++; } else { copy[key] = replaceEqualDeep(a[key], b[key]); if (copy[key] === a[key] && a[key] !== void 0) { equalItems++; } } } return aSize === bSize && equalItems === aSize ? a : copy; } return b; } function shallowEqualObjects(a, b) { if (!b || Object.keys(a).length !== Object.keys(b).length) { return false; } for (const key in a) { if (a[key] !== b[key]) { return false; } } return true; } function isPlainArray(value) { return Array.isArray(value) && value.length === Object.keys(value).length; } function isPlainObject(o) { if (!hasObjectPrototype(o)) { return false; } const ctor = o.constructor; if (ctor === void 0) { return true; } const prot = ctor.prototype; if (!hasObjectPrototype(prot)) { return false; } if (!prot.hasOwnProperty("isPrototypeOf")) { return false; } if (Object.getPrototypeOf(o) !== Object.prototype) { return false; } return true; } function hasObjectPrototype(o) { return Object.prototype.toString.call(o) === "[object Object]"; } function replaceData(prevData, data, options) { if (typeof options.structuralSharing === "function") { return options.structuralSharing(prevData, data); } else if (options.structuralSharing !== false) { return replaceEqualDeep(prevData, data); } return data; } var skipToken = Symbol(); // ../../node_modules/@tanstack/query-core/build/modern/focusManager.js var _focused, _cleanup, _setup, _a; var FocusManager = (_a = class extends Subscribable { constructor() { super(); __privateAdd(this, _focused); __privateAdd(this, _cleanup); __privateAdd(this, _setup); __privateSet(this, _setup, (onFocus) => { if (!isServer && window.addEventListener) { const listener = () => onFocus(); window.addEventListener("visibilitychange", listener, false); return () => { window.removeEventListener("visibilitychange", listener); }; } return; }); } onSubscribe() { if (!__privateGet(this, _cleanup)) { this.setEventListener(__privateGet(this, _setup)); } } onUnsubscribe() { var _a5; if (!this.hasListeners()) { (_a5 = __privateGet(this, _cleanup)) == null ? void 0 : _a5.call(this); __privateSet(this, _cleanup, void 0); } } setEventListener(setup) { var _a5; __privateSet(this, _setup, setup); (_a5 = __privateGet(this, _cleanup)) == null ? void 0 : _a5.call(this); __privateSet(this, _cleanup, setup((focused) => { if (typeof focused === "boolean") { this.setFocused(focused); } else { this.onFocus(); } })); } setFocused(focused) { const changed = __privateGet(this, _focused) !== focused; if (changed) { __privateSet(this, _focused, focused); this.onFocus(); } } onFocus() { const isFocused = this.isFocused(); this.listeners.forEach((listener) => { listener(isFocused); }); } isFocused() { if (typeof __privateGet(this, _focused) === "boolean") { return __privateGet(this, _focused); } return _optionalChain([globalThis, 'access', _23 => _23.document, 'optionalAccess', _24 => _24.visibilityState]) !== "hidden"; } }, _focused = new WeakMap(), _cleanup = new WeakMap(), _setup = new WeakMap(), _a); var focusManager = new FocusManager(); // ../../node_modules/@tanstack/query-core/build/modern/onlineManager.js var _online, _cleanup2, _setup2, _a2; var OnlineManager = (_a2 = class extends Subscribable { constructor() { super(); __privateAdd(this, _online, true); __privateAdd(this, _cleanup2); __privateAdd(this, _setup2); __privateSet(this, _setup2, (onOnline) => { if (!isServer && window.addEventListener) { const onlineListener = () => onOnline(true); const offlineListener = () => onOnline(false); window.addEventListener("online", onlineListener, false); window.addEventListener("offline", offlineListener, false); return () => { window.removeEventListener("online", onlineListener); window.removeEventListener("offline", offlineListener); }; } return; }); } onSubscribe() { if (!__privateGet(this, _cleanup2)) { this.setEventListener(__privateGet(this, _setup2)); } } onUnsubscribe() { var _a5; if (!this.hasListeners()) { (_a5 = __privateGet(this, _cleanup2)) == null ? void 0 : _a5.call(this); __privateSet(this, _cleanup2, void 0); } } setEventListener(setup) { var _a5; __privateSet(this, _setup2, setup); (_a5 = __privateGet(this, _cleanup2)) == null ? void 0 : _a5.call(this); __privateSet(this, _cleanup2, setup(this.setOnline.bind(this))); } setOnline(online) { const changed = __privateGet(this, _online) !== online; if (changed) { __privateSet(this, _online, online); this.listeners.forEach((listener) => { listener(online); }); } } isOnline() { return __privateGet(this, _online); } }, _online = new WeakMap(), _cleanup2 = new WeakMap(), _setup2 = new WeakMap(), _a2); var onlineManager = new OnlineManager(); // ../../node_modules/@tanstack/query-core/build/modern/retryer.js function canFetch(networkMode) { return (_nullishCoalesce(networkMode, () => ( "online"))) === "online" ? onlineManager.isOnline() : true; } // ../../node_modules/@tanstack/query-core/build/modern/notifyManager.js function createNotifyManager() { let queue = []; let transactions = 0; let notifyFn = (callback) => { callback(); }; let batchNotifyFn = (callback) => { callback(); }; let scheduleFn = (cb) => setTimeout(cb, 0); const setScheduler = (fn) => { scheduleFn = fn; }; const batch = (callback) => { let result; transactions++; try { result = callback(); } finally { transactions--; if (!transactions) { flush(); } } return result; }; const schedule = (callback) => { if (transactions) { queue.push(callback); } else { scheduleFn(() => { notifyFn(callback); }); } }; const batchCalls = (callback) => { return (...args) => { schedule(() => { callback(...args); }); }; }; const flush = () => { const originalQueue = queue; queue = []; if (originalQueue.length) { scheduleFn(() => { batchNotifyFn(() => { originalQueue.forEach((callback) => { notifyFn(callback); }); }); }); } }; const setNotifyFunction = (fn) => { notifyFn = fn; }; const setBatchNotifyFunction = (fn) => { batchNotifyFn = fn; }; return { batch, batchCalls, schedule, setNotifyFunction, setBatchNotifyFunction, setScheduler }; } var notifyManager = createNotifyManager(); // ../../node_modules/@tanstack/query-core/build/modern/query.js function fetchState(data, options) { return { fetchFailureCount: 0, fetchFailureReason: null, fetchStatus: canFetch(options.networkMode) ? "fetching" : "paused", ...data === void 0 && { error: null, status: "pending" } }; } // ../../node_modules/@tanstack/query-core/build/modern/mutation.js function getDefaultState() { return { context: void 0, data: void 0, error: null, failureCount: 0, failureReason: null, isPaused: false, status: "idle", variables: void 0, submittedAt: 0 }; } // ../../node_modules/@tanstack/query-core/build/modern/queryObserver.js var _client, _currentQuery, _currentQueryInitialState, _currentResult, _currentResultState, _currentResultOptions, _selectError, _selectFn, _selectResult, _lastQueryWithDefinedData, _staleTimeoutId, _refetchIntervalId, _currentRefetchInterval, _trackedProps, _QueryObserver_instances, executeFetch_fn, updateStaleTimeout_fn, computeRefetchInterval_fn, updateRefetchInterval_fn, updateTimers_fn, clearStaleTimeout_fn, clearRefetchInterval_fn, updateQuery_fn, notify_fn, _a3; var QueryObserver = (_a3 = class extends Subscribable { constructor(client, options) { super(); __privateAdd(this, _QueryObserver_instances); __privateAdd(this, _client); __privateAdd(this, _currentQuery); __privateAdd(this, _currentQueryInitialState); __privateAdd(this, _currentResult); __privateAdd(this, _currentResultState); __privateAdd(this, _currentResultOptions); __privateAdd(this, _selectError); __privateAdd(this, _selectFn); __privateAdd(this, _selectResult); // This property keeps track of the last query with defined data. // It will be used to pass the previous data and query to the placeholder function between renders. __privateAdd(this, _lastQueryWithDefinedData); __privateAdd(this, _staleTimeoutId); __privateAdd(this, _refetchIntervalId); __privateAdd(this, _currentRefetchInterval); __privateAdd(this, _trackedProps, /* @__PURE__ */ new Set()); this.options = options; __privateSet(this, _client, client); __privateSet(this, _selectError, null); this.bindMethods(); this.setOptions(options); } bindMethods() { this.refetch = this.refetch.bind(this); } onSubscribe() { if (this.listeners.size === 1) { __privateGet(this, _currentQuery).addObserver(this); if (shouldFetchOnMount(__privateGet(this, _currentQuery), this.options)) { __privateMethod(this, _QueryObserver_instances, executeFetch_fn).call(this); } else { this.updateResult(); } __privateMethod(this, _QueryObserver_instances, updateTimers_fn).call(this); } } onUnsubscribe() { if (!this.hasListeners()) { this.destroy(); } } shouldFetchOnReconnect() { return shouldFetchOn( __privateGet(this, _currentQuery), this.options, this.options.refetchOnReconnect ); } shouldFetchOnWindowFocus() { return shouldFetchOn( __privateGet(this, _currentQuery), this.options, this.options.refetchOnWindowFocus ); } destroy() { this.listeners = /* @__PURE__ */ new Set(); __privateMethod(this, _QueryObserver_instances, clearStaleTimeout_fn).call(this); __privateMethod(this, _QueryObserver_instances, clearRefetchInterval_fn).call(this); __privateGet(this, _currentQuery).removeObserver(this); } setOptions(options, notifyOptions) { const prevOptions = this.options; const prevQuery = __privateGet(this, _currentQuery); this.options = __privateGet(this, _client).defaultQueryOptions(options); if (this.options.enabled !== void 0 && typeof this.options.enabled !== "boolean" && typeof this.options.enabled !== "function" && typeof resolveEnabled(this.options.enabled, __privateGet(this, _currentQuery)) !== "boolean") { throw new Error( "Expected enabled to be a boolean or a callback that returns a boolean" ); } __privateMethod(this, _QueryObserver_instances, updateQuery_fn).call(this); __privateGet(this, _currentQuery).setOptions(this.options); if (prevOptions._defaulted && !shallowEqualObjects(this.options, prevOptions)) { __privateGet(this, _client).getQueryCache().notify({ type: "observerOptionsUpdated", query: __privateGet(this, _currentQuery), observer: this }); } const mounted = this.hasListeners(); if (mounted && shouldFetchOptionally( __privateGet(this, _currentQuery), prevQuery, this.options, prevOptions )) { __privateMethod(this, _QueryObserver_instances, executeFetch_fn).call(this); } this.updateResult(notifyOptions); if (mounted && (__privateGet(this, _currentQuery) !== prevQuery || resolveEnabled(this.options.enabled, __privateGet(this, _currentQuery)) !== resolveEnabled(prevOptions.enabled, __privateGet(this, _currentQuery)) || resolveStaleTime(this.options.staleTime, __privateGet(this, _currentQuery)) !== resolveStaleTime(prevOptions.staleTime, __privateGet(this, _currentQuery)))) { __privateMethod(this, _QueryObserver_instances, updateStaleTimeout_fn).call(this); } const nextRefetchInterval = __privateMethod(this, _QueryObserver_instances, computeRefetchInterval_fn).call(this); if (mounted && (__privateGet(this, _currentQuery) !== prevQuery || resolveEnabled(this.options.enabled, __privateGet(this, _currentQuery)) !== resolveEnabled(prevOptions.enabled, __privateGet(this, _currentQuery)) || nextRefetchInterval !== __privateGet(this, _currentRefetchInterval))) { __privateMethod(this, _QueryObserver_instances, updateRefetchInterval_fn).call(this, nextRefetchInterval); } } getOptimisticResult(options) { const query = __privateGet(this, _client).getQueryCache().build(__privateGet(this, _client), options); const result = this.createResult(query, options); if (shouldAssignObserverCurrentProperties(this, result)) { __privateSet(this, _currentResult, result); __privateSet(this, _currentResultOptions, this.options); __privateSet(this, _currentResultState, __privateGet(this, _currentQuery).state); } return result; } getCurrentResult() { return __privateGet(this, _currentResult); } trackResult(result, onPropTracked) { const trackedResult = {}; Object.keys(result).forEach((key) => { Object.defineProperty(trackedResult, key, { configurable: false, enumerable: true, get: () => { this.trackProp(key); _optionalChain([onPropTracked, 'optionalCall', _25 => _25(key)]); return result[key]; } }); }); return trackedResult; } trackProp(key) { __privateGet(this, _trackedProps).add(key); } getCurrentQuery() { return __privateGet(this, _currentQuery); } refetch({ ...options } = {}) { return this.fetch({ ...options }); } fetchOptimistic(options) { const defaultedOptions = __privateGet(this, _client).defaultQueryOptions(options); const query = __privateGet(this, _client).getQueryCache().build(__privateGet(this, _client), defaultedOptions); query.isFetchingOptimistic = true; return query.fetch().then(() => this.createResult(query, defaultedOptions)); } fetch(fetchOptions) { return __privateMethod(this, _QueryObserver_instances, executeFetch_fn).call(this, { ...fetchOptions, cancelRefetch: _nullishCoalesce(fetchOptions.cancelRefetch, () => ( true)) }).then(() => { this.updateResult(); return __privateGet(this, _currentResult); }); } createResult(query, options) { const prevQuery = __privateGet(this, _currentQuery); const prevOptions = this.options; const prevResult = __privateGet(this, _currentResult); const prevResultState = __privateGet(this, _currentResultState); const prevResultOptions = __privateGet(this, _currentResultOptions); const queryChange = query !== prevQuery; const queryInitialState = queryChange ? query.state : __privateGet(this, _currentQueryInitialState); const { state } = query; let newState = { ...state }; let isPlaceholderData = false; let data; if (options._optimisticResults) { const mounted = this.hasListeners(); const fetchOnMount = !mounted && shouldFetchOnMount(query, options); const fetchOptionally = mounted && shouldFetchOptionally(query, prevQuery, options, prevOptions); if (fetchOnMount || fetchOptionally) { newState = { ...newState, ...fetchState(state.data, query.options) }; } if (options._optimisticResults === "isRestoring") { newState.fetchStatus = "idle"; } } let { error, errorUpdatedAt, status } = newState; if (options.select && newState.data !== void 0) { if (prevResult && newState.data === _optionalChain([prevResultState, 'optionalAccess', _26 => _26.data]) && options.select === __privateGet(this, _selectFn)) { data = __privateGet(this, _selectResult); } else { try { __privateSet(this, _selectFn, options.select); data = options.select(newState.data); data = replaceData(_optionalChain([prevResult, 'optionalAccess', _27 => _27.data]), data, options); __privateSet(this, _selectResult, data); __privateSet(this, _selectError, null); } catch (selectError) { __privateSet(this, _selectError, selectError); } } } else { data = newState.data; } if (options.placeholderData !== void 0 && data === void 0 && status === "pending") { let placeholderData; if (_optionalChain([prevResult, 'optionalAccess', _28 => _28.isPlaceholderData]) && options.placeholderData === _optionalChain([prevResultOptions, 'optionalAccess', _29 => _29.placeholderData])) { placeholderData = prevResult.data; } else { placeholderData = typeof options.placeholderData === "function" ? options.placeholderData( _optionalChain([__privateGet, 'call', _30 => _30(this, _lastQueryWithDefinedData), 'optionalAccess', _31 => _31.state, 'access', _32 => _32.data]), __privateGet(this, _lastQueryWithDefinedData) ) : options.placeholderData; if (options.select && placeholderData !== void 0) { try { placeholderData = options.select(placeholderData); __privateSet(this, _selectError, null); } catch (selectError) { __privateSet(this, _selectError, selectError); } } } if (placeholderData !== void 0) { status = "success"; data = replaceData( _optionalChain([prevResult, 'optionalAccess', _33 => _33.data]), placeholderData, options ); isPlaceholderData = true; } } if (__privateGet(this, _selectError)) { error = __privateGet(this, _selectError); data = __privateGet(this, _selectResult); errorUpdatedAt = Date.now(); status = "error"; } const isFetching = newState.fetchStatus === "fetching"; const isPending = status === "pending"; const isError = status === "error"; const isLoading = isPending && isFetching; const hasData = data !== void 0; const result = { status, fetchStatus: newState.fetchStatus, isPending, isSuccess: status === "success", isError, isInitialLoading: isLoading, isLoading, data, dataUpdatedAt: newState.dataUpdatedAt, error, errorUpdatedAt, failureCount: newState.fetchFailureCount, failureReason: newState.fetchFailureReason, errorUpdateCount: newState.errorUpdateCount, isFetched: newState.dataUpdateCount > 0 || newState.errorUpdateCount > 0, isFetchedAfterMount: newState.dataUpdateCount > queryInitialState.dataUpdateCount || newState.errorUpdateCount > queryInitialState.errorUpdateCount, isFetching, isRefetching: isFetching && !isPending, isLoadingError: isError && !hasData, isPaused: newState.fetchStatus === "paused", isPlaceholderData, isRefetchError: isError && hasData, isStale: isStale(query, options), refetch: this.refetch }; return result; } updateResult(notifyOptions) { const prevResult = __privateGet(this, _currentResult); const nextResult = this.createResult(__privateGet(this, _currentQuery), this.options); __privateSet(this, _currentResultState, __privateGet(this, _currentQuery).state); __privateSet(this, _currentResultOptions, this.options); if (__privateGet(this, _currentResultState).data !== void 0) { __privateSet(this, _lastQueryWithDefinedData, __privateGet(this, _currentQuery)); } if (shallowEqualObjects(nextResult, prevResult)) { return; } __privateSet(this, _currentResult, nextResult); const defaultNotifyOptions = {}; const shouldNotifyListeners = () => { if (!prevResult) { return true; } const { notifyOnChangeProps } = this.options; const notifyOnChangePropsValue = typeof notifyOnChangeProps === "function" ? notifyOnChangeProps() : notifyOnChangeProps; if (notifyOnChangePropsValue === "all" || !notifyOnChangePropsValue && !__privateGet(this, _trackedProps).size) { return true; } const includedProps = new Set( _nullishCoalesce(notifyOnChangePropsValue, () => ( __privateGet(this, _trackedProps))) ); if (this.options.throwOnError) { includedProps.add("error"); } return Object.keys(__privateGet(this, _currentResult)).some((key) => { const typedKey = key; const changed = __privateGet(this, _currentResult)[typedKey] !== prevResult[typedKey]; return changed && includedProps.has(typedKey); }); }; if (_optionalChain([notifyOptions, 'optionalAccess', _34 => _34.listeners]) !== false && shouldNotifyListeners()) { defaultNotifyOptions.listeners = true; } __privateMethod(this, _QueryObserver_instances, notify_fn).call(this, { ...defaultNotifyOptions, ...notifyOptions }); } onQueryUpdate() { this.updateResult(); if (this.hasListeners()) { __privateMethod(this, _QueryObserver_instances, updateTimers_fn).call(this); } } }, _client = new WeakMap(), _currentQuery = new WeakMap(), _currentQueryInitialState = new WeakMap(), _currentResult = new WeakMap(), _currentResultState = new WeakMap(), _currentResultOptions = new WeakMap(), _selectError = new WeakMap(), _selectFn = new WeakMap(), _selectResult = new WeakMap(), _lastQueryWithDefinedData = new WeakMap(), _staleTimeoutId = new WeakMap(), _refetchIntervalId = new WeakMap(), _currentRefetchInterval = new WeakMap(), _trackedProps = new WeakMap(), _QueryObserver_instances = new WeakSet(), executeFetch_fn = function(fetchOptions) { __privateMethod(this, _QueryObserver_instances, updateQuery_fn).call(this); let promise = __privateGet(this, _currentQuery).fetch( this.options, fetchOptions ); if (!_optionalChain([fetchOptions, 'optionalAccess', _35 => _35.throwOnError])) { promise = promise.catch(noop); } return promise; }, updateStaleTimeout_fn = function() { __privateMethod(this, _QueryObserver_instances, clearStaleTimeout_fn).call(this); const staleTime = resolveStaleTime( this.options.staleTime, __privateGet(this, _currentQuery) ); if (isServer || __privateGet(this, _currentResult).isStale || !isValidTimeout(staleTime)) { return; } const time = timeUntilStale(__privateGet(this, _currentResult).dataUpdatedAt, staleTime); const timeout = time + 1; __privateSet(this, _staleTimeoutId, setTimeout(() => { if (!__privateGet(this, _currentResult).isStale) { this.updateResult(); } }, timeout)); }, computeRefetchInterval_fn = function() { return _nullishCoalesce((typeof this.options.refetchInterval === "function" ? this.options.refetchInterval(__privateGet(this, _currentQuery)) : this.options.refetchInterval), () => ( false)); }, updateRefetchInterval_fn = function(nextInterval) { __privateMethod(this, _QueryObserver_instances, clearRefetchInterval_fn).call(this); __privateSet(this, _currentRefetchInterval, nextInterval); if (isServer || resolveEnabled(this.options.enabled, __privateGet(this, _currentQuery)) === false || !isValidTimeout(__privateGet(this, _currentRefetchInterval)) || __privateGet(this, _currentRefetchInterval) === 0) { return; } __privateSet(this, _refetchIntervalId, setInterval(() => { if (this.options.refetchIntervalInBackground || focusManager.isFocused()) { __privateMethod(this, _QueryObserver_instances, executeFetch_fn).call(this); } }, __privateGet(this, _currentRefetchInterval))); }, updateTimers_fn = function() { __privateMethod(this, _QueryObserver_instances, updateStaleTimeout_fn).call(this); __privateMethod(this, _QueryObserver_instances, updateRefetchInterval_fn).call(this, __privateMethod(this, _QueryObserver_instances, computeRefetchInterval_fn).call(this)); }, clearStaleTimeout_fn = function() { if (__privateGet(this, _staleTimeoutId)) { clearTimeout(__privateGet(this, _staleTimeoutId)); __privateSet(this, _staleTimeoutId, void 0); } }, clearRefetchInterval_fn = function() { if (__privateGet(this, _refetchIntervalId)) { clearInterval(__privateGet(this, _refetchIntervalId)); __privateSet(this, _refetchIntervalId, void 0); } }, updateQuery_fn = function() { const query = __privateGet(this, _client).getQueryCache().build(__privateGet(this, _client), this.options); if (query === __privateGet(this, _currentQuery)) { return; } const prevQuery = __privateGet(this, _currentQuery); __privateSet(this, _currentQuery, query); __privateSet(this, _currentQueryInitialState, query.state); if (this.hasListeners()) { _optionalChain([prevQuery, 'optionalAccess', _36 => _36.removeObserver, 'call', _37 => _37(this)]); query.addObserver(this); } }, notify_fn = function(notifyOptions) { notifyManager.batch(() => { if (notifyOptions.listeners) { this.listeners.forEach((listener) => { listener(__privateGet(this, _currentResult)); }); } __privateGet(this, _client).getQueryCache().notify({ query: __privateGet(this, _currentQuery), type: "observerResultsUpdated" }); }); }, _a3); function shouldLoadOnMount(query, options) { return resolveEnabled(options.enabled, query) !== false && query.state.data === void 0 && !(query.state.status === "error" && options.retryOnMount === false); } function shouldFetchOnMount(query, options) { return shouldLoadOnMount(query, options) || query.state.data !== void 0 && shouldFetchOn(query, options, options.refetchOnMount); } function shouldFetchOn(query, options, field) { if (resolveEnabled(options.enabled, query) !== false) { const value = typeof field === "function" ? field(query) : field; return value === "always" || value !== false && isStale(query, options); } return false; } function shouldFetchOptionally(query, prevQuery, options, prevOptions) { return (query !== prevQuery || resolveEnabled(prevOptions.enabled, query) === false) && (!options.suspense || query.state.status !== "error") && isStale(query, options); } function isStale(query, options) { return resolveEnabled(options.enabled, query) !== false && query.isStaleByTime(resolveStaleTime(options.staleTime, query)); } function shouldAssignObserverCurrentProperties(observer, optimisticResult) { if (!shallowEqualObjects(observer.getCurrentResult(), optimisticResult)) { return true; } return false; } // ../../node_modules/@tanstack/query-core/build/modern/mutationObserver.js var _client2, _currentResult2, _currentMutation, _mutateOptions, _MutationObserver_instances, updateResult_fn, notify_fn2, _a4; var MutationObserver = (_a4 = class extends Subscribable { constructor(client, options) { super(); __privateAdd(this, _MutationObserver_instances); __privateAdd(this, _client2); __privateAdd(this, _currentResult2); __privateAdd(this, _currentMutation); __privateAdd(this, _mutateOptions); __privateSet(this, _client2, client); this.setOptions(options); this.bindMethods(); __privateMethod(this, _MutationObserver_instances, updateResult_fn).call(this); } bindMethods() { this.mutate = this.mutate.bind(this); this.reset = this.reset.bind(this); } setOptions(options) { const prevOptions = this.options; this.options = __privateGet(this, _client2).defaultMutationOptions(options); if (!shallowEqualObjects(this.options, prevOptions)) { __privateGet(this, _client2).getMutationCache().notify({ type: "observerOptionsUpdated", mutation: __privateGet(this, _currentMutation), observer: this }); } if (_optionalChain([prevOptions, 'optionalAccess', _38 => _38.mutationKey]) && this.options.mutationKey && hashKey(prevOptions.mutationKey) !== hashKey(this.options.mutationKey)) { this.reset(); } else if (_optionalChain([__privateGet, 'call', _39 => _39(this, _currentMutation), 'optionalAccess', _40 => _40.state, 'access', _41 => _41.status]) === "pending") { __privateGet(this, _currentMutation).setOptions(this.options); } } onUnsubscribe() { if (!this.hasListeners()) { _optionalChain([__privateGet, 'call', _42 => _42(this, _currentMutation), 'optionalAccess', _43 => _43.removeObserver, 'call', _44 => _44(this)]); } } onMutationUpdate(action) { __privateMethod(this, _MutationObserver_instances, updateResult_fn).call(this); __privateMethod(this, _MutationObserver_instances, notify_fn2).call(this, action); } getCurrentResult() { return __privateGet(this, _currentResult2); } reset() { _optionalChain([__privateGet, 'call', _45 => _45(this, _currentMutation), 'optionalAccess', _46 => _46.removeObserver, 'call', _47 => _47(this)]); __privateSet(this, _currentMutation, void 0); __privateMethod(this, _MutationObserver_instances, updateResult_fn).call(this); __privateMethod(this, _MutationObserver_instances, notify_fn2).call(this); } mutate(variables, options) { __privateSet(this, _mutateOptions, options); _optionalChain([__privateGet, 'call', _48 => _48(this, _currentMutation), 'optionalAccess', _49 => _49.removeObserver, 'call', _50 => _50(this)]); __privateSet(this, _currentMutation, __privateGet(this, _client2).getMutationCache().build(__privateGet(this, _client2), this.options)); __privateGet(this, _currentMutation).addObserver(this); return __privateGet(this, _currentMutation).execute(variables); } }, _client2 = new WeakMap(), _currentResult2 = new WeakMap(), _currentMutation = new WeakMap(), _mutateOptions = new WeakMap(), _MutationObserver_instances = new WeakSet(), updateResult_fn = function() { const state = _nullishCoalesce(_optionalChain([__privateGet, 'call', _51 => _51(this, _currentMutation), 'optionalAccess', _52 => _52.state]), () => ( getDefaultState())); __privateSet(this, _currentResult2, { ...state, isPending: state.status === "pending", isSuccess: state.status === "success", isError: state.status === "error", isIdle: state.status === "idle", mutate: this.mutate, reset: this.reset }); }, notify_fn2 = function(action) { notifyManager.batch(() => { if (__privateGet(this, _mutateOptions) && this.hasListeners()) { const variables = __privateGet(this, _currentResult2).variables; const context = __privateGet(this, _currentResult2).context; if (_optionalChain([action, 'optionalAccess', _53 => _53.type]) === "success") { _optionalChain([__privateGet, 'call', _54 => _54(this, _mutateOptions), 'access', _55 => _55.onSuccess, 'optionalCall', _56 => _56(action.data, variables, context)]); _optionalChain([__privateGet, 'call', _57 => _57(this, _mutateOptions), 'access', _58 => _58.onSettled, 'optionalCall', _59 => _59(action.data, null, variables, context)]); } else if (_optionalChain([action, 'optionalAccess', _60 => _60.type]) === "error") { _optionalChain([__privateGet, 'call', _61 => _61(this, _mutateOptions), 'access', _62 => _62.onError, 'optionalCall', _63 => _63(action.error, variables, context)]); _optionalChain([__privateGet, 'call', _64 => _64(this, _mutateOptions), 'access', _65 => _65.onSettled, 'optionalCall', _66 => _66( void 0, action.error, variables, context )]); } } this.listeners.forEach((listener) => { listener(__privateGet(this, _currentResult2)); }); }); }, _a4); // ../../node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js var _jsxruntime = require('react/jsx-runtime'); var QueryClientContext = React2.createContext( void 0 ); var useQueryClient = (queryClient) => { const client = React2.useContext(QueryClientContext); if (queryClient) { return queryClient; } if (!client) { throw new Error("No QueryClient set, use QueryClientProvider to set one"); } return client; }; // ../../node_modules/@tanstack/react-query/build/modern/isRestoring.js var IsRestoringContext = React3.createContext(false); var useIsRestoring = () => React3.useContext(IsRestoringContext); var IsRestoringProvider = IsRestoringContext.Provider; // ../../node_modules/@tanstack/react-query/build/modern/QueryErrorResetBoundary.js function createValue() { let isReset = false; return { clearReset: () => { isReset = false; }, reset: () => { isReset = true; }, isReset: () => { return isReset; } }; } var QueryErrorResetBoundaryContext = React4.createContext(createValue()); var useQueryErrorResetBoundary = () => React4.useContext(QueryErrorResetBoundaryContext); // ../../node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js // ../../node_modules/@tanstack/react-query/build/modern/utils.js function shouldThrowError(throwError, params) { if (typeof throwError === "function") { return throwError(...params); } return !!throwError; } function noop2() { } // ../../node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js var ensurePreventErrorBoundaryRetry = (options, errorResetBoundary) => { if (options.suspense || options.throwOnError) { if (!errorResetBoundary.isReset()) { options.retryOnMount = false; } } }; var useClearResetErrorBoundary = (errorResetBoundary) => { React5.useEffect(() => { errorResetBoundary.clearReset(); }, [errorResetBoundary]); }; var getHasError = ({ result, errorResetBoundary, throwOnError, query }) => { return result.isError && !errorResetBoundary.isReset() && !result.isFetching && query && shouldThrowError(throwOnError, [result.error, query]); }; // ../../node_modules/@tanstack/react-query/build/modern/suspense.js var ensureStaleTime = (defaultedOptions) => { if (defaultedOptions.suspense) { if (typeof defaultedOptions.staleTime !== "number") { defaultedOptions.staleTime = 1e3; } } }; var shouldSuspend = (defaultedOptions, result) => _optionalChain([defaultedOptions, 'optionalAccess', _67 => _67.suspense]) && result.isPending; var fetchOptimistic = (defaultedOptions, observer, errorResetBoundary) => observer.fetchOptimistic(defaultedOptions).catch(() => { errorResetBoundary.clearReset(); }); // ../../node_modules/@tanstack/react-query/build/modern/useBaseQuery.js function useBaseQuery(options, Observer, queryClient) { if (process.env.NODE_ENV !== "production") { if (typeof options !== "object" || Array.isArray(options)) { throw new Error( 'Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object' ); } } const client = useQueryClient(queryClient); const isRestoring = useIsRestoring(); const errorResetBoundary = useQueryErrorResetBoundary(); const defaultedOptions = client.defaultQueryOptions(options); _optionalChain([client, 'access', _68 => _68.getDefaultOptions, 'call', _69 => _69(), 'access', _70 => _70.queries, 'optionalAccess', _71 => _71._experimental_beforeQuery, 'optionalCall', _72 => _72( defaultedOptions )]); defaultedOptions._optimisticResults = isRestoring ? "isRestoring" : "optimistic"; ensureStaleTime(defaultedOptions); ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary); useClearResetErrorBoundary(errorResetBoundary); const [observer] = React6.useState( () => new Observer( client, defaultedOptions ) ); const result = observer.getOptimisticResult(defaultedOptions); React6.useSyncExternalStore( React6.useCallback( (onStoreChange) => { const unsubscribe = isRestoring ? () => void 0 : observer.subscribe(notifyManager.batchCalls(onStoreChange)); observer.updateResult(); return unsubscribe; }, [observer, isRestoring] ), () => observer.getCurrentResult(), () => observer.getCurrentResult() ); React6.useEffect(() => { observer.setOptions(defaultedOptions, { listeners: false }); }, [defaultedOptions, observer]); if (shouldSuspend(defaultedOptions, result)) { throw fetchOptimistic(defaultedOptions, observer, errorResetBoundary); } if (getHasError({ result, errorResetBoundary, throwOnError: defaultedOptions.throwOnError, query: client.getQueryCache().get(defaultedOptions.queryHash) })) { throw result.error; } ; _optionalChain([client, 'access', _73 => _73.getDefaultOptions, 'call', _74 => _74(), 'access', _75 => _75.queries, 'optionalAccess', _76 => _76._experimental_afterQuery, 'optionalCall', _77 => _77( defaultedOptions, result )]); return !defaultedOptions.notifyOnChangeProps ? observer.trackResult(result) : result; } // ../../node_modules/@tanstack/react-query/build/modern/useQuery.js function useQuery(options, queryClient) { return useBaseQuery(options, QueryObserver, queryClient); } // ../../node_modules/@tanstack/react-query/build/modern/useMutation.js function useMutation(options, queryClient) { const client = useQueryClient(queryClient); const [observer] = React7.useState( () => new MutationObserver( client, options ) ); React7.useEffect(() => { observer.setOptions(options); }, [observer, options]); const result = React7.useSyncExternalStore( React7.useCallback( (onStoreChange) => observer.subscribe(notifyManager.batchCalls(onStoreChange)), [observer] ), () => observer.getCurrentResult(), () => observer.getCurrentResult() ); const mutate = React7.useCallback( (variables, mutateOptions) => { observer.mutate(variables, mutateOptions).catch(noop2); }, [observer] ); if (result.error && shouldThrowError(observer.options.throwOnError, [result.error])) { throw result.error; } return { ...result, mutate, mutateAsync: result.mutate }; } // src/hooks/useSendTransaction.ts var useSendTransaction = (mutationProps) => { const { smartAccountClient, queryClient } = useSmartAccount(); const { mutate, mutateAsync, ...result } = useMutation( { // Define the mutation function mutationFn: (variables) => { if (!smartAccountClient) { throw new Error("No smart account found"); } const { transactions } = variables; if (!Array.isArray(transactions)) { return smartAccountClient.sendTransaction(transactions); } return smartAccountClient.sendTransactions({ transactions }); }, // Spread any additional mutation options provided ...mutationProps }, queryClient ); return { data: result.data, error: result.error, isPending: result.isPending, isSuccess: result.isSuccess, isError: result.isError, sendTransaction: mutate, sendTransactionAsync: mutateAsync }; }; // src/hooks/useWriteContract.ts var _viem = require('viem'); var useWriteContract = (mutationProps) => { const { smartAccountClient, queryClient } = useSmartAccount(); const { mutate, mutateAsync, ...result } = useMutation( { mutationFn: async (variables) => { if (!smartAccountClient) { throw new Error("No smart account found"); } const { abi, address, functionName, args, value } = variables; const data = _viem.encodeFunctionData.call(void 0, { abi, functionName, args }); const hash = await smartAccountClient.sendTransaction({ to: address, data, value }); return hash; }, ...mutationProps }, queryClient ); return { data: result.data, error: result.error, isPending: result.isPending, isSuccess: result.isSuccess, isError: result.isError, writeContract: mutate, writeContractAsync: mutateAsync }; }; // src/hooks/sessionKeys/useSendTransactionWithSessionKey.ts var useSendTransactionWithSessionKey = (mutationProps) => { const { smartAccountClient, queryClient } = useSmartAccount(); const { mutate, mutateAsync, ...result } = useMutation( { mutationFn: (variables) => { if (!smartAccountClient) { throw new Error("No smart account found"); } const { transactions } = variables; if (!Array.isArray(transactions)) { return smartAccountClient.sendTransactionWithSessionKey( transactions ); } return smartAccountClient.sendTransactionsWithSessionKey({ transactions }); }, ...mutationProps }, queryClient ); return { data: result.data, error: result.error, isPending: result.isPending, isSuccess: result.isSuccess, isError: result.isError, sendTransaction: mutate, sendTransactionAsync: mutateAsync }; }; // src/hooks/sessionKeys/useWriteContractWithSessionKey.ts var useWriteContractWithSessionKey = (mutationProps) => { const { smartAccountClient, queryClient } = useSmartAccount(); const { mutate, mutateAsync, ...result } = useMutation( { mutationFn: async (variables) => { if (!smartAccountClient) { throw new Error("No smart account found"); } const { abi, address, functionName, args, value } = variables; const data = _viem.encodeFunctionData.call(void 0, { abi, functionName, args }); const hash = await smartAccountClient.sendTransactionWithSessionKey({ to: address, data, value }); return hash; }, ...mutationProps }, queryClient ); return { data: result.data, error: result.error, isPending: result.isPending, isSuccess: result.isSuccess, isError: result.isError, writeContractWithSessionKey: mutate, writeContractWithSessionKeyAsync: mutateAsync }; }; // src/hooks/useConnect.ts var useConnect = () => { const context = _react.useContext.call(void 0, ConnectContext); if (context === void 0) { throw new Error("useConnect must be used within a ConnectProvider"); } const { queryClient, updateSmartAccountClient } = context; const [isPending, setIsPending] = _react.useState.call(void 0, false); const [error, setError] = _react.useState.call(void 0, null); const connect = _react.useCallback.call(void 0, (params = {}) => { setIsPending(true); setError(null); updateSmartAccountClient(params).then(() => { _optionalChain([queryClient, 'optionalAccess', _78 => _78.invalidateQueries, 'call', _79 => _79({ queryKey: ["connect"] })]); }).catch((e) => { const err = e instanceof Error ? e : new Error("An error occurred"); setError(err); }).finally(() => { setIsPending(false); }); }, [updateSmartAccountClient, queryClient] ); const connectAsync = _react.useCallback.call(void 0, async (params = {}) => { setIsPending(true); setError(null); try { await updateSmartAccountClient(params); _optionalChain([queryClient, 'optionalAccess', _80 => _80.invalidateQueries, 'call', _81 => _81({ queryKey: ["connect"] })]); } catch (e) { const err = e instanceof Error ? e : new Error("An error occurred"); setError(err); throw err; } finally { setIsPending(false); } }, [updateSmartAccountClient, queryClient] ); return { connect, connectAsync, isPending, error }; }; // src/hooks/useDisconnect.ts var useDisconnect = () => { const context = _react.useContext.call(void 0, ConnectContext); if (context === void 0) { throw new Error("useDisconnect must be used within a ConnectProvider"); } const { queryClient, disconnectSmartAccount } = context; const [isPending, setIsPending] = _react.useState.call(void 0, false); const [error, setError] = _react.useState.call(void 0, null); const disconnect = _react.useCallback.call(void 0, () => { setIsPending(true); setError(null); disconnectSmartAccount().then(() => { _optionalChain([queryClient, 'optionalAccess', _82 => _82.invalidateQueries, 'call', _83 => _83({ queryKey: ["connect"] })]); }).catch((e) => { const err = e instanceof Error ? e : new Error("An error occurred during disconnection"); setError(err); }).finally(() => { setIsPending(false); }); }, [disconnectSmartAccount, queryClient]); const disconnectAsync = _react.useCallback.call(void 0, async () => { setIsPending(true); setError(null); try { await disconnectSmartAccount(); _optionalChain([queryClient, 'optionalAccess', _84 => _84.invalidateQueries, 'call', _85 => _85({ queryKey: ["connect"] })]); } catch (e) { const err = e instanceof Error ? e : new Error("An error occurred during disconnection"); setError(err); throw err; } finally { setIsPending(false); } }, [disconnectSmartAccount, queryClient]); return { disconnect, disconnectAsync, isPending, error }; }; // src/hooks/owners/useOwners.ts var useAddOwner = (mutationProps) => { const { smartAccountClient, queryClient } = useSmartAccount(); const { mutate, mutateAsync, ...result } = useMutation( { mutationFn: async ({ ownerToAdd }) => { if (!smartAccountClient) { throw new Error("No smart account found"); } return await smartAccountClient.addOwner({ ownerToAdd }); }, ...mutationProps }, queryClient ); return { data: result.data, error: result.error, isPending: result.isPending, isSuccess: result.isSuccess, isError: result.isError, addOwner: mutate, addOwnerAsync: mutateAsync }; }; var useRemoveOwner = (mutationProps) => { const { smartAccountClient, queryClient } = useSmartAccount(); const { mutate, mutateAsync, ...result } = useMutation( { mutationFn: async ({ ownerToRemove }) => { if (!smartAccountClient) { throw new Error("No smart account found"); } return await smartAccountClient.removeOwner({ ownerToRemove }); }, ...mutationProps }, queryClient ); return { data: result.data, error: result.error, isPending: result.isPending, isSuccess: result.isSuccess, isError: result.isError, removeOwner: mutate, removeOwnerAsync: mutateAsync }; }; var useGetOwners = (queryProps) => { const { smartAccountClient, queryClient } = useSmartAccount(); return useQuery( { queryKey: ["getOwners"], queryFn: async () => { if (!smartAccountClient) { throw new Error("No smart account found"); } return await smartAccountClient.getOwners(); }, ...queryProps }, queryClient ); }; var useGetEnrichedOwners = (queryProps) => { const { smartAccountClient, queryClient } = useSmartAccount(); return useQuery( { queryKey: ["getEnrichedOwners"], queryFn: async () => { if (!smartAccountClient) { throw new Error("No smart account found"); } return await smartAccountClient.getEnrichedOwners(); }, ...queryProps }, queryClient ); }; // src/hooks/sessionKeys/useSessionKeys.ts var useAddSessionKey = (mutationProps) => { const { smartAccountClient, queryClient } = useSmartAccount(); const { mutate, mutateAsync, ...result } = useMutation( { mutationFn: async (params) => { if (!smartAccountClient) { throw new Error("No smart account found"); } return await smartAccountClient.addSessionKey(params); }, ...mutationProps }, queryClient ); return { data: result.data, error: result.error, isPending: result.isPending, isSuccess: result.isSuccess, isError: result.isError, addSessionKey: mutate, addSessionKeyAsync: mutateAsync }; }; var useRevokeSessionKey = (mutationProps) => { const { smartAccountClient, queryClient } = useSmartAccount(); const { mutate, mutateAsync, ...result } = useMutation( { mutationFn: async ({ sessionKey }) => { if (!smartAccountClient) { throw new Error("No smart account found"); } return await smartAccountClient.revokeSessionKey({ sessionKey }); }, ...mutationProps }, queryClient ); return { data: result.data, error: result.error, isPending: result.isPending, isSuccess: result.isSuccess, isError: result.isError, revokeSessionKey: mutate, revokeSessionKeyAsync: mutateAsync }; }; var useAddWhitelistDestination = (mutationProps) => { const { smartAccountClient, queryClient } = useSmartAccount(); const { mutate, mutateAsync, ...result } = useMutation( { mutationFn: async ({ sessionKey, destination }) => { if (!smartAccountClient) { throw new Error("No smart account found"); } return await smartAccountClient.addWhitelistDestination({ sessionKey, destination }); }, ...mutationProps }, queryClient ); return { data: result.data, error: result.error, isPending: result.isPending, isSuccess: result.isSuccess, isError: result.isError, addWhitelistDestination: mutate, addWhitelistDestinationAsync: mutateAsync }; }; var useRemoveWhitelistDestination = (mutationProps) => { const { smartAccountClient, queryClient } = useSmartAccount(); const { mutate, mutateAsync, ...result } = useMutation( { mutationFn: async ({ sessionKey, destination }) => { if (!smartAccountClient) { throw new Error("No smart account found"); } return await smartAccountClient.removeWhitelistDestination({ sessionKey, destination }); }, ...mutationProps }, queryClient ); return { data: result.data, error: result.error, isPending: result.isPending, isSuccess: result.isSuccess, isError: result.isError, removeWhitelistDestination: mutate, removeWhitelistDestinationAsync: mutateAsync }; }; var useGetSessionFromAddress = (sessionKey, queryProps) => { const { smartAccountClient, queryClient } = useSmartAccount(); return useQuery( { queryKey: ["getSessionFromAddress", sessionKey], queryFn: async () => { if (!smartAccountClient) { throw new Error("No smart account found"); } return await smartAccountClient.getSessionFromAddress({ sessionKey }); }, ...queryProps }, queryClient ); }; var useIsAddressWhitelistDestination = (sessionKey, targetAddress, queryProps) => { const { smartAccountClient, queryClient } = useSmartAccount(); return useQuery( { queryKey: [ "isAddressWhitelistDestination", sessionKey, targetAddress ], queryFn: async () => { if (!smartAccountClient) { throw new Error("No smart account found"); } return await smartAccountClient.isAddressWhitelistDestination({ sessionKey, targetAddress }); }, ...queryProps }, queryClient ); }; // src/hooks/owners/useValidateAddDevice.ts var useValidateAddDevice = (mutationProps) => { const { smartAccountClient, queryClient } = useSmartAccount(); const { mutate, mutateAsync, ...result } = useMutation( { mutationFn: (variables) => { if (!smartAccountClient) { throw new Error("No smart account found"); } const { signer } = variables; return smartAccountClient.validateAddDevice({ signer }); }, ...mutationProps }, queryClient ); return { data: result.data, error: result.error, isPending: result.isPending, isSuccess: result.isSuccess, isError: result.isError, validateAddDevice: mutate, validateAddDeviceAsync: mutateAsync }; }; // src/hooks/useVerifyMessage.ts var useVerifyMessage = (mutationProps) => { const { smartAccountClient, queryClient } = useSmartAccount(); const { mutate, mutateAsync, ...result } = useMutation( { mutationFn: async (variables) => { if (!smartAccountClient) { throw new Error("No smart account found"); } const { message, signature } = variables; return smartAccountClient.verifySignature({ message, signature }); }, ...mutationProps }, queryClient ); return { data: result.data, error: result.error, isPending: result.isPending, isSuccess: result.isSuccess, isError: result.isError, verifyMessage: mutate, verifyMessageAsync: mutateAsync }; }; // src/hooks/useGetGasPrice.ts var useGetGasPrice = (rpcUrl, queryProps) => { const { smartAccountClient, queryClient } = useSmartAccount(); return useQuery( { queryKey: ["gasPrice", rpcUrl], queryFn: async () => { if (!smartAccountClient) { throw new Error("No smart account found"); } const publicClient = _viem.createPublicClient.call(void 0, { chain: smartAccountClient.chain, transport: _viem.http.call(void 0, rpcUrl) }); const { maxFeePerGas } = await publicClient.estimateFeesPerGas(); return { maxFeePerGas: maxFeePerGas * 2n, maxPriorityFeePerGas: maxFeePerGas }; }, ...queryProps }, queryClient ); }; // src/hooks/useRetrieveAddressFromPasskey.ts var useRetrieveAccountAddressFromPasskeys = ({ apiKey, chain, fullDomainSelected = false, baseUrl }) => { const [isPending, setIsPending] = _react.useState.call(void 0, false); const [error, setError] = _react.useState.call(void 0, null); const retrieveAddress = _react.useCallback.call(void 0, async () => { setIsPending(true); setError(null); try { const result = await _connectsdk4337.retrieveAccountAddressFromPasskeys.call(void 0, apiKey, chain, fullDomainSelected, baseUrl ); const address = result; return address; } catch (e) { const err = e instanceof Error ? e : new Error("An error occurred"); setError(err); throw err; } finally { setIsPending(false); } }, [apiKey, chain, baseUrl, fullDomainSelected]); return { retrieveAddress, isPending, error }; }; var useRetrieveAccountAddressFromPasskeyId = ({ apiKey, chain, fullDomainSelected = false, baseUrl }) => { const [isPending, setIsPending] = _react.useState.call(void 0, false); const [error, setError] = _react.useState.call(void 0, null); const retrieveAddress = _react.useCallback.call(void 0, async (id) => { setIsPending(true); setError(null); try { const result = await _connectsdk4337.retrieveAccountAddressFromPasskeyId.call(void 0, { apiKey, chain, id, fullDomainSelected, baseUrl }); const address = result; return address; } catch (e) { const err = e instanceof Error ? e : new Error("An error occurred"); setError(err); throw err; } finally { setIsPending(false); } }, [apiKey, chain, baseUrl, fullDomainSelected] ); return { retrieveAddress, isPending, error }; }; // src/hooks/useCreatePasskeySigner.ts var useCreateNewSigner = (apiKey, baseUrl) => { const { queryClient } = useSmartAccount(); const [isPending, setIsPending] = _react.useState.call(void 0, false); const [error, setError] = _react.useState.call(void 0, null); const createSigner = _react.useCallback.call(void 0, (params = {}) => { setIsPending(true); setError(null); _connectsdk4337.createNewSigner.call(void 0, { apiKey, baseUrl, params }).then((signer) => { _optionalChain([queryClient, 'optionalAccess', _86 => _86.invalidateQueries, 'call', _87 => _87({ queryKey: ["signer"] })]); return signer; }).catch((e) => { const err = e instanceof Error ? e : new Error("An error occurred"); setError(err); }).finally(() => { setIsPending(false); }); }, [apiKey, baseUrl, queryClient] ); const createSignerAsync = _react.useCallback.call(void 0, async (params = {}) => { setIsPending(true); setError(null); try { const signer = await _connectsdk4337.createNewSigner.call(void 0, { apiKey, baseUrl, params }); _optionalChain([queryClient, 'optionalAccess', _88 => _88.invalidateQueries, 'call', _89 => _89({ queryKey: ["signer"] })]); return signer; } catch (e) { const err = e instanceof Error ? e : new Error("An error occurred"); setError(err); throw err; } finally { setIsPending(false); } }, [apiKey, queryClient, baseUrl] ); return { createSigner, createSignerAsync, isPending, error }; }; var useSerializeUrlWithSignerPayload = () => { const [isPending, setIsPending] = _react.useState.call(void 0, false); const [error, setError] = _react.useState.call(void 0, null); const serializeUrl = _react.useCallback.call(void 0, (params) => { setIsPending(true); setError(null); _connectsdk4337.serializeUrlWithSignerPayload.call(void 0, params.validationPageUrl, params.signerPayload ).then((url) => { return url; }).catch((e) => { const err = e instanceof Error ? e : new Error("An error occurred"); setError(err); }).finally(() => { setIsPending(false); }); }, []); const serializeUrlAsync = _react.useCallback.call(void 0, async (params) => { setIsPending(true); setError(null); try { return await _connectsdk4337.serializeUrlWithSignerPayload.call(void 0, params.validationPageUrl, params.signerPayload ); } catch (e) { const err = e instanceof Error ? e : new Error("An error occurred"); setError(err); throw err; } finally { setIsPending(false); } }, [] ); return { serializeUrl, serializeUrlAsync, isPending, error }; }; var useGenerateQRCodeUrl = () => { const [isPending, setIsPending] = _react.useState.call(void 0, false); const [error, setError] = _react.useState.call(void 0, null); const generateQRCode = _react.useCallback.call(void 0, (params) => { setIsPending(true); setError(null); _connectsdk4337.generateQRCodeUrl.call(void 0, params.validationPageUrl, params.signerPayload, params.options ).then((qrCodeUrl) => { return qrCodeUrl; }).catch((e) => { const err = e instanceof Error ? e : new Error("An error occurred"); setError(err); }).finally(() => { setIsPending(false); }); }, [] ); const generateQRCodeAsync = _react.useCallback.call(void 0, async (params) => { setIsPending(true); setError(null); try { return await _connectsdk4337.generateQRCodeUrl.call(void 0, params.validationPageUrl, params.signerPayload, params.options ); } catch (e) { const err = e instanceof Error ? e : new Error("An error occurred"); setError(err); throw err; } finally { setIsPending(false); } }, [] ); return { generateQRCode, generateQRCodeAsync, isPending, error }; }; // src/hooks/useSignMessage.ts function useSignMessage() { const { smartAccountClient, queryClient } = useSmartAccount(); const { mutate, mutateAsync, ...result } = useMutation( { mutationFn: async ({ message }) => { if (!smartAccountClient) { throw new Error("No smart account found"); } const signature = await smartAccountClient.account.signMessage({ message }); return signature; } }, queryClient ); return { signMessage: mutate, signMessageAsync: mutateAsync, data: result.data, error: result.error, isPending: result.isPending, isSuccess: result.isSuccess, isError: result.isError }; } // src/hooks/recovery/useSetUpRecovery.ts function useSetUpRecovery() { const { smartAccountClient, queryClient } = useSmartAccount(); const { mutate, mutateAsync, ...result } = useMutation( { mutationFn: async (variables) => { if (!smartAccountClient) { throw new Error("No smart account found"); } return smartAccountClient.setUpRecoveryModule({ passKeyName: variables.passKeyName, rpcUrl: variables.rpcUrl, webAuthnOptions: variables.webAuthnOptions, // biome-ignore lint/suspicious/noExplicitAny: TODO: remove any middleware: variables.middleware }); } }, queryClient ); return { setUpRecoveryModule: mutate, setUpRecoveryModuleAsync: mutateAsync, isPending: result.isPending, isError: result.isError, error: result.error, isSuccess: result.isSuccess, data: result.data }; } // src/hooks/recovery/useIsRecoveryActive.ts function useIsRecoveryActive(props = {}) { const { smartAccountClient, queryClient } = useSmartAccount(); return useQuery( { queryKey: ["isRecoveryActive", props.rpcUrl], queryFn: async () => { if (!smartAccountClient) { throw new Error("No smart account found"); } return smartAccountClient.isRecoveryActive(props); }, enabled: !!smartAccountClient }, queryClient ); } // src/hooks/recovery/useGetRecoveryRequest.ts function useGetRecoveryRequest(props = {}, queryOptions) { const { smartAccountClient, queryClient } = useSmartAccount(); const { data, isLoading, isError, error } = useQuery( { queryKey: ["getRecoveryRequest", props.rpcUrl], queryFn: async () => { if (!smartAccountClient) { throw new Error("No smart account found"); } return smartAccountClient.getRecoveryRequest(props); }, enabled: !!smartAccountClient, ...queryOptions }, queryClient ); return { data, isLoading, isError, error }; } // src/hooks/recovery/useCancelRecoveryRequest.ts function useCancelRecoveryRequest() { const { smartAccountClient, queryClient } = useSmartAccount(); const { mutate, mutateAsync, ...result } = useMutation( { mutationFn: async (variables) => { if (!smartAccountClient) { throw new Error("No smart account found"); } return smartAccountClient.cancelRecoveryRequest({ rpcUrl: variables.rpcUrl, // biome-ignore lint/suspicious/noExplicitAny: TODO: remove any middleware: variables.middleware }); } }, queryClient ); return { cancelRecoveryRequest: mutate, cancelRecoveryRequestAsync: mutateAsync, isPending: result.isPending, isError: result.isError, error: result.error, isSuccess: result.isSuccess, data: result.data }; } // src/hooks/useSwitchChain.ts var useSwitchChain = () => { const context = _react.useContext.call(void 0, ConnectContext); if (context === void 0) { throw new Error("useSwitchChain must be used within a ConnectProvider"); } const { queryClient, smartAccountClient, updateSmartAccountClient, networksConfig } = context; const [isPending, setIsPending] = _react.useState.call(void 0, false); const [error, setError] = _react.useState.call(void 0, null); const switchChainInternal = _react.useCallback.call(void 0, async (params) => { const { chainId } = params; if (!networksConfig) throw new Error("No current configuration found"); const selectedNetwork = _optionalChain([networksConfig, 'optionalAccess', _90 => _90.find, 'call', _91 => _91( (network) => _optionalChain([network, 'access', _92 => _92.chain, 'optionalAccess', _93 => _93.id]) === chainId )]); if (!selectedNetwork) throw new Error("No current configuration found"); try { await updateSmartAccountClient({ address: _optionalChain([smartAccountClient, 'optionalAccess', _94 => _94.account, 'access', _95 => _95.address]), chain: selectedNetwork.chain }); _optionalChain([queryClient, 'optionalAccess', _96 => _96.invalidateQueries, 'call', _97 => _97({ queryKey: ["switchChain"] })]); } catch (e) { throw e instanceof Error ? e : new Error("An error occurred while switching chain"); } }, [ smartAccountClient, updateSmartAccountClient, queryClient, networksConfig ] ); const switchChain = _react.useCallback.call(void 0, (params) => { setIsPending(true); setError(null); switchChainInternal(params).catch((e) => { const err = e instanceof Error ? e : new Error( "An error occurred while switching chain" ); setError(err); }).finally(() => { setIsPending(false); }); }, [switchChainInternal] ); const switchChainAsync = _react.useCallback.call(void 0, async (params) => { setIsPending(true); setError(null); try { await switchChainInternal(params); } catch (e) { const err = e instanceof Error ? e : new Error("An error occurred while switching chain"); setError(err); throw err; } finally { setIsPending(false); } }, [switchChainInternal] ); return { switchChain, switchChainAsync, isPending, error }; }; // src/hooks/useGetTransactionCost.ts var useGetTransactionCost = (mutationProps) => { const { smartAccountClient, queryClient } = useSmartAccount(); const { mutate, mutateAsync, ...result } = useMutation( { mutationFn: async (variables) => { if (!smartAccountClient) { throw new Error("No smart account found"); } const { transactions } = variables; const userOperation = await smartAccountClient.account.buildUserOperation( transactions ); const estimateGas = await smartAccountClient.estimateGas({ userOperation }); const totalGas = estimateGas.preVerificationGas + estimateGas.verificationGasLimit + estimateGas.callGasLimit; return { totalGasCost: totalGas * estimateGas.maxFeePerGas }; }, ...mutationProps }, queryClient ); return { data: _optionalChain([result, 'access', _98 => _98.data, 'optionalAccess', _99 => _99.totalGasCost]), error: result.error, isPending: result.isPending, isSuccess: result.isSuccess, isError: result.isError, getTransactionCost: mutate, getTransactionCostAsync: mutateAsync }; }; // src/hooks/useEstimateGas.ts var useEstimateGas = (mutationProps) => { const { smartAccountClient, queryClient } = useSmartAccount(); const { mutate, mutateAsync, ...result } = useMutation( { mutationFn: async (variables) => { if (!smartAccountClient) { throw new Error("No smart account found"); } const { transactions } = variables; const userOperation = await smartAccountClient.account.buildUserOperation( transactions ); const estimateGas = await smartAccountClient.estimateGas({ userOperation }); return estimateGas; }, ...mutationProps }, queryClient ); return { data: result.data, error: result.error, isPending: result.isPending, isSuccess: result.isSuccess, isError: result.isError, estimateGas: mutate, estimateGasAsync: mutateAsync }; }; exports.ConnectProvider = ConnectProvider; exports.useAccount = useAccount; exports.useAddOwner = useAddOwner; exports.useAddSessionKey = useAddSessionKey; exports.useAddWhitelistDestination = useAddWhitelistDestination; exports.useCancelRecoveryRequest = useCancelRecoveryRequest; exports.useConnect = useConnect; exports.useCreateNewSigner = useCreateNewSigner; exports.useDisconnect = useDisconnect; exports.useEstimateGas = useEstimateGas; exports.useGenerateQRCodeUrl = useGenerateQRCodeUrl; exports.useGetEnrichedOwners = useGetEnrichedOwners; exports.useGetGasPrice = useGetGasPrice; exports.useGetOwners = useGetOwners; exports.useGetRecoveryRequest = useGetRecoveryRequest; exports.useGetSessionFromAddress = useGetSessionFromAddress; exports.useGetTransactionCost = useGetTransactionCost; exports.useIsAddressWhitelistDestination = useIsAddressWhitelistDestination; exports.useIsRecoveryActive = useIsRecoveryActive; exports.useRemoveOwner = useRemoveOwner; exports.useRemoveWhitelistDestination = useRemoveWhitelistDestination; exports.useRetrieveAccountAddressFromPasskeyId = useRetrieveAccountAddressFromPasskeyId; exports.useRetrieveAccountAddressFromPasskeys = useRetrieveAccountAddressFromPasskeys; exports.useRevokeSessionKey = useRevokeSessionKey; exports.useSendTransaction = useSendTransaction; exports.useSendTransactionWithSessionKey = useSendTransactionWithSessionKey; exports.useSerializeUrlWithSignerPayload = useSerializeUrlWithSignerPayload; exports.useSetUpRecovery = useSetUpRecovery; exports.useSignMessage = useSignMessage; exports.useSwitchChain = useSwitchChain; exports.useValidateAddDevice = useValidateAddDevice; exports.useVerifyMessage = useVerifyMessage; exports.useWriteContract = useWriteContract; exports.useWriteContractWithSessionKey = useWriteContractWithSessionKey;