@provex/react 1.2.5 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ProvexProvider-DWxHsaR8.d.cts +1013 -0
- package/dist/ProvexProvider-DWxHsaR8.d.ts +1013 -0
- package/dist/chunk-7BVFQVKS.js +2165 -0
- package/dist/chunk-7BVFQVKS.js.map +1 -0
- package/dist/index.cjs +174 -107
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +35 -1030
- package/dist/index.d.ts +35 -1030
- package/dist/index.js +79 -2174
- package/dist/index.js.map +1 -1
- package/dist/wagmi.cjs +2142 -0
- package/dist/wagmi.cjs.map +1 -0
- package/dist/wagmi.d.cts +82 -0
- package/dist/wagmi.d.ts +82 -0
- package/dist/wagmi.js +72 -0
- package/dist/wagmi.js.map +1 -0
- package/package.json +16 -5
package/dist/index.cjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var react = require('react');
|
|
4
4
|
var reactQuery = require('@tanstack/react-query');
|
|
5
|
+
var viem = require('viem');
|
|
5
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
7
|
var payment = require('@provex/utils/payment');
|
|
7
8
|
var currencies = require('@provex/utils/currencies');
|
|
@@ -10,12 +11,10 @@ var units = require('@provex/utils/units');
|
|
|
10
11
|
var conversionRates = require('@provex/utils/conversionRates');
|
|
11
12
|
var reputation = require('@provex/utils/reputation');
|
|
12
13
|
var contracts = require('@provex/utils/contracts');
|
|
13
|
-
var viem = require('viem');
|
|
14
14
|
var fees = require('@provex/utils/fees');
|
|
15
15
|
var abis = require('@provex/abis');
|
|
16
16
|
var chain = require('@provex/utils/chain');
|
|
17
17
|
var chains = require('viem/chains');
|
|
18
|
-
var wagmi = require('wagmi');
|
|
19
18
|
var ids = require('@provex/utils/ids');
|
|
20
19
|
|
|
21
20
|
// src/ProvexProvider.tsx
|
|
@@ -58,13 +57,25 @@ function ProvexProvider({
|
|
|
58
57
|
config,
|
|
59
58
|
indexer,
|
|
60
59
|
queryClient,
|
|
60
|
+
publicClient: publicClient2,
|
|
61
|
+
publicClients,
|
|
62
|
+
wallet,
|
|
61
63
|
children
|
|
62
64
|
}) {
|
|
63
65
|
const resolvedQueryClient = queryClient ?? defaultQueryClient;
|
|
64
66
|
const contextValue = react.useMemo(() => {
|
|
65
67
|
const apiClient = createApiClient(config.apiUrl);
|
|
66
|
-
|
|
67
|
-
|
|
68
|
+
const chainId = config.chain.id;
|
|
69
|
+
const base2 = publicClients ?? {};
|
|
70
|
+
const resolved = { ...base2 };
|
|
71
|
+
if (publicClient2 && !resolved[chainId]) {
|
|
72
|
+
resolved[chainId] = publicClient2;
|
|
73
|
+
}
|
|
74
|
+
if (!resolved[chainId]) {
|
|
75
|
+
resolved[chainId] = viem.createPublicClient({ chain: config.chain, transport: viem.http() });
|
|
76
|
+
}
|
|
77
|
+
return { config, indexer, apiClient, publicClients: resolved, wallet };
|
|
78
|
+
}, [config, indexer, publicClient2, publicClients, wallet]);
|
|
68
79
|
return /* @__PURE__ */ jsxRuntime.jsx(ProvexContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxRuntime.jsx(reactQuery.QueryClientProvider, { client: resolvedQueryClient, children }) });
|
|
69
80
|
}
|
|
70
81
|
function useProvex() {
|
|
@@ -77,6 +88,23 @@ function useProvex() {
|
|
|
77
88
|
function useOptionalProvex() {
|
|
78
89
|
return react.useContext(ProvexContext);
|
|
79
90
|
}
|
|
91
|
+
function useProvexPublicClient(chainId) {
|
|
92
|
+
const { config, publicClients } = useProvex();
|
|
93
|
+
const target = chainId ?? config.chain.id;
|
|
94
|
+
return publicClients[target];
|
|
95
|
+
}
|
|
96
|
+
function useOptionalProvexPublicClient(chainId) {
|
|
97
|
+
const ctx = useOptionalProvex();
|
|
98
|
+
if (!ctx) return void 0;
|
|
99
|
+
const target = chainId ?? ctx.config.chain.id;
|
|
100
|
+
return ctx.publicClients[target];
|
|
101
|
+
}
|
|
102
|
+
function useProvexWallet() {
|
|
103
|
+
return useProvex().wallet;
|
|
104
|
+
}
|
|
105
|
+
function useOptionalProvexWallet() {
|
|
106
|
+
return useOptionalProvex()?.wallet;
|
|
107
|
+
}
|
|
80
108
|
var DEFAULT_REFETCH_INTERVAL_MS = 5e3;
|
|
81
109
|
function getRate({
|
|
82
110
|
deposit,
|
|
@@ -1368,6 +1396,79 @@ function usePayeeDetails({
|
|
|
1368
1396
|
refetchAll
|
|
1369
1397
|
]);
|
|
1370
1398
|
}
|
|
1399
|
+
function useContractRead(params) {
|
|
1400
|
+
const publicClient2 = useOptionalProvexPublicClient(params.chainId);
|
|
1401
|
+
const enabled = (params.query?.enabled ?? true) && !!publicClient2 && !!params.address;
|
|
1402
|
+
return reactQuery.useQuery({
|
|
1403
|
+
queryKey: [
|
|
1404
|
+
"provex",
|
|
1405
|
+
"readContract",
|
|
1406
|
+
params.chainId,
|
|
1407
|
+
params.address,
|
|
1408
|
+
params.functionName,
|
|
1409
|
+
params.args
|
|
1410
|
+
],
|
|
1411
|
+
queryFn: async () => {
|
|
1412
|
+
if (!publicClient2) throw new Error("No public client available");
|
|
1413
|
+
if (!params.address) throw new Error("Missing contract address");
|
|
1414
|
+
const result = await publicClient2.readContract({
|
|
1415
|
+
address: params.address,
|
|
1416
|
+
abi: params.abi,
|
|
1417
|
+
functionName: params.functionName,
|
|
1418
|
+
args: params.args ?? []
|
|
1419
|
+
});
|
|
1420
|
+
return result;
|
|
1421
|
+
},
|
|
1422
|
+
enabled,
|
|
1423
|
+
staleTime: params.query?.staleTime,
|
|
1424
|
+
gcTime: params.query?.gcTime
|
|
1425
|
+
});
|
|
1426
|
+
}
|
|
1427
|
+
function useContractReads(params) {
|
|
1428
|
+
const firstChainId = params.contracts[0]?.chainId;
|
|
1429
|
+
const publicClient2 = useOptionalProvexPublicClient(firstChainId);
|
|
1430
|
+
const allHaveAddresses = params.contracts.every((c) => !!c.address);
|
|
1431
|
+
const enabled = (params.query?.enabled ?? true) && !!publicClient2 && allHaveAddresses && params.contracts.length > 0;
|
|
1432
|
+
return reactQuery.useQuery({
|
|
1433
|
+
queryKey: [
|
|
1434
|
+
"provex",
|
|
1435
|
+
"readContracts",
|
|
1436
|
+
firstChainId,
|
|
1437
|
+
params.contracts.map((c) => [c.address, c.functionName, c.args])
|
|
1438
|
+
],
|
|
1439
|
+
queryFn: async () => {
|
|
1440
|
+
if (!publicClient2) throw new Error("No public client available");
|
|
1441
|
+
const results = await Promise.all(
|
|
1442
|
+
params.contracts.map(async (call) => {
|
|
1443
|
+
if (!call.address) {
|
|
1444
|
+
return {
|
|
1445
|
+
status: "failure",
|
|
1446
|
+
error: new Error("Missing contract address")
|
|
1447
|
+
};
|
|
1448
|
+
}
|
|
1449
|
+
try {
|
|
1450
|
+
const result = await publicClient2.readContract({
|
|
1451
|
+
address: call.address,
|
|
1452
|
+
abi: call.abi,
|
|
1453
|
+
functionName: call.functionName,
|
|
1454
|
+
args: call.args ?? []
|
|
1455
|
+
});
|
|
1456
|
+
return { status: "success", result };
|
|
1457
|
+
} catch (error) {
|
|
1458
|
+
return {
|
|
1459
|
+
status: "failure",
|
|
1460
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
1461
|
+
};
|
|
1462
|
+
}
|
|
1463
|
+
})
|
|
1464
|
+
);
|
|
1465
|
+
return results;
|
|
1466
|
+
},
|
|
1467
|
+
enabled,
|
|
1468
|
+
staleTime: params.query?.staleTime,
|
|
1469
|
+
gcTime: params.query?.gcTime
|
|
1470
|
+
});
|
|
1471
|
+
}
|
|
1371
1472
|
var FEE_CACHE_STALE_TIME = 60 * 60 * 1e3;
|
|
1372
1473
|
function useProtocolFees({
|
|
1373
1474
|
chainId,
|
|
@@ -1380,7 +1481,7 @@ function useProtocolFees({
|
|
|
1380
1481
|
isError: isErrorOrchestrator,
|
|
1381
1482
|
error: errorOrchestrator,
|
|
1382
1483
|
refetch: refetchOrchestrator
|
|
1383
|
-
} =
|
|
1484
|
+
} = useContractRead({
|
|
1384
1485
|
address: escrowAddress,
|
|
1385
1486
|
abi: abis.V3EscrowAbi,
|
|
1386
1487
|
functionName: "orchestrator",
|
|
@@ -1397,7 +1498,7 @@ function useProtocolFees({
|
|
|
1397
1498
|
isError: isErrorFees,
|
|
1398
1499
|
error: errorFees,
|
|
1399
1500
|
refetch: refetchFees
|
|
1400
|
-
} =
|
|
1501
|
+
} = useContractReads({
|
|
1401
1502
|
contracts: [
|
|
1402
1503
|
{
|
|
1403
1504
|
address: orchestratorAddress,
|
|
@@ -2067,59 +2168,13 @@ function ProvexBuyRoot({
|
|
|
2067
2168
|
}
|
|
2068
2169
|
);
|
|
2069
2170
|
}
|
|
2070
|
-
function useWagmiWallet() {
|
|
2071
|
-
const { address } = wagmi.useAccount();
|
|
2072
|
-
const { data: walletClient } = wagmi.useWalletClient();
|
|
2073
|
-
return react.useMemo(() => {
|
|
2074
|
-
if (!walletClient || !address) return null;
|
|
2075
|
-
return {
|
|
2076
|
-
address,
|
|
2077
|
-
async sendTransaction(tx) {
|
|
2078
|
-
return walletClient.sendTransaction({
|
|
2079
|
-
to: tx.to,
|
|
2080
|
-
data: tx.data,
|
|
2081
|
-
value: tx.value ?? 0n,
|
|
2082
|
-
chain: walletClient.chain,
|
|
2083
|
-
maxFeePerGas: tx.maxFeePerGas,
|
|
2084
|
-
maxPriorityFeePerGas: tx.maxPriorityFeePerGas
|
|
2085
|
-
});
|
|
2086
|
-
}
|
|
2087
|
-
};
|
|
2088
|
-
}, [walletClient, address]);
|
|
2089
|
-
}
|
|
2090
|
-
var DISCONNECTED_WALLET = {
|
|
2091
|
-
address: void 0,
|
|
2092
|
-
sendTransaction: () => Promise.reject(new Error("Wallet not connected"))
|
|
2093
|
-
};
|
|
2094
|
-
function ProvexBuyWagmi({
|
|
2095
|
-
onIntentSignaled,
|
|
2096
|
-
onComplete,
|
|
2097
|
-
paymentMethods,
|
|
2098
|
-
className,
|
|
2099
|
-
style,
|
|
2100
|
-
theme
|
|
2101
|
-
}) {
|
|
2102
|
-
const wallet = useWagmiWallet() ?? DISCONNECTED_WALLET;
|
|
2103
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2104
|
-
ProvexBuy,
|
|
2105
|
-
{
|
|
2106
|
-
wallet,
|
|
2107
|
-
onIntentSignaled,
|
|
2108
|
-
onComplete,
|
|
2109
|
-
paymentMethods,
|
|
2110
|
-
className,
|
|
2111
|
-
style,
|
|
2112
|
-
theme
|
|
2113
|
-
}
|
|
2114
|
-
);
|
|
2115
|
-
}
|
|
2116
2171
|
function useNullifierRegistry({
|
|
2117
2172
|
escrowAddress,
|
|
2118
2173
|
paymentMethodId,
|
|
2119
2174
|
chainId
|
|
2120
2175
|
}) {
|
|
2121
|
-
const publicClient2 =
|
|
2122
|
-
const { data: orchestratorAddress, isLoading: isLoadingOrchestrator } =
|
|
2176
|
+
const publicClient2 = useOptionalProvexPublicClient(chainId);
|
|
2177
|
+
const { data: orchestratorAddress, isLoading: isLoadingOrchestrator } = useContractRead({
|
|
2123
2178
|
address: escrowAddress,
|
|
2124
2179
|
abi: abis.V3EscrowAbi,
|
|
2125
2180
|
functionName: "orchestrator",
|
|
@@ -2128,7 +2183,7 @@ function useNullifierRegistry({
|
|
|
2128
2183
|
enabled: !!escrowAddress
|
|
2129
2184
|
}
|
|
2130
2185
|
});
|
|
2131
|
-
const { data: paymentVerifierRegistryAddress, isLoading: isLoadingRegistry } =
|
|
2186
|
+
const { data: paymentVerifierRegistryAddress, isLoading: isLoadingRegistry } = useContractRead({
|
|
2132
2187
|
address: orchestratorAddress,
|
|
2133
2188
|
abi: abis.OrchestratorAbi,
|
|
2134
2189
|
functionName: "paymentVerifierRegistry",
|
|
@@ -2137,7 +2192,7 @@ function useNullifierRegistry({
|
|
|
2137
2192
|
enabled: !!orchestratorAddress
|
|
2138
2193
|
}
|
|
2139
2194
|
});
|
|
2140
|
-
const { data: verifierAddress, isLoading: isLoadingVerifier } =
|
|
2195
|
+
const { data: verifierAddress, isLoading: isLoadingVerifier } = useContractRead({
|
|
2141
2196
|
address: paymentVerifierRegistryAddress,
|
|
2142
2197
|
abi: abis.PaymentVerifierRegistryAbi,
|
|
2143
2198
|
functionName: "getVerifier",
|
|
@@ -2147,7 +2202,7 @@ function useNullifierRegistry({
|
|
|
2147
2202
|
enabled: !!paymentVerifierRegistryAddress && !!paymentMethodId
|
|
2148
2203
|
}
|
|
2149
2204
|
});
|
|
2150
|
-
const { data: nullifierRegistryAddress, isLoading: isLoadingNullifierRegistry } =
|
|
2205
|
+
const { data: nullifierRegistryAddress, isLoading: isLoadingNullifierRegistry } = useContractRead({
|
|
2151
2206
|
address: verifierAddress,
|
|
2152
2207
|
abi: abis.UnifiedPaymentVerifierAbi,
|
|
2153
2208
|
functionName: "nullifierRegistry",
|
|
@@ -2202,25 +2257,19 @@ var useAllowance = ({
|
|
|
2202
2257
|
}
|
|
2203
2258
|
return viem.maxUint256;
|
|
2204
2259
|
}, [defaultAllowance, balance]);
|
|
2205
|
-
const
|
|
2206
|
-
const
|
|
2207
|
-
const
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
args: [account, spender]
|
|
2217
|
-
});
|
|
2218
|
-
return result;
|
|
2219
|
-
},
|
|
2220
|
-
enabled: queryEnabled
|
|
2260
|
+
const publicClient2 = useOptionalProvexPublicClient(token.chainId);
|
|
2261
|
+
const wallet = useOptionalProvexWallet();
|
|
2262
|
+
const { data, isLoading, error, refetch } = useContractRead({
|
|
2263
|
+
address: token.address,
|
|
2264
|
+
abi: viem.erc20Abi,
|
|
2265
|
+
functionName: "allowance",
|
|
2266
|
+
args: account && spender ? [account, spender] : void 0,
|
|
2267
|
+
chainId: token.chainId,
|
|
2268
|
+
query: {
|
|
2269
|
+
enabled: !!account && !!spender && !!token.address
|
|
2270
|
+
}
|
|
2221
2271
|
});
|
|
2222
2272
|
const [approvalPhase, setApprovalPhase] = react.useState("idle");
|
|
2223
|
-
const { mutateAsync } = wagmi.useWriteContract();
|
|
2224
2273
|
const isWritingApproval = approvalPhase !== "idle";
|
|
2225
2274
|
const approvalLoadingText = approvalPhase === "confirming" ? "Confirming..." : `Approve ${token.symbol}`;
|
|
2226
2275
|
return {
|
|
@@ -2231,23 +2280,25 @@ var useAllowance = ({
|
|
|
2231
2280
|
approvalLoadingText,
|
|
2232
2281
|
error,
|
|
2233
2282
|
writeApproval: async () => {
|
|
2234
|
-
if (!account || !spender || !token.address || !publicClient2) {
|
|
2283
|
+
if (!account || !spender || !token.address || !publicClient2 || !wallet) {
|
|
2235
2284
|
return;
|
|
2236
2285
|
}
|
|
2237
2286
|
setApprovalPhase("submitting");
|
|
2238
2287
|
try {
|
|
2239
|
-
if (currentChain?.id !== token.chainId) {
|
|
2240
|
-
await switchChainAsync({ chainId: token.chainId });
|
|
2241
|
-
}
|
|
2242
2288
|
const gasInputs = await getTransactionGasInputs(token.chainId);
|
|
2243
|
-
const
|
|
2244
|
-
chainId: token.chainId,
|
|
2245
|
-
address: token.address,
|
|
2289
|
+
const callData = viem.encodeFunctionData({
|
|
2246
2290
|
abi: viem.erc20Abi,
|
|
2247
2291
|
functionName: "approve",
|
|
2248
|
-
...gasInputs,
|
|
2249
2292
|
args: [spender, targetAllowance]
|
|
2250
2293
|
});
|
|
2294
|
+
const hash = await wallet.sendTransaction({
|
|
2295
|
+
to: token.address,
|
|
2296
|
+
data: callData,
|
|
2297
|
+
value: 0n,
|
|
2298
|
+
chainId: token.chainId,
|
|
2299
|
+
maxFeePerGas: gasInputs.maxFeePerGas,
|
|
2300
|
+
maxPriorityFeePerGas: gasInputs.maxPriorityFeePerGas
|
|
2301
|
+
});
|
|
2251
2302
|
setApprovalPhase("confirming");
|
|
2252
2303
|
await publicClient2.waitForTransactionReceipt({ hash });
|
|
2253
2304
|
await refetch();
|
|
@@ -2271,7 +2322,8 @@ var useCancelIntent = ({
|
|
|
2271
2322
|
version: explicitVersion
|
|
2272
2323
|
}) => {
|
|
2273
2324
|
const provex = useOptionalProvex();
|
|
2274
|
-
const wallet =
|
|
2325
|
+
const wallet = useOptionalProvexWallet();
|
|
2326
|
+
const publicClient2 = useOptionalProvexPublicClient(chainId ?? void 0);
|
|
2275
2327
|
const [status, setStatus] = react.useState("idle");
|
|
2276
2328
|
const [errorMessage, setErrorMessage] = react.useState(null);
|
|
2277
2329
|
const isLoading = react.useMemo(() => status === "prompt_wallet_confirm" || status === "writing_tx", [status]);
|
|
@@ -2293,13 +2345,11 @@ var useCancelIntent = ({
|
|
|
2293
2345
|
return createProveXClient({
|
|
2294
2346
|
chain: provex.config.chain,
|
|
2295
2347
|
apiUrl: provex.config.apiUrl,
|
|
2296
|
-
wallet
|
|
2348
|
+
wallet,
|
|
2297
2349
|
indexer: provex.indexer,
|
|
2298
2350
|
escrowAddress: escrowAddress ?? void 0
|
|
2299
2351
|
});
|
|
2300
2352
|
}, [provex, chainId, version, wallet, escrowAddress]);
|
|
2301
|
-
const { mutateAsync: writeContractAsync } = wagmi.useWriteContract();
|
|
2302
|
-
const publicClient2 = wagmi.usePublicClient();
|
|
2303
2353
|
const cancelIntent = react.useCallback(async (intentHash) => {
|
|
2304
2354
|
if (!intentHash || !chainId) return;
|
|
2305
2355
|
setStatus("prompt_wallet_confirm");
|
|
@@ -2310,13 +2360,20 @@ var useCancelIntent = ({
|
|
|
2310
2360
|
await client.cancelIntent({ intentHash });
|
|
2311
2361
|
} else {
|
|
2312
2362
|
if (!escrowAddress) throw new Error("Missing escrow address");
|
|
2363
|
+
if (!wallet) throw new Error("No wallet configured on ProvexProvider");
|
|
2313
2364
|
const gasInputs = await getTransactionGasInputs(chainId);
|
|
2314
|
-
const
|
|
2315
|
-
address: escrowAddress,
|
|
2365
|
+
const data = viem.encodeFunctionData({
|
|
2316
2366
|
abi: abis.V2EscrowAbi,
|
|
2317
2367
|
functionName: "cancelIntent",
|
|
2318
|
-
args: [intentHash]
|
|
2319
|
-
|
|
2368
|
+
args: [intentHash]
|
|
2369
|
+
});
|
|
2370
|
+
const hash = await wallet.sendTransaction({
|
|
2371
|
+
to: escrowAddress,
|
|
2372
|
+
data,
|
|
2373
|
+
value: 0n,
|
|
2374
|
+
chainId,
|
|
2375
|
+
maxFeePerGas: gasInputs.maxFeePerGas,
|
|
2376
|
+
maxPriorityFeePerGas: gasInputs.maxPriorityFeePerGas
|
|
2320
2377
|
});
|
|
2321
2378
|
if (publicClient2) await publicClient2.waitForTransactionReceipt({ hash });
|
|
2322
2379
|
if (provex?.indexer) {
|
|
@@ -2337,7 +2394,7 @@ var useCancelIntent = ({
|
|
|
2337
2394
|
} finally {
|
|
2338
2395
|
onSettled?.();
|
|
2339
2396
|
}
|
|
2340
|
-
}, [chainId, escrowAddress, version, client, publicClient2,
|
|
2397
|
+
}, [chainId, escrowAddress, version, client, publicClient2, wallet, provex, onSuccess, onMutate, onError, onSettled]);
|
|
2341
2398
|
return {
|
|
2342
2399
|
cancelIntent,
|
|
2343
2400
|
status,
|
|
@@ -2354,7 +2411,8 @@ var useReleaseFundsToPayer = ({
|
|
|
2354
2411
|
version: explicitVersion
|
|
2355
2412
|
}) => {
|
|
2356
2413
|
const provex = useOptionalProvex();
|
|
2357
|
-
const wallet =
|
|
2414
|
+
const wallet = useOptionalProvexWallet();
|
|
2415
|
+
const publicClient2 = useOptionalProvexPublicClient(chainId ?? void 0);
|
|
2358
2416
|
const [status, setStatus] = react.useState("idle");
|
|
2359
2417
|
const [errorMessage, setErrorMessage] = react.useState(null);
|
|
2360
2418
|
const isLoading = react.useMemo(
|
|
@@ -2379,13 +2437,11 @@ var useReleaseFundsToPayer = ({
|
|
|
2379
2437
|
return createProveXClient({
|
|
2380
2438
|
chain: provex.config.chain,
|
|
2381
2439
|
apiUrl: provex.config.apiUrl,
|
|
2382
|
-
wallet
|
|
2440
|
+
wallet,
|
|
2383
2441
|
indexer: provex.indexer,
|
|
2384
2442
|
escrowAddress: escrowAddress ?? void 0
|
|
2385
2443
|
});
|
|
2386
2444
|
}, [provex, chainId, version, wallet, escrowAddress]);
|
|
2387
|
-
const { mutateAsync: writeContractAsync } = wagmi.useWriteContract();
|
|
2388
|
-
const publicClient2 = wagmi.usePublicClient();
|
|
2389
2445
|
const releaseFundsToPayer = react.useCallback(async (intentHash) => {
|
|
2390
2446
|
if (!intentHash || !chainId) return;
|
|
2391
2447
|
setStatus("prompt_wallet_confirm");
|
|
@@ -2395,13 +2451,20 @@ var useReleaseFundsToPayer = ({
|
|
|
2395
2451
|
await client.releaseFundsToPayer({ intentHash });
|
|
2396
2452
|
} else {
|
|
2397
2453
|
if (!escrowAddress) throw new Error("Missing escrow address");
|
|
2454
|
+
if (!wallet) throw new Error("No wallet configured on ProvexProvider");
|
|
2398
2455
|
const gasInputs = await getTransactionGasInputs(chainId);
|
|
2399
|
-
const
|
|
2400
|
-
address: escrowAddress,
|
|
2456
|
+
const data = viem.encodeFunctionData({
|
|
2401
2457
|
abi: abis.V2EscrowAbi,
|
|
2402
2458
|
functionName: "releaseFundsToPayer",
|
|
2403
|
-
args: [intentHash]
|
|
2404
|
-
|
|
2459
|
+
args: [intentHash]
|
|
2460
|
+
});
|
|
2461
|
+
const hash = await wallet.sendTransaction({
|
|
2462
|
+
to: escrowAddress,
|
|
2463
|
+
data,
|
|
2464
|
+
value: 0n,
|
|
2465
|
+
chainId,
|
|
2466
|
+
maxFeePerGas: gasInputs.maxFeePerGas,
|
|
2467
|
+
maxPriorityFeePerGas: gasInputs.maxPriorityFeePerGas
|
|
2405
2468
|
});
|
|
2406
2469
|
if (publicClient2) await publicClient2.waitForTransactionReceipt({ hash });
|
|
2407
2470
|
if (provex?.indexer) {
|
|
@@ -2422,7 +2485,7 @@ var useReleaseFundsToPayer = ({
|
|
|
2422
2485
|
} finally {
|
|
2423
2486
|
onSettled?.();
|
|
2424
2487
|
}
|
|
2425
|
-
}, [chainId, escrowAddress, version, client, publicClient2,
|
|
2488
|
+
}, [chainId, escrowAddress, version, client, publicClient2, wallet, provex, onSuccess, onSettled]);
|
|
2426
2489
|
return {
|
|
2427
2490
|
releaseFundsToPayer,
|
|
2428
2491
|
status,
|
|
@@ -2439,7 +2502,7 @@ var useV3Escrow = ({
|
|
|
2439
2502
|
onError
|
|
2440
2503
|
}) => {
|
|
2441
2504
|
const provex = useOptionalProvex();
|
|
2442
|
-
const wallet =
|
|
2505
|
+
const wallet = useOptionalProvexWallet();
|
|
2443
2506
|
const [status, setStatus] = react.useState("idle");
|
|
2444
2507
|
const [error, setError] = react.useState(null);
|
|
2445
2508
|
const [txHash, setTxHash] = react.useState(null);
|
|
@@ -2457,7 +2520,7 @@ var useV3Escrow = ({
|
|
|
2457
2520
|
return createProveXClient({
|
|
2458
2521
|
chain: provex.config.chain,
|
|
2459
2522
|
apiUrl: provex.config.apiUrl,
|
|
2460
|
-
wallet
|
|
2523
|
+
wallet,
|
|
2461
2524
|
indexer: provex.indexer,
|
|
2462
2525
|
escrowAddress: escrow ?? void 0,
|
|
2463
2526
|
onTransactionHash: (hash) => {
|
|
@@ -2470,16 +2533,18 @@ var useV3Escrow = ({
|
|
|
2470
2533
|
}
|
|
2471
2534
|
});
|
|
2472
2535
|
}, [provex, chainId, wallet, escrow, onSlowSync]);
|
|
2473
|
-
const { data: orchestratorAddress, refetch: refetchOrchestrator } =
|
|
2536
|
+
const { data: orchestratorAddress, refetch: refetchOrchestrator } = useContractRead({
|
|
2474
2537
|
address: escrow ?? void 0,
|
|
2475
2538
|
abi: abis.V3EscrowAbi,
|
|
2476
2539
|
functionName: "orchestrator",
|
|
2540
|
+
chainId: chainId ?? void 0,
|
|
2477
2541
|
query: { enabled: !!escrow }
|
|
2478
2542
|
});
|
|
2479
|
-
const { data: depositCounter, refetch: refetchDepositCounter } =
|
|
2543
|
+
const { data: depositCounter, refetch: refetchDepositCounter } = useContractRead({
|
|
2480
2544
|
address: escrow ?? void 0,
|
|
2481
2545
|
abi: abis.V3EscrowAbi,
|
|
2482
2546
|
functionName: "depositCounter",
|
|
2547
|
+
chainId: chainId ?? void 0,
|
|
2483
2548
|
query: { enabled: !!escrow }
|
|
2484
2549
|
});
|
|
2485
2550
|
const executeClientMethod = react.useCallback(async (method, action) => {
|
|
@@ -2627,7 +2692,7 @@ var useTransactionWithIndexer = (options = {}) => {
|
|
|
2627
2692
|
const provex = useOptionalProvex();
|
|
2628
2693
|
const indexer = indexerParam ?? provex?.indexer;
|
|
2629
2694
|
const [phase, setPhase] = react.useState("idle");
|
|
2630
|
-
const publicClient2 =
|
|
2695
|
+
const publicClient2 = useOptionalProvexPublicClient();
|
|
2631
2696
|
const waitForTransaction = react.useCallback(async ({
|
|
2632
2697
|
hash,
|
|
2633
2698
|
chainId,
|
|
@@ -2726,7 +2791,6 @@ exports.ProveXClient = ProveXClient;
|
|
|
2726
2791
|
exports.ProveXError = ProveXError;
|
|
2727
2792
|
exports.ProvexBuy = ProvexBuy;
|
|
2728
2793
|
exports.ProvexBuyProvider = ProvexBuyProvider;
|
|
2729
|
-
exports.ProvexBuyWagmi = ProvexBuyWagmi;
|
|
2730
2794
|
exports.ProvexProvider = ProvexProvider;
|
|
2731
2795
|
exports.ProvingPhase = ProvingPhase;
|
|
2732
2796
|
exports.createApiClient = createApiClient;
|
|
@@ -2738,6 +2802,8 @@ exports.useAllowance = useAllowance;
|
|
|
2738
2802
|
exports.useCancelIntent = useCancelIntent;
|
|
2739
2803
|
exports.useDeposits = useDeposits;
|
|
2740
2804
|
exports.useNullifierRegistry = useNullifierRegistry;
|
|
2805
|
+
exports.useOptionalProvexPublicClient = useOptionalProvexPublicClient;
|
|
2806
|
+
exports.useOptionalProvexWallet = useOptionalProvexWallet;
|
|
2741
2807
|
exports.usePayeeDetails = usePayeeDetails;
|
|
2742
2808
|
exports.useProtocolFeePercentage = useProtocolFeePercentage;
|
|
2743
2809
|
exports.useProtocolFees = useProtocolFees;
|
|
@@ -2745,12 +2811,13 @@ exports.useProveXClient = useProveXClient;
|
|
|
2745
2811
|
exports.useProvex = useProvex;
|
|
2746
2812
|
exports.useProvexBuy = useProvexBuy;
|
|
2747
2813
|
exports.useProvexBuyContext = useProvexBuyContext;
|
|
2814
|
+
exports.useProvexPublicClient = useProvexPublicClient;
|
|
2815
|
+
exports.useProvexWallet = useProvexWallet;
|
|
2748
2816
|
exports.useReleaseFundsToPayer = useReleaseFundsToPayer;
|
|
2749
2817
|
exports.useReputation = useReputation;
|
|
2750
2818
|
exports.useReputationLimits = useReputationLimits;
|
|
2751
2819
|
exports.useSignalIntent = useSignalIntent;
|
|
2752
2820
|
exports.useTransactionWithIndexer = useTransactionWithIndexer;
|
|
2753
2821
|
exports.useV3Escrow = useV3Escrow;
|
|
2754
|
-
exports.useWagmiWallet = useWagmiWallet;
|
|
2755
2822
|
//# sourceMappingURL=index.cjs.map
|
|
2756
2823
|
//# sourceMappingURL=index.cjs.map
|