1import { 2 ERROR_MAPPING 3} from "./chunk-3XSJCHSY.js"; 4import { 5 useKernelClient, 6 useUserOperationRunner 7} from "./chunk-5T6J6LWV.js"; 8import "./chunk-QZ6J6PY7.js"; 9import "./chunk-YJIE56AA.js"; 10import "./chunk-GABYCIRX.js"; 11import "./chunk-GWTLZPQW.js"; 12import "./chunk-TUIXK4GB.js"; 13import "./chunk-2SIOJVPY.js"; 14import "./chunk-DELSWSYH.js"; 15import "./chunk-F6HKBNBJ.js"; 16import "./chunk-EFX7LFQF.js"; 17import "./chunk-GW6OWVAS.js"; 18import "./chunk-V3VQYMUU.js"; 19import "./chunk-WAY6HQ7C.js"; 20import "./chunk-KAIIOKO3.js"; 21import "./chunk-F7LOI2M5.js"; 22import "./chunk-GWCOH4DF.js"; 23import "./chunk-FUATFXFK.js"; 24import "./chunk-55ARO2SJ.js"; 25import "./chunk-J46SIAYM.js"; 26import "./chunk-EUVCRAFR.js"; 27import "./chunk-5HUKUZMX.js"; 28import "./chunk-DRQXJS52.js"; 29import "./chunk-EKGTQN7B.js"; 30import { 31 decodeErrorResult, 32 encodeFunctionData 33} from "./chunk-57LJOLTQ.js"; 34import "./chunk-QOAWOBZZ.js"; 35import "./chunk-CXC3RFJP.js"; 36import "./chunk-LOYGATPO.js"; 37import "./chunk-MWZBDUVS.js"; 38import "./chunk-IVTAVDWF.js"; 39import { 40 require_react 41} from "./chunk-2TKNTQO7.js"; 42import { 43 __toESM, 44 init_buffer_shim 45} from "./chunk-DMHST2WB.js"; 46
47// ../VeeFriends.Web.Www.Components/React/ApprovalExecutor.tsx 48init_buffer_shim(); 49
50// ../VeeFriends.Web.Www.Components/React/hooks/useApprovalExecution.ts 51init_buffer_shim(); 52var React = __toESM(require_react()); 53var useApprovalExecution = (props) => { 54 const { dotNetRef, approvalTransfers, contractAddress, contractAbi, bundlerRpc, paymasterRpc, isDevelopment, selectedPrivyWalletAddress, network, approvalBatchSize } = props; 55 const decodeRevertError = React.useCallback((errorMessage) => { 56 if (!contractAbi) return errorMessage; 57 const hexMatch = errorMessage.match(/0x[a-fA-F0-9]+/); 58 if (!hexMatch) return errorMessage; 59 const errorHex = hexMatch[0]; 60 try { 61 const errorAbi = contractAbi.filter((item) => item.type === "error"); 62 if (errorAbi.length === 0) return errorMessage; 63 const decodedError = decodeErrorResult({ 64 abi: contractAbi, 65 data: errorHex 66 }); 67 if (decodedError.errorName) { 68 let decodedMessage = `Contract Error: ${decodedError.errorName}`; 69 if (decodedError.args && Object.keys(decodedError.args).length > 0) { 70 const args = Object.entries(decodedError.args).map(([key, value]) => `${key}: ${value}`).join(", "); 71 decodedMessage += ` (${args})`; 72 } 73 return decodedMessage; 74 } 75 } catch (decodeError) { 76 console.log("Could not decode error with ABI:", decodeError); 77 const errorCode = errorHex.toLowerCase(); 78 const knownError = ERROR_MAPPING[errorCode]; 79 if (knownError) { 80 return `${knownError.message} 81 82(Error: ${knownError.name})`; 83 } 84 } 85 return errorMessage; 86 }, [contractAbi]); 87 const { client, isInitializing: isClientInitializing, error: clientError } = useKernelClient({ 88 bundlerRpc, 89 paymasterRpc, 90 isDevelopment, 91 selectedWalletAddress: selectedPrivyWalletAddress, 92 network 93 }); 94 const [hasStarted, setHasStarted] = React.useState(false); 95 const [isComplete, setIsComplete] = React.useState(false); 96 const eventQueueRef = React.useRef(Promise.resolve()); 97 const stableApprovalTransfers = React.useMemo(() => approvalTransfers, [JSON.stringify(approvalTransfers)]); 98 const emitEvent = React.useCallback((event) => { 99 const nextEvent = eventQueueRef.current.then(async () => { 100 try { 101 await dotNetRef.invokeMethodAsync("OnEventCallback", JSON.stringify(event)); 102 } catch (error) { 103 console.error("[ApprovalExecution] Failed to deliver progress event:", error); 104 } 105 }); 106 eventQueueRef.current = nextEvent; 107 return nextEvent; 108 }, [dotNetRef]); 109 const { executeBundled, executeBatchedApprovals, isExecuting, error: runnerError, completedTxs, currentBatch, totalBatches } = useUserOperationRunner(client, dotNetRef, emitEvent); 110 const executeApproval = React.useCallback(async () => { 111 await emitEvent({ 112 type: "status", 113 category: "approval", 114 status: "preparing", 115 message: "Preparing approval transactions..." 116 }); 117 const calls = stableApprovalTransfers.map((transfer) => ({ 118 to: contractAddress, 119 value: BigInt(0), 120 data: encodeFunctionData({ ...transfer.batchData }) 121 })); 122 if (approvalBatchSize !== void 0) { 123 await executeBatchedApprovals(calls, approvalBatchSize); 124 return; 125 } 126 await emitEvent({ 127 type: "status", 128 category: "approval", 129 status: "executing", 130 message: `Bundling ${calls.length} approval${calls.length > 1 ? "s" : ""} into one transaction...` 131 }); 132 await executeBundled(calls); 133 }, [stableApprovalTransfers, contractAddress, executeBundled, executeBatchedApprovals, approvalBatchSize, emitEvent]); 134 React.useEffect(() => { 135 if (isClientInitializing) { 136 void emitEvent({ 137 type: "status", 138 category: "approval", 139 status: "initializing", 140 message: "Connecting to wallet..." 141 }); 142 } 143 }, [isClientInitializing, emitEvent]); 144 React.useEffect(() => { 145 if (completedTxs.length > 0) { 146 console.log("[ApprovalExecution] Completed transactions:", completedTxs); 147 } 148 }, [completedTxs]); 149 React.useEffect(() => { 150 const error = clientError || runnerError; 151 if (error && !isComplete) { 152 const decodedError = decodeRevertError(error); 153 void emitEvent({ 154 type: "error", 155 category: error === clientError ? "wallet" : "transaction", 156 message: decodedError, 157 error: decodedError 158 }); 159 setIsComplete(true); 160 } 161 }, [clientError, runnerError, isComplete, emitEvent, decodeRevertError]); 162 React.useEffect(() => { 163 if (!isExecuting && !runnerError && !clientError && currentBatch === totalBatches && completedTxs.length > 0 && !isComplete && hasStarted) { 164 console.log("[ApprovalExecution] Approval complete! Transaction hashes:", completedTxs); 165 console.log("[ApprovalExecution] Sending result event with", completedTxs.length, "transaction hashes"); 166 void emitEvent({ 167 type: "result", 168 success: true, 169 transactionHashes: completedTxs, 170 approvedTokens: stableApprovalTransfers.length, 171 message: `Successfully approved ${stableApprovalTransfers.length} tokens` 172 }); 173 setIsComplete(true); 174 } 175 }, [isExecuting, runnerError, clientError, currentBatch, totalBatches, completedTxs, isComplete, hasStarted, stableApprovalTransfers.length, emitEvent]); 176 React.useEffect(() => { 177 if (!isClientInitializing && client && !hasStarted) { 178 setHasStarted(true); 179 void (async () => { 180 await emitEvent({ 181 type: "status", 182 category: "approval", 183 status: "signing", 184 message: "Setting up wallet for EIP-7702..." 185 }); 186 await executeApproval(); 187 })(); 188 } 189 }, [isClientInitializing, client, hasStarted, executeApproval, emitEvent]); 190 return { 191 isInitializing: isClientInitializing, 192 isExecuting, 193 isComplete, 194 error: clientError || runnerError, 195 completedTxs, 196 currentBatch, 197 totalBatches 198 }; 199};
vendor: 2 bytes, line 200
200
201// ../VeeFriends.Web.Www.Components/React/ApprovalExecutor.tsx 202var ApprovalExecutor = (props) => { 203 useApprovalExecution(props); 204 return null; 205}; 206var ApprovalExecutor_default = ApprovalExecutor; 207export { 208 ApprovalExecutor_default as default 209}; 210//# sourceMappingURL=ApprovalExecutor.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.