@provex/react 1.9.2 → 1.10.0-rc.20260912192040.fdbb8fc
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-B51CXrDO.d.cts → ProvexProvider-DY7zWiTb.d.cts} +5 -2
- package/dist/{ProvexProvider-B51CXrDO.d.ts → ProvexProvider-DY7zWiTb.d.ts} +5 -2
- package/dist/{chunk-ORPPRRER.js → chunk-NYG43ZIX.js} +115 -79
- package/dist/chunk-NYG43ZIX.js.map +1 -0
- package/dist/index.cjs +111 -75
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +64 -15
- package/dist/index.d.ts +64 -15
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/wagmi.cjs +110 -74
- package/dist/wagmi.cjs.map +1 -1
- package/dist/wagmi.d.cts +1 -1
- package/dist/wagmi.d.ts +1 -1
- package/dist/wagmi.js +1 -1
- package/package.json +6 -6
- package/dist/chunk-ORPPRRER.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as CreateDepositRawParams, I as IndexerAdapter, P as ProveXClientConfig, a as PaginationOptions, b as PaginatedResult, c as IndexedDeposit, d as IndexedIntent, R as ReputationData, W as WritableMethod, F as FulfillIntentParams, e as CreateDepositParams$1, T as TransactionResult, f as PreparedTransaction, S as SignalIntentParams, g as SignalIntentResult, h as PayeeDetails, M as MakerRegistrationParams, A as AttestationParams, i as AttestationResponse, j as WalletAdapter, U as UseProvexBuyOptions, k as UseProvexBuyReturn, l as PhaseRenderProps, B as BuyProps } from './ProvexProvider-
|
|
2
|
-
export { y as ApiClient, n as BuyPhase, Y as DepositInfo, D as DepositPaymentMethod, a0 as IndexedVerifier, Z as IntentStatus, _ as PayeeInfo, p as PhaseComponentProps, t as ProveXError, v as ProveXErrorCode, m as ProvexConfig, r as ProvexContextValue, q as ProvexProvider, s as ProvexProviderProps, o as ProvexTheme, X as ReputationLimits, V as ReputationLimitsParams, w as SignalIntentRawParams, $ as SignalIntentStatus, x as createApiClient, G as getRate, J as intentStatuses, E as useDeposits, N as useOptionalProvexPublicClient, Q as useOptionalProvexWallet, H as usePayeeDetails, u as useProvex, L as useProvexPublicClient, O as useProvexWallet, z as useReputationLimits, K as useSignalIntent } from './ProvexProvider-
|
|
1
|
+
import { C as CreateDepositRawParams, I as IndexerAdapter, P as ProveXClientConfig, a as PaginationOptions, b as PaginatedResult, c as IndexedDeposit, d as IndexedIntent, R as ReputationData, W as WritableMethod, F as FulfillIntentParams, e as CreateDepositParams$1, T as TransactionResult, f as PreparedTransaction, S as SignalIntentParams, g as SignalIntentResult, h as PayeeDetails, M as MakerRegistrationParams, A as AttestationParams, i as AttestationResponse, j as WalletAdapter, U as UseProvexBuyOptions, k as UseProvexBuyReturn, l as PhaseRenderProps, B as BuyProps } from './ProvexProvider-DY7zWiTb.cjs';
|
|
2
|
+
export { y as ApiClient, n as BuyPhase, Y as DepositInfo, D as DepositPaymentMethod, a0 as IndexedVerifier, Z as IntentStatus, _ as PayeeInfo, p as PhaseComponentProps, t as ProveXError, v as ProveXErrorCode, m as ProvexConfig, r as ProvexContextValue, q as ProvexProvider, s as ProvexProviderProps, o as ProvexTheme, X as ReputationLimits, V as ReputationLimitsParams, w as SignalIntentRawParams, $ as SignalIntentStatus, x as createApiClient, G as getRate, J as intentStatuses, E as useDeposits, N as useOptionalProvexPublicClient, Q as useOptionalProvexWallet, H as usePayeeDetails, u as useProvex, L as useProvexPublicClient, O as useProvexWallet, z as useReputationLimits, K as useSignalIntent } from './ProvexProvider-DY7zWiTb.cjs';
|
|
3
3
|
export { CaptureAdapter, CaptureCandidate, ProvingState } from '@provex/proving';
|
|
4
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
5
|
import * as React from 'react';
|
|
@@ -13,7 +13,7 @@ import { TokenInfo } from '@provex/utils/tokens';
|
|
|
13
13
|
import { Version } from '@provex/utils/contracts';
|
|
14
14
|
import { WriteHookParams } from '@valve-tech/wallet-adapter';
|
|
15
15
|
import * as _tanstack_query_core from '@tanstack/query-core';
|
|
16
|
-
import
|
|
16
|
+
import { UseQueryResult } from '@tanstack/react-query';
|
|
17
17
|
import '@provex/utils/currencies';
|
|
18
18
|
import '@provex/utils';
|
|
19
19
|
|
|
@@ -464,9 +464,49 @@ declare class ProveXClient {
|
|
|
464
464
|
/** Cached orchestrator address (lazy-loaded). */
|
|
465
465
|
private cachedOrchestratorAddress;
|
|
466
466
|
constructor(config: ProveXClientConfig);
|
|
467
|
-
/**
|
|
467
|
+
/**
|
|
468
|
+
* The escrow this client acts on.
|
|
469
|
+
*
|
|
470
|
+
* Callers that touch a specific deposit MUST construct the client with
|
|
471
|
+
* `escrowAddress: deposit.escrow` — the fallback below is only correct for a
|
|
472
|
+
* client that has no deposit in hand, and silently sends every write to the
|
|
473
|
+
* wrong escrow otherwise.
|
|
474
|
+
*
|
|
475
|
+
* That fallback follows the chain's current generation rather than a pinned
|
|
476
|
+
* v3. The only writes that reach it are ones with no existing deposit to
|
|
477
|
+
* name — `createDeposit` above all — and those belong on the generation the
|
|
478
|
+
* protocol is actually running, not the one it has moved off.
|
|
479
|
+
*/
|
|
468
480
|
getEscrowAddress(): Hex;
|
|
469
|
-
/**
|
|
481
|
+
/**
|
|
482
|
+
* The escrow's generation, used to pick the matching interface.
|
|
483
|
+
*
|
|
484
|
+
* An unrecognised address is not an error: callers may point the client at a
|
|
485
|
+
* fork or a local deployment through `escrowAddress`. Those fall back to v3,
|
|
486
|
+
* which is what this client assumed for every escrow before generations were
|
|
487
|
+
* resolved at all — so an override that worked before still works.
|
|
488
|
+
*/
|
|
489
|
+
private getEscrowGeneration;
|
|
490
|
+
/**
|
|
491
|
+
* The escrow interface matching this client's escrow generation.
|
|
492
|
+
*
|
|
493
|
+
* EscrowV2 is not signature-compatible with the v3 escrow for every maker
|
|
494
|
+
* write — `createDeposit`, `addPaymentMethods` and `addCurrencies` each gain
|
|
495
|
+
* an oracle rate config in their currency tuple, which changes the selector.
|
|
496
|
+
* Binding one generation's interface to whatever address we resolved
|
|
497
|
+
* produces a call the contract cannot decode, and since these writes are not
|
|
498
|
+
* simulated the maker signs and pays gas for a certain revert.
|
|
499
|
+
*/
|
|
500
|
+
private getEscrowAbi;
|
|
501
|
+
/**
|
|
502
|
+
* Get the orchestrator address (cached after first read).
|
|
503
|
+
*
|
|
504
|
+
* Generation decides where this comes from. v2 and v3 escrows expose
|
|
505
|
+
* `orchestrator()`; EscrowV2 authorizes through an `OrchestratorRegistry`
|
|
506
|
+
* and exposes no such function, so reading it reverts and the address has to
|
|
507
|
+
* come from configuration. Probing on-chain first would therefore break
|
|
508
|
+
* every v4 flow before the wallet ever opens.
|
|
509
|
+
*/
|
|
470
510
|
getOrchestratorAddress(): Promise<Hex>;
|
|
471
511
|
private requireIndexer;
|
|
472
512
|
getMatchableDeposits(params: {
|
|
@@ -603,7 +643,7 @@ declare class ProveXClient {
|
|
|
603
643
|
prepareCreateDeposit(params: CreateDepositParams$1): Promise<PreparedTransaction>;
|
|
604
644
|
/**
|
|
605
645
|
* Convert human-readable deposit params to raw contract params.
|
|
606
|
-
* Handles
|
|
646
|
+
* Handles rail collapsing, hashing, gating service encoding, and defaults.
|
|
607
647
|
*/
|
|
608
648
|
private buildCreateDepositRawParams;
|
|
609
649
|
readonly cancelIntent: WritableMethod<{
|
|
@@ -727,16 +767,25 @@ declare function createProveXClient(config: ProveXClientConfig): ProveXClient;
|
|
|
727
767
|
declare function useProveXClient(wallet?: WalletAdapter): ProveXClient;
|
|
728
768
|
|
|
729
769
|
/**
|
|
730
|
-
* Resolve the Orchestrator contract address
|
|
770
|
+
* Resolve the Orchestrator contract address for an escrow.
|
|
771
|
+
*
|
|
772
|
+
* **Two escrow generations, two answers.**
|
|
773
|
+
*
|
|
774
|
+
* - v2 / v3 escrows expose `orchestrator()`, so the address is read on-chain.
|
|
775
|
+
* It is governance-static — set once at escrow deployment and never
|
|
776
|
+
* reassigned in practice — so `staleTime: Infinity` makes this a single RPC
|
|
777
|
+
* per session per chain, shared by every consumer (intent flow, fee reads,
|
|
778
|
+
* nullifier resolution, address menu) through the same query cache key.
|
|
779
|
+
* - v4 escrows (EscrowV2) have **no** `orchestrator()` function: they authorize
|
|
780
|
+
* through an `OrchestratorRegistry`, so that call reverts. Their orchestrator
|
|
781
|
+
* is held in configuration and returned here with no network read at all.
|
|
731
782
|
*
|
|
732
|
-
*
|
|
733
|
-
*
|
|
734
|
-
*
|
|
735
|
-
* (intent flow, fee reads, nullifier resolution, address menu) shares
|
|
736
|
-
* via the same TanStack Query cache key.
|
|
783
|
+
* Getting this wrong is silent rather than loud: the read simply fails, `data`
|
|
784
|
+
* stays undefined, and every dependent step (fulfill, payee details, protocol
|
|
785
|
+
* fee display) waits forever on an address that will never arrive.
|
|
737
786
|
*
|
|
738
|
-
* Returns the standard react-query observable shape so callers can
|
|
739
|
-
*
|
|
787
|
+
* Returns the standard react-query observable shape so callers can gate
|
|
788
|
+
* dependent reads on `isLoading` / `data`, whichever branch answered.
|
|
740
789
|
*
|
|
741
790
|
* @param enabled - Additional gate on top of the `!!escrowAddress` guard.
|
|
742
791
|
* Useful when the caller has its own enabled flag (e.g. useProtocolFees).
|
|
@@ -746,7 +795,7 @@ declare function useOrchestratorAddress({ escrowAddress, chainId, enabled, }: {
|
|
|
746
795
|
chainId: number;
|
|
747
796
|
/** Extra enable gate; the hook also guards on `!!escrowAddress`. */
|
|
748
797
|
enabled?: boolean;
|
|
749
|
-
}):
|
|
798
|
+
}): UseQueryResult<Hex, Error>;
|
|
750
799
|
|
|
751
800
|
/**
|
|
752
801
|
* @fileoverview useProvexBuy — headless state machine for the buy flow.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as CreateDepositRawParams, I as IndexerAdapter, P as ProveXClientConfig, a as PaginationOptions, b as PaginatedResult, c as IndexedDeposit, d as IndexedIntent, R as ReputationData, W as WritableMethod, F as FulfillIntentParams, e as CreateDepositParams$1, T as TransactionResult, f as PreparedTransaction, S as SignalIntentParams, g as SignalIntentResult, h as PayeeDetails, M as MakerRegistrationParams, A as AttestationParams, i as AttestationResponse, j as WalletAdapter, U as UseProvexBuyOptions, k as UseProvexBuyReturn, l as PhaseRenderProps, B as BuyProps } from './ProvexProvider-
|
|
2
|
-
export { y as ApiClient, n as BuyPhase, Y as DepositInfo, D as DepositPaymentMethod, a0 as IndexedVerifier, Z as IntentStatus, _ as PayeeInfo, p as PhaseComponentProps, t as ProveXError, v as ProveXErrorCode, m as ProvexConfig, r as ProvexContextValue, q as ProvexProvider, s as ProvexProviderProps, o as ProvexTheme, X as ReputationLimits, V as ReputationLimitsParams, w as SignalIntentRawParams, $ as SignalIntentStatus, x as createApiClient, G as getRate, J as intentStatuses, E as useDeposits, N as useOptionalProvexPublicClient, Q as useOptionalProvexWallet, H as usePayeeDetails, u as useProvex, L as useProvexPublicClient, O as useProvexWallet, z as useReputationLimits, K as useSignalIntent } from './ProvexProvider-
|
|
1
|
+
import { C as CreateDepositRawParams, I as IndexerAdapter, P as ProveXClientConfig, a as PaginationOptions, b as PaginatedResult, c as IndexedDeposit, d as IndexedIntent, R as ReputationData, W as WritableMethod, F as FulfillIntentParams, e as CreateDepositParams$1, T as TransactionResult, f as PreparedTransaction, S as SignalIntentParams, g as SignalIntentResult, h as PayeeDetails, M as MakerRegistrationParams, A as AttestationParams, i as AttestationResponse, j as WalletAdapter, U as UseProvexBuyOptions, k as UseProvexBuyReturn, l as PhaseRenderProps, B as BuyProps } from './ProvexProvider-DY7zWiTb.js';
|
|
2
|
+
export { y as ApiClient, n as BuyPhase, Y as DepositInfo, D as DepositPaymentMethod, a0 as IndexedVerifier, Z as IntentStatus, _ as PayeeInfo, p as PhaseComponentProps, t as ProveXError, v as ProveXErrorCode, m as ProvexConfig, r as ProvexContextValue, q as ProvexProvider, s as ProvexProviderProps, o as ProvexTheme, X as ReputationLimits, V as ReputationLimitsParams, w as SignalIntentRawParams, $ as SignalIntentStatus, x as createApiClient, G as getRate, J as intentStatuses, E as useDeposits, N as useOptionalProvexPublicClient, Q as useOptionalProvexWallet, H as usePayeeDetails, u as useProvex, L as useProvexPublicClient, O as useProvexWallet, z as useReputationLimits, K as useSignalIntent } from './ProvexProvider-DY7zWiTb.js';
|
|
3
3
|
export { CaptureAdapter, CaptureCandidate, ProvingState } from '@provex/proving';
|
|
4
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
5
|
import * as React from 'react';
|
|
@@ -13,7 +13,7 @@ import { TokenInfo } from '@provex/utils/tokens';
|
|
|
13
13
|
import { Version } from '@provex/utils/contracts';
|
|
14
14
|
import { WriteHookParams } from '@valve-tech/wallet-adapter';
|
|
15
15
|
import * as _tanstack_query_core from '@tanstack/query-core';
|
|
16
|
-
import
|
|
16
|
+
import { UseQueryResult } from '@tanstack/react-query';
|
|
17
17
|
import '@provex/utils/currencies';
|
|
18
18
|
import '@provex/utils';
|
|
19
19
|
|
|
@@ -464,9 +464,49 @@ declare class ProveXClient {
|
|
|
464
464
|
/** Cached orchestrator address (lazy-loaded). */
|
|
465
465
|
private cachedOrchestratorAddress;
|
|
466
466
|
constructor(config: ProveXClientConfig);
|
|
467
|
-
/**
|
|
467
|
+
/**
|
|
468
|
+
* The escrow this client acts on.
|
|
469
|
+
*
|
|
470
|
+
* Callers that touch a specific deposit MUST construct the client with
|
|
471
|
+
* `escrowAddress: deposit.escrow` — the fallback below is only correct for a
|
|
472
|
+
* client that has no deposit in hand, and silently sends every write to the
|
|
473
|
+
* wrong escrow otherwise.
|
|
474
|
+
*
|
|
475
|
+
* That fallback follows the chain's current generation rather than a pinned
|
|
476
|
+
* v3. The only writes that reach it are ones with no existing deposit to
|
|
477
|
+
* name — `createDeposit` above all — and those belong on the generation the
|
|
478
|
+
* protocol is actually running, not the one it has moved off.
|
|
479
|
+
*/
|
|
468
480
|
getEscrowAddress(): Hex;
|
|
469
|
-
/**
|
|
481
|
+
/**
|
|
482
|
+
* The escrow's generation, used to pick the matching interface.
|
|
483
|
+
*
|
|
484
|
+
* An unrecognised address is not an error: callers may point the client at a
|
|
485
|
+
* fork or a local deployment through `escrowAddress`. Those fall back to v3,
|
|
486
|
+
* which is what this client assumed for every escrow before generations were
|
|
487
|
+
* resolved at all — so an override that worked before still works.
|
|
488
|
+
*/
|
|
489
|
+
private getEscrowGeneration;
|
|
490
|
+
/**
|
|
491
|
+
* The escrow interface matching this client's escrow generation.
|
|
492
|
+
*
|
|
493
|
+
* EscrowV2 is not signature-compatible with the v3 escrow for every maker
|
|
494
|
+
* write — `createDeposit`, `addPaymentMethods` and `addCurrencies` each gain
|
|
495
|
+
* an oracle rate config in their currency tuple, which changes the selector.
|
|
496
|
+
* Binding one generation's interface to whatever address we resolved
|
|
497
|
+
* produces a call the contract cannot decode, and since these writes are not
|
|
498
|
+
* simulated the maker signs and pays gas for a certain revert.
|
|
499
|
+
*/
|
|
500
|
+
private getEscrowAbi;
|
|
501
|
+
/**
|
|
502
|
+
* Get the orchestrator address (cached after first read).
|
|
503
|
+
*
|
|
504
|
+
* Generation decides where this comes from. v2 and v3 escrows expose
|
|
505
|
+
* `orchestrator()`; EscrowV2 authorizes through an `OrchestratorRegistry`
|
|
506
|
+
* and exposes no such function, so reading it reverts and the address has to
|
|
507
|
+
* come from configuration. Probing on-chain first would therefore break
|
|
508
|
+
* every v4 flow before the wallet ever opens.
|
|
509
|
+
*/
|
|
470
510
|
getOrchestratorAddress(): Promise<Hex>;
|
|
471
511
|
private requireIndexer;
|
|
472
512
|
getMatchableDeposits(params: {
|
|
@@ -603,7 +643,7 @@ declare class ProveXClient {
|
|
|
603
643
|
prepareCreateDeposit(params: CreateDepositParams$1): Promise<PreparedTransaction>;
|
|
604
644
|
/**
|
|
605
645
|
* Convert human-readable deposit params to raw contract params.
|
|
606
|
-
* Handles
|
|
646
|
+
* Handles rail collapsing, hashing, gating service encoding, and defaults.
|
|
607
647
|
*/
|
|
608
648
|
private buildCreateDepositRawParams;
|
|
609
649
|
readonly cancelIntent: WritableMethod<{
|
|
@@ -727,16 +767,25 @@ declare function createProveXClient(config: ProveXClientConfig): ProveXClient;
|
|
|
727
767
|
declare function useProveXClient(wallet?: WalletAdapter): ProveXClient;
|
|
728
768
|
|
|
729
769
|
/**
|
|
730
|
-
* Resolve the Orchestrator contract address
|
|
770
|
+
* Resolve the Orchestrator contract address for an escrow.
|
|
771
|
+
*
|
|
772
|
+
* **Two escrow generations, two answers.**
|
|
773
|
+
*
|
|
774
|
+
* - v2 / v3 escrows expose `orchestrator()`, so the address is read on-chain.
|
|
775
|
+
* It is governance-static — set once at escrow deployment and never
|
|
776
|
+
* reassigned in practice — so `staleTime: Infinity` makes this a single RPC
|
|
777
|
+
* per session per chain, shared by every consumer (intent flow, fee reads,
|
|
778
|
+
* nullifier resolution, address menu) through the same query cache key.
|
|
779
|
+
* - v4 escrows (EscrowV2) have **no** `orchestrator()` function: they authorize
|
|
780
|
+
* through an `OrchestratorRegistry`, so that call reverts. Their orchestrator
|
|
781
|
+
* is held in configuration and returned here with no network read at all.
|
|
731
782
|
*
|
|
732
|
-
*
|
|
733
|
-
*
|
|
734
|
-
*
|
|
735
|
-
* (intent flow, fee reads, nullifier resolution, address menu) shares
|
|
736
|
-
* via the same TanStack Query cache key.
|
|
783
|
+
* Getting this wrong is silent rather than loud: the read simply fails, `data`
|
|
784
|
+
* stays undefined, and every dependent step (fulfill, payee details, protocol
|
|
785
|
+
* fee display) waits forever on an address that will never arrive.
|
|
737
786
|
*
|
|
738
|
-
* Returns the standard react-query observable shape so callers can
|
|
739
|
-
*
|
|
787
|
+
* Returns the standard react-query observable shape so callers can gate
|
|
788
|
+
* dependent reads on `isLoading` / `data`, whichever branch answered.
|
|
740
789
|
*
|
|
741
790
|
* @param enabled - Additional gate on top of the `!!escrowAddress` guard.
|
|
742
791
|
* Useful when the caller has its own enabled flag (e.g. useProtocolFees).
|
|
@@ -746,7 +795,7 @@ declare function useOrchestratorAddress({ escrowAddress, chainId, enabled, }: {
|
|
|
746
795
|
chainId: number;
|
|
747
796
|
/** Extra enable gate; the hook also guards on `!!escrowAddress`. */
|
|
748
797
|
enabled?: boolean;
|
|
749
|
-
}):
|
|
798
|
+
}): UseQueryResult<Hex, Error>;
|
|
750
799
|
|
|
751
800
|
/**
|
|
752
801
|
* @fileoverview useProvexBuy — headless state machine for the buy flow.
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { useOptionalProvexPublicClient, useOptionalProvexWallet, useContractRead, getTransactionGasInputs, useOptionalProvex, createProveXClient, checkTransactionIndexed, ProveXError, isUserRejectionError, getUserFriendlyErrorMessage, useOrchestratorAddress, checkMutation } from './chunk-
|
|
2
|
-
export { BrowsePhase, CommittedPhase, CompletePhase, ProveXClient, ProveXError, ProvexBuy, ProvexBuyProvider, ProvexProvider, ProvingPhase, createApiClient, createProveXClient, getRate, getTierDisplayInfo, intentStatuses, useDeposits, useNullifierRegistry, useOptionalProvexPublicClient, useOptionalProvexWallet, useOrchestratorAddress, usePayeeDetails, useProtocolFeePercentage, useProtocolFees, useProveXClient, useProvex, useProvexBuy, useProvexBuyContext, useProvexPublicClient, useProvexWallet, useReputation, useReputationLimits, useSignalIntent } from './chunk-
|
|
1
|
+
import { useOptionalProvexPublicClient, useOptionalProvexWallet, useContractRead, getTransactionGasInputs, useOptionalProvex, createProveXClient, checkTransactionIndexed, ProveXError, isUserRejectionError, getUserFriendlyErrorMessage, useOrchestratorAddress, checkMutation } from './chunk-NYG43ZIX.js';
|
|
2
|
+
export { BrowsePhase, CommittedPhase, CompletePhase, ProveXClient, ProveXError, ProvexBuy, ProvexBuyProvider, ProvexProvider, ProvingPhase, createApiClient, createProveXClient, getRate, getTierDisplayInfo, intentStatuses, useDeposits, useNullifierRegistry, useOptionalProvexPublicClient, useOptionalProvexWallet, useOrchestratorAddress, usePayeeDetails, useProtocolFeePercentage, useProtocolFees, useProveXClient, useProvex, useProvexBuy, useProvexBuyContext, useProvexPublicClient, useProvexWallet, useReputation, useReputationLimits, useSignalIntent } from './chunk-NYG43ZIX.js';
|
|
3
3
|
import { useMemo, useState, useCallback } from 'react';
|
|
4
4
|
import { maxUint256, erc20Abi, encodeFunctionData } from 'viem';
|
|
5
5
|
import { V2EscrowAbi, V3EscrowAbi } from '@provex/abis';
|
|
6
|
-
import { getEscrowVersion, getLatestContract, supportsOrchestrator } from '@provex/utils/contracts';
|
|
6
|
+
import { getEscrowVersion, getLatestContract, supportsOrchestrator, getLatestConfiguredVersion } from '@provex/utils/contracts';
|
|
7
7
|
import { orderId } from '@provex/utils/ids';
|
|
8
8
|
|
|
9
9
|
var useAllowance = ({
|
|
@@ -282,7 +282,7 @@ var useV3Escrow = ({
|
|
|
282
282
|
const escrow = useMemo(() => {
|
|
283
283
|
if (escrowAddress) return escrowAddress;
|
|
284
284
|
if (!chainId) return null;
|
|
285
|
-
return getLatestContract(chainId, "escrow",
|
|
285
|
+
return getLatestContract(chainId, "escrow", getLatestConfiguredVersion(chainId));
|
|
286
286
|
}, [chainId, escrowAddress]);
|
|
287
287
|
const isLoading = useMemo(
|
|
288
288
|
() => status === "prompt_wallet_confirm" || status === "writing_tx" || status === "confirming" || status === "syncing",
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/useAllowance.ts","../src/hooks/useCancelIntent.ts","../src/hooks/useReleaseFundsToPayer.ts","../src/hooks/useV3Escrow.ts","../src/hooks/useTransactionWithIndexer.ts"],"names":["useState","useMemo","encodeFunctionData","escrowAbi","getEscrowVersion","getLatestContract","supportsOrchestrator","useCallback","v3EscrowAbi"],"mappings":";;;;;;;;AA4BO,IAAM,eAAe,CAAC;AAAA,EAC3B,KAAA;AAAA,EACA,OAAA;AAAA,EACA,OAAA;AAAA,EACA,OAAA;AAAA,EACA,gBAAA,GAAmB,KAAA;AAAA,EACnB,SAAA;AAAA,EACA,OAAA;AAAA,EACA;AACF,CAAA,KAUM;AAC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AAAA,MACH;AAEA,MAAA,QAAA,CAAS,UAAU,CAAA;AACnB,MAAA,sBAAA,GAAyB,EAAE,IAAA,EAAM,OAAA,EAAS,MAAA,EAAQ,CAAA;AAClD,MAAA,SAAA,IAAY;AAAA,IACd,SAAS,CAAA,EAAG;AACV,MAAA,QAAA,CAAS,OAAO,CAAA;AAChB,MAAA,MAAM,KAAA,GAAQ,aAAa,KAAA,GAAQ,CAAA,GAAI,IAAI,KAAA,CAAM,MAAA,CAAO,CAAC,CAAC,CAAA;AAC1D,MAAA,kBAAA,GAAqB,2BAAA,CAA4B,KAAK,CAAC,CAAA;AACvD,MAAA,OAAA,GAAU,KAAK,CAAA;AACf,MAAA,MAAM,CAAA;AAAA,IACR;AAAA,EACF,CAAA,EAAG,CAAC,YAAA,EAAc,OAAA,EAAS,WAAW,OAAA,EAAS,UAAA,EAAY,sBAAA,EAAwB,kBAAkB,CAAC,CAAA;AAEtG,EAAA,MAAM,KAAA,GAAQE,YAAY,MAAM;AAC9B,IAAA,QAAA,CAAS,MAAM,CAAA;AAAA,EACjB,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,MAAM,SAAA,GAAY,KAAA,KAAU,YAAA,IAAgB,KAAA,KAAU,gBAAgB,KAAA,KAAU,SAAA;AAEhF,EAAA,MAAM,cAAc,KAAA,KAAU,SAAA,GAC1B,YAAA,GACA,KAAA,KAAU,eACR,eAAA,GACA,MAAA;AAEN,EAAA,OAAO;AAAA,IACL,KAAA;AAAA,IACA,SAAA;AAAA,IACA,WAAA;AAAA,IACA,kBAAA;AAAA,IACA,eAAA;AAAA,IACA,KAAA;AAAA,IACA;AAAA,GACF;AACF","file":"index.js","sourcesContent":["/**\n * @fileoverview Hook for ERC20 token allowance checking and approval.\n *\n * Handles the common pattern of checking if a spender (escrow contract)\n * has sufficient allowance to transfer tokens, and prompting for approval\n * if needed.\n *\n * @remarks\n * Approval is required before createDeposit or addFunds can transfer\n * tokens to the escrow contract.\n *\n * Reads use the `publicClient` registered on `ProvexProvider` (auto-built\n * from `config.chain` if not supplied). Writes require a `wallet` on the\n * same provider.\n */\n\nimport { useMemo, useState } from \"react\"\nimport { encodeFunctionData, erc20Abi, maxUint256, type Hex } from \"viem\"\nimport { useContractRead } from \"../lib/contractRead\"\nimport { useOptionalProvexPublicClient, useOptionalProvexWallet } from \"../ProvexProvider\"\nimport { getTransactionGasInputs } from \"../lib/block\"\nimport type { TokenInfo } from \"@provex/utils/tokens\"\n\n/**\n * Phase of the approval transaction lifecycle.\n */\ntype ApprovalPhase = 'idle' | 'submitting' | 'confirming'\n\nexport const useAllowance = ({\n token,\n spender,\n account,\n balance,\n defaultAllowance = 'max',\n onSuccess,\n onError,\n onSettled,\n}: {\n token: TokenInfo\n spender: Hex\n /** The account address to check/write allowance for. If undefined, hook returns null allowance and writeApproval is a no-op. */\n account: Hex | undefined\n balance?: bigint\n defaultAllowance?: 'max' | 'balance'\n onSuccess?: (...args: unknown[]) => void\n onError?: (...args: unknown[]) => void\n onSettled?: (...args: unknown[]) => void\n}) => {\n const targetAllowance = useMemo(() => {\n if (defaultAllowance === 'balance' && balance) {\n return balance\n }\n return maxUint256\n }, [defaultAllowance, balance])\n\n const publicClient = useOptionalProvexPublicClient(token.chainId)\n const wallet = useOptionalProvexWallet()\n\n const { data, isLoading, error, refetch } = useContractRead<bigint>({\n address: token.address as Hex,\n abi: erc20Abi,\n functionName: 'allowance',\n args: account && spender ? [account, spender] : undefined,\n chainId: token.chainId,\n query: {\n enabled: !!account && !!spender && !!token.address,\n },\n })\n\n const [approvalPhase, setApprovalPhase] = useState<ApprovalPhase>('idle')\n const isWritingApproval = approvalPhase !== 'idle'\n const approvalLoadingText = approvalPhase === 'confirming' ? 'Confirming...' : `Approve ${token.symbol}`\n\n return {\n allowance: data ?? null,\n isLoading,\n isWritingApproval,\n /** Loading text for the approval button */\n approvalLoadingText,\n error,\n writeApproval: async () => {\n if (!account || !spender || !token.address || !publicClient || !wallet) {\n return\n }\n setApprovalPhase('submitting')\n try {\n const gasInputs = await getTransactionGasInputs(token.chainId)\n const callData = encodeFunctionData({\n abi: erc20Abi,\n functionName: 'approve',\n args: [spender, targetAllowance],\n })\n const hash = await wallet.sendTransaction({\n to: token.address as Hex,\n data: callData,\n value: 0n,\n chainId: token.chainId,\n maxFeePerGas: gasInputs.maxFeePerGas,\n maxPriorityFeePerGas: gasInputs.maxPriorityFeePerGas,\n })\n\n setApprovalPhase('confirming')\n await publicClient.waitForTransactionReceipt({ hash })\n await refetch()\n onSuccess?.(hash)\n } catch (err) {\n onError?.(err as Error)\n } finally {\n setApprovalPhase('idle')\n onSettled?.()\n }\n },\n }\n}\n","/**\n * @fileoverview Hook for canceling an active intent.\n *\n * v3 / v4 (orchestrator generations): delegate to ProveXClient.cancelIntent,\n * which targets the Orchestrator where cancelIntent lives.\n * v2 (legacy monolith): fall back to a direct viem transaction via\n * WalletAdapter, because on v2 cancelIntent lives on the Escrow itself.\n */\n\nimport { useState, useMemo, useCallback } from 'react'\nimport { encodeFunctionData, type Hex } from 'viem'\nimport { V2EscrowAbi as escrowAbi } from '@provex/abis'\nimport { getLatestContract, getEscrowVersion, supportsOrchestrator, type Version } from '@provex/utils/contracts'\nimport type { ChainId } from '@provex/utils/chain'\nimport { getTransactionGasInputs } from '../lib/block'\nimport { checkTransactionIndexed } from '../lib/updates'\nimport { useOptionalProvex, useOptionalProvexPublicClient, useOptionalProvexWallet } from '../ProvexProvider'\nimport { getUserFriendlyErrorMessage, isUserRejectionError } from '../lib/errors'\nimport { createProveXClient } from '../client/ProveXClient'\nimport { ProveXError, type WriteHookParams } from '../client/types'\n\n/** Status values for the cancel intent operation. */\nexport type CancelIntentStatus =\n | 'idle'\n | 'prompt_wallet_confirm'\n | 'writing_tx'\n | 'success'\n | 'error'\n\n/**\n * Hook to cancel an intent with automatic v2/v3 version detection.\n *\n * V3 delegates to ProveXClient. V2 falls back to a direct WalletAdapter\n * call. Both paths source the wallet + public client from ProvexProvider.\n */\nexport const useCancelIntent = ({\n onSuccess,\n onMutate,\n onError,\n onSettled,\n chainId,\n escrowAddress: providedEscrowAddress,\n version: explicitVersion,\n}: {\n onSuccess?: () => void\n onMutate?: () => void\n onError?: (error: Error) => void\n onSettled?: () => void\n chainId?: ChainId | null | undefined\n escrowAddress?: Hex | null | undefined\n version?: Version\n}) => {\n const provex = useOptionalProvex()\n const wallet = useOptionalProvexWallet()\n const publicClient = useOptionalProvexPublicClient(chainId ?? undefined)\n const [status, setStatus] = useState<CancelIntentStatus>('idle')\n const [errorMessage, setErrorMessage] = useState<string | null>(null)\n const isLoading = useMemo(() => status === 'prompt_wallet_confirm' || status === 'writing_tx', [status])\n\n const version = useMemo(() => {\n if (explicitVersion) return explicitVersion\n if (providedEscrowAddress) {\n const detected = getEscrowVersion(providedEscrowAddress)\n if (detected) return detected\n }\n return 'v3' as Version\n }, [explicitVersion, providedEscrowAddress])\n\n const escrowAddress = useMemo(() => {\n if (providedEscrowAddress) return providedEscrowAddress\n if (!chainId) return null\n return getLatestContract(chainId, 'escrow', version)\n }, [providedEscrowAddress, chainId, version])\n\n // Orchestrator client (memoized) — built for v3 and every newer generation.\n const client = useMemo(() => {\n if (!provex || !chainId || !supportsOrchestrator(version)) return null\n return createProveXClient({\n chain: provex.config.chain,\n apiUrl: provex.config.apiUrl,\n wallet,\n indexer: provex.indexer,\n escrowAddress: escrowAddress ?? undefined,\n })\n }, [provex, chainId, version, wallet, escrowAddress])\n\n const cancelIntent = useCallback(async (intentHash: Hex, hooks?: WriteHookParams) => {\n if (!intentHash || !chainId) return\n\n setStatus('prompt_wallet_confirm')\n setErrorMessage(null)\n onMutate?.()\n\n try {\n if (supportsOrchestrator(version) && client) {\n // v3 / v4: delegate to ProveXClient (targets the Orchestrator)\n await client.cancelIntent({ intentHash, ...hooks })\n } else {\n // v2: direct wallet call via WalletAdapter (cancelIntent on the Escrow)\n if (!escrowAddress) throw new Error('Missing escrow address')\n if (!wallet) throw new Error('No wallet configured on ProvexProvider')\n const gasInputs = await getTransactionGasInputs(chainId)\n const data = encodeFunctionData({\n abi: escrowAbi,\n functionName: 'cancelIntent',\n args: [intentHash],\n })\n const request = {\n to: escrowAddress,\n data,\n value: 0n,\n chainId,\n maxFeePerGas: gasInputs.maxFeePerGas,\n maxPriorityFeePerGas: gasInputs.maxPriorityFeePerGas,\n }\n const ctx = { chainId, request }\n hooks?.onAwaitingSignature?.(ctx)\n const hash = await wallet.sendTransaction(request)\n hooks?.onTransactionHash?.({ ...ctx, hash })\n if (publicClient) await publicClient.waitForTransactionReceipt({ hash })\n if (provex?.indexer) {\n await checkTransactionIndexed({ queryTransaction: provex.indexer.getTransactionByHash, hash })\n }\n }\n\n setStatus('success')\n onSuccess?.()\n } catch (error) {\n // V3 path's client fires onFailed internally with full TxContext;\n // V2 path errors before request construction can't synthesize one.\n // The outer wrapper deliberately doesn't double-fire.\n const isRejection = (error instanceof ProveXError && error.isRejection) || isUserRejectionError(error)\n if (isRejection) {\n setStatus('idle')\n } else {\n setStatus('error')\n setErrorMessage(getUserFriendlyErrorMessage(error))\n }\n onError?.(error as Error)\n } finally {\n onSettled?.()\n }\n }, [chainId, escrowAddress, version, client, publicClient, wallet, provex, onSuccess, onMutate, onError, onSettled])\n\n return {\n cancelIntent,\n status,\n isLoading,\n version,\n errorMessage,\n }\n}\n","/**\n * @fileoverview Hook for releasing funds back to payer.\n *\n * v3 / v4 (orchestrator generations): delegate to\n * ProveXClient.releaseFundsToPayer, which targets the Orchestrator.\n * v2 (legacy monolith): fall back to a direct viem transaction via\n * WalletAdapter, because on v2 releaseFundsToPayer lives on the Escrow.\n */\n\nimport { useState, useMemo, useCallback } from 'react'\nimport { encodeFunctionData, type Hex } from 'viem'\nimport { V2EscrowAbi as escrowAbi } from '@provex/abis'\nimport { getLatestContract, getEscrowVersion, supportsOrchestrator, type Version } from '@provex/utils/contracts'\nimport type { ChainId } from '@provex/utils/chain'\nimport { getTransactionGasInputs } from '../lib/block'\nimport { checkTransactionIndexed } from '../lib/updates'\nimport { useOptionalProvex, useOptionalProvexPublicClient, useOptionalProvexWallet } from '../ProvexProvider'\nimport { isUserRejectionError } from '../lib/errors'\nimport { createProveXClient } from '../client/ProveXClient'\nimport { ProveXError, type WriteHookParams } from '../client/types'\n\n/** Status values for the release funds operation. */\nexport type ReleaseFundsStatus =\n | 'idle'\n | 'prompt_wallet_confirm'\n | 'writing_tx'\n | 'success'\n | 'error'\n\n/**\n * Hook to release funds back to payer with automatic v2/v3 version detection.\n *\n * V3 delegates to ProveXClient. V2 falls back to a direct WalletAdapter\n * call. Both paths source the wallet + public client from ProvexProvider.\n */\nexport const useReleaseFundsToPayer = ({\n onSuccess,\n onSettled,\n chainId,\n escrowAddress: providedEscrowAddress,\n version: explicitVersion,\n}: {\n onSuccess?: () => void\n onSettled?: () => void\n chainId?: ChainId | null | undefined\n escrowAddress?: Hex | null | undefined\n version?: Version\n}) => {\n const provex = useOptionalProvex()\n const wallet = useOptionalProvexWallet()\n const publicClient = useOptionalProvexPublicClient(chainId ?? undefined)\n const [status, setStatus] = useState<ReleaseFundsStatus>('idle')\n const [errorMessage, setErrorMessage] = useState<string | null>(null)\n const isLoading = useMemo(\n () => status === 'prompt_wallet_confirm' || status === 'writing_tx',\n [status]\n )\n\n const version = useMemo(() => {\n if (explicitVersion) return explicitVersion\n if (providedEscrowAddress) {\n const detected = getEscrowVersion(providedEscrowAddress)\n if (detected) return detected\n }\n return 'v3' as Version\n }, [explicitVersion, providedEscrowAddress])\n\n const escrowAddress = useMemo(() => {\n if (providedEscrowAddress) return providedEscrowAddress\n if (!chainId) return null\n return getLatestContract(chainId, 'escrow', version)\n }, [providedEscrowAddress, chainId, version])\n\n // Orchestrator client — built for v3 and every newer generation.\n const client = useMemo(() => {\n if (!provex || !chainId || !supportsOrchestrator(version)) return null\n return createProveXClient({\n chain: provex.config.chain,\n apiUrl: provex.config.apiUrl,\n wallet,\n indexer: provex.indexer,\n escrowAddress: escrowAddress ?? undefined,\n })\n }, [provex, chainId, version, wallet, escrowAddress])\n\n const releaseFundsToPayer = useCallback(async (intentHash: Hex, hooks?: WriteHookParams) => {\n if (!intentHash || !chainId) return\n\n setStatus('prompt_wallet_confirm')\n setErrorMessage(null)\n\n try {\n if (supportsOrchestrator(version) && client) {\n // v3 / v4: delegate to ProveXClient (targets the Orchestrator)\n await client.releaseFundsToPayer({ intentHash, ...hooks })\n } else {\n // v2: direct wallet call via WalletAdapter (function on the Escrow)\n if (!escrowAddress) throw new Error('Missing escrow address')\n if (!wallet) throw new Error('No wallet configured on ProvexProvider')\n const gasInputs = await getTransactionGasInputs(chainId)\n const data = encodeFunctionData({\n abi: escrowAbi,\n functionName: 'releaseFundsToPayer',\n args: [intentHash],\n })\n const request = {\n to: escrowAddress,\n data,\n value: 0n,\n chainId,\n maxFeePerGas: gasInputs.maxFeePerGas,\n maxPriorityFeePerGas: gasInputs.maxPriorityFeePerGas,\n }\n const ctx = { chainId, request }\n hooks?.onAwaitingSignature?.(ctx)\n const hash = await wallet.sendTransaction(request)\n hooks?.onTransactionHash?.({ ...ctx, hash })\n if (publicClient) await publicClient.waitForTransactionReceipt({ hash })\n if (provex?.indexer) {\n await checkTransactionIndexed({ queryTransaction: provex.indexer.getTransactionByHash, hash })\n }\n }\n\n setStatus('success')\n onSuccess?.()\n } catch (error) {\n // V3 path's client already fires onFailed with full TxContext from\n // inside the SDK; no need to double-fire here. V2 path errors that\n // surface before request construction (gasInputs/encoding/connection)\n // also can't synthesize a meaningful request, so the outer onFailed\n // call is intentionally dropped — the per-call hook is best-effort\n // for the SDK-managed window, not the entire wrapper.\n const isRejection = (error instanceof ProveXError && error.isRejection) || isUserRejectionError(error)\n if (isRejection) {\n setStatus('idle')\n setErrorMessage(null)\n } else {\n setStatus('error')\n setErrorMessage(error instanceof Error ? error.message : 'Transaction failed')\n }\n } finally {\n onSettled?.()\n }\n }, [chainId, escrowAddress, version, client, publicClient, wallet, provex, onSuccess, onSettled])\n\n return {\n releaseFundsToPayer,\n status,\n isLoading,\n errorMessage,\n version,\n }\n}\n","/**\n * @fileoverview React hook for V3 Escrow contract interactions.\n *\n * Thin state wrapper around ProveXClient — manages status, error,\n * and loading state for each escrow write operation.\n *\n * Reads (orchestrator address, deposit counter) use the viem public\n * client from ProvexProvider for automatic cache invalidation.\n */\n\nimport { useState, useMemo, useCallback } from 'react'\nimport type { Hex } from 'viem'\nimport { useContractRead } from '../lib/contractRead'\nimport { V3EscrowAbi as v3EscrowAbi } from '@provex/abis'\nimport { useOrchestratorAddress } from './useOrchestratorAddress'\nimport { getLatestContract } from '@provex/utils/contracts'\nimport type { ChainId } from '@provex/utils/chain'\nimport { useOptionalProvex, useOptionalProvexWallet } from '../ProvexProvider'\nimport { createProveXClient } from '../client/ProveXClient'\nimport { ProveXError, type TransactionResult, type WriteHookParams } from '../client/types'\nimport type { CreateDepositRawParams } from '../client/types'\n\n/**\n * Status values for escrow write operations.\n */\nexport type V3EscrowStatus =\n | 'idle'\n | 'prompt_wallet_confirm'\n | 'writing_tx'\n | 'confirming'\n | 'syncing'\n | 'success'\n | 'error'\n\n/** @deprecated Use `CreateDepositRawParams` from `@provex/react/client/types`. */\nexport type CreateDepositParams = CreateDepositRawParams\n\n/**\n * Hook for interacting with v3 Escrow contract.\n *\n * All write methods delegate to ProveXClient. Reads use the\n * ProvexProvider's public client with tanstack-query caching.\n */\nexport const useV3Escrow = ({\n chainId,\n escrowAddress,\n onSlowSync,\n onTransactionConfirmed,\n onError,\n}: {\n chainId?: ChainId | null\n escrowAddress?: Hex | null\n /** Called when indexer sync is taking longer than expected. */\n onSlowSync?: () => void\n /** Called after the transaction is confirmed on-chain. */\n onTransactionConfirmed?: (params: { hash: Hex; chainId: ChainId; action: string }) => void\n /** Called when a write method fails (contract revert, gas issues, etc). Not called on user rejection. */\n onError?: (error: Error) => void\n}) => {\n const provex = useOptionalProvex()\n const wallet = useOptionalProvexWallet()\n const [status, setStatus] = useState<V3EscrowStatus>('idle')\n const [error, setError] = useState<string | null>(null)\n const [txHash, setTxHash] = useState<Hex | null>(null)\n\n const escrow = useMemo(() => {\n if (escrowAddress) return escrowAddress\n if (!chainId) return null\n return getLatestContract(chainId, 'escrow', 'v3')\n }, [chainId, escrowAddress])\n\n const isLoading = useMemo(\n () =>\n status === 'prompt_wallet_confirm' ||\n status === 'writing_tx' ||\n status === 'confirming' ||\n status === 'syncing',\n [status]\n )\n\n // Memoized client — recreated when wallet or config changes\n const client = useMemo(() => {\n if (!provex || !chainId) return null\n return createProveXClient({\n chain: provex.config.chain,\n apiUrl: provex.config.apiUrl,\n wallet,\n indexer: provex.indexer,\n escrowAddress: escrow ?? undefined,\n onTransactionHash: (hash) => {\n setTxHash(hash)\n setStatus('confirming')\n },\n onSlowSync: () => {\n setStatus('syncing')\n onSlowSync?.()\n },\n })\n }, [provex, chainId, wallet, escrow, onSlowSync])\n\n // ─── Reads (viem via ProvexProvider) ──────────────────────────────────────\n\n const { data: orchestratorAddress, refetch: refetchOrchestrator } = useOrchestratorAddress({\n escrowAddress: escrow ?? undefined,\n chainId: chainId ?? 0,\n })\n\n const { data: depositCounter, refetch: refetchDepositCounter } = useContractRead<bigint>({\n address: escrow ?? undefined,\n abi: v3EscrowAbi,\n functionName: 'depositCounter',\n chainId: chainId ?? undefined,\n query: { enabled: !!escrow },\n })\n\n // ─── Generic write executor ───────────────────────────────────────────────\n\n const executeClientMethod = useCallback(async <T extends TransactionResult>(\n method: () => Promise<T>,\n action: string,\n ): Promise<Hex | null> => {\n if (!client || !chainId) {\n const msg = 'Client or chain not configured'\n setError(msg)\n onError?.(new Error(msg))\n return null\n }\n\n try {\n setStatus('prompt_wallet_confirm')\n setError(null)\n setTxHash(null)\n\n const result = await method()\n\n setStatus('success')\n onTransactionConfirmed?.({ hash: result.hash, chainId, action })\n return result.hash\n } catch (err) {\n // ProveXClient fires onFailed internally with full TxContext (chainId,\n // request, error). The outer wrapper here used to double-fire with\n // just an Error — drop it so consumers receive one well-formed event.\n if (err instanceof ProveXError && err.isRejection) {\n setStatus('idle')\n setError(null)\n return null\n }\n const errorObj = err instanceof Error ? err : new Error(String(err))\n setStatus('error')\n setError(errorObj.message)\n onError?.(errorObj)\n return null\n }\n }, [client, chainId, onTransactionConfirmed, onError])\n\n // ─── Write methods ────────────────────────────────────────────────────────\n\n const createDeposit = useCallback(\n (params: CreateDepositRawParams, hooks?: WriteHookParams) =>\n executeClientMethod(() => client!.createDepositRaw({ ...params, ...hooks }), 'Deposit created'),\n [client, executeClientMethod]\n )\n\n const addFunds = useCallback(\n (depositId: bigint, amount: bigint, hooks?: WriteHookParams) =>\n executeClientMethod(() => client!.addFunds({ depositId, amount, ...hooks }), 'Funds added'),\n [client, executeClientMethod]\n )\n\n const removeFunds = useCallback(\n (depositId: bigint, amount: bigint, hooks?: WriteHookParams) =>\n executeClientMethod(() => client!.removeFunds({ depositId, amount, ...hooks }), 'Funds removed'),\n [client, executeClientMethod]\n )\n\n const withdrawDeposit = useCallback(\n (depositId: bigint, hooks?: WriteHookParams) =>\n executeClientMethod(() => client!.withdrawDeposit({ depositId, ...hooks }), 'Deposit withdrawn'),\n [client, executeClientMethod]\n )\n\n const pruneExpiredIntents = useCallback(\n (depositId: bigint, hooks?: WriteHookParams) =>\n executeClientMethod(() => client!.pruneExpiredIntents({ depositId, ...hooks }), 'Expired intents pruned'),\n [client, executeClientMethod]\n )\n\n const setAcceptingIntents = useCallback(\n (depositId: bigint, accepting: boolean, hooks?: WriteHookParams) =>\n executeClientMethod(() => client!.setAcceptingIntents({ depositId, accepting, ...hooks }), 'Deposit updated'),\n [client, executeClientMethod]\n )\n\n const setRetainOnEmpty = useCallback(\n (depositId: bigint, retain: boolean, hooks?: WriteHookParams) =>\n executeClientMethod(() => client!.setRetainOnEmpty({ depositId, retain, ...hooks }), 'Deposit updated'),\n [client, executeClientMethod]\n )\n\n const setIntentRange = useCallback(\n (depositId: bigint, intentAmountRange: { min: bigint; max: bigint }, hooks?: WriteHookParams) =>\n executeClientMethod(() => client!.setIntentRange({ depositId, ...intentAmountRange, ...hooks }), 'Amount range updated'),\n [client, executeClientMethod]\n )\n\n const setPaymentMethodActive = useCallback(\n (depositId: bigint, paymentMethod: Hex, active: boolean, hooks?: WriteHookParams) =>\n executeClientMethod(() => client!.setPaymentMethodActive({ depositId, paymentMethod, active, ...hooks }), 'Platform updated'),\n [client, executeClientMethod]\n )\n\n const setCurrencyMinRate = useCallback(\n (params: { depositId: bigint; paymentMethod: Hex; currency: Hex; newMinConversionRate: bigint }, hooks?: WriteHookParams) =>\n executeClientMethod(() => client!.setCurrencyMinRate({\n depositId: params.depositId,\n paymentMethod: params.paymentMethod,\n currency: params.currency,\n rate: params.newMinConversionRate,\n ...hooks,\n }), 'Conversion rate updated'),\n [client, executeClientMethod]\n )\n\n const addCurrencies = useCallback(\n (params: { depositId: bigint; paymentMethod: Hex; currencies: Array<{ code: Hex; minConversionRate: bigint }> }, hooks?: WriteHookParams) =>\n executeClientMethod(() => client!.addCurrencies({ ...params, ...hooks }), 'Currencies added'),\n [client, executeClientMethod]\n )\n\n const deactivateCurrency = useCallback(\n (params: { depositId: bigint; paymentMethod: Hex; currencyCode: Hex }, hooks?: WriteHookParams) =>\n executeClientMethod(() => client!.deactivateCurrency({ ...params, ...hooks }), 'Currency deactivated'),\n [client, executeClientMethod]\n )\n\n const addPaymentMethods = useCallback(\n (params: {\n depositId: bigint\n paymentMethods: Hex[]\n paymentMethodData: Array<{ intentGatingService: Hex; payeeDetails: Hex; data: Hex }>\n currencies: Array<Array<{ code: Hex; minConversionRate: bigint }>>\n }, hooks?: WriteHookParams) =>\n executeClientMethod(() => client!.addPaymentMethods({ ...params, ...hooks }), 'Payment method added'),\n [client, executeClientMethod]\n )\n\n // ─── Read methods (delegate to client) ────────────────────────────────────\n\n const getDeposit = useCallback(\n async (depositId: bigint) => {\n if (!client) return null\n try { return await client.getDeposit(depositId) }\n catch { return null }\n },\n [client]\n )\n\n const getAccountDeposits = useCallback(\n async (account: Hex) => {\n if (!client) return []\n try { return await client.getAccountDeposits(account) }\n catch { return [] }\n },\n [client]\n )\n\n const reset = useCallback(() => {\n setStatus('idle')\n setError(null)\n setTxHash(null)\n }, [])\n\n return {\n status,\n error,\n isLoading,\n escrow,\n orchestratorAddress,\n depositCounter,\n txHash,\n createDeposit,\n addFunds,\n removeFunds,\n withdrawDeposit,\n pruneExpiredIntents,\n setAcceptingIntents,\n setRetainOnEmpty,\n setIntentRange,\n setPaymentMethodActive,\n setCurrencyMinRate,\n addCurrencies,\n deactivateCurrency,\n addPaymentMethods,\n getDeposit,\n getAccountDeposits,\n reset,\n refetchOrchestrator,\n refetchDepositCounter,\n }\n}\n","/**\n * @fileoverview Hook for tracking transactions through indexer sync.\n *\n * Manages the full transaction lifecycle: submission → confirmation → indexer sync.\n * Provides phase tracking and optional toast notifications for slow indexer syncs.\n *\n * @remarks\n * The indexer typically lags behind the blockchain by a few seconds.\n * This hook waits for the indexer to catch up before reporting success,\n * ensuring the UI shows consistent state after transactions.\n *\n * Requires a `ProvexProvider` ancestor (a public client is auto-built\n * from `config.chain` if one is not supplied).\n */\n\nimport { useState, useCallback } from 'react'\nimport type { Hex } from 'viem'\nimport type { ChainId } from '@provex/utils/chain'\nimport { orderId } from '@provex/utils/ids'\nimport { getLatestContract } from '@provex/utils/contracts'\nimport { checkTransactionIndexed, checkMutation, type IndexerAdapter } from '../lib/updates'\nimport { getUserFriendlyErrorMessage } from '../lib/errors'\nimport { useOptionalProvex, useOptionalProvexPublicClient } from '../ProvexProvider'\n\n/**\n * Phase of the transaction lifecycle.\n */\nexport type TransactionPhase = 'idle' | 'submitting' | 'confirming' | 'syncing' | 'complete' | 'error'\n\nexport interface UseTransactionWithIndexerOptions {\n /** Called when transaction is fully indexed */\n onSuccess?: () => void\n /** Called on any error */\n onError?: (error: Error) => void\n /** Called when indexer sync is taking longer than expected. */\n onSlowSync?: () => void\n /** Called after the transaction is confirmed on-chain. */\n onTransactionConfirmed?: (params: { hash: Hex; chainId: ChainId; action: string }) => void\n /** Called when a transaction-level error message is available. */\n onTransactionError?: (message: string) => void\n /** Indexer adapter. Falls back to ProvexProvider context, then skips sync. */\n indexer?: IndexerAdapter\n}\n\nexport interface TransactionSyncOptions {\n /** The transaction hash to track */\n hash: Hex\n /** Chain ID for the transaction */\n chainId: ChainId\n /** Action description (e.g., \"Deposit created\") */\n action: string\n}\n\nexport interface MutationSyncOptions {\n /** The transaction hash */\n hash: Hex\n /** Deposit local ID for mutation tracking */\n depositId: bigint\n /** Chain ID for the deposit */\n chainId: ChainId\n /** Target status to wait for */\n status: string\n /** Action description */\n action: string\n}\n\n/**\n * Hook for handling the three-phase transaction flow:\n * 1. Transaction submission (handled by caller)\n * 2. Transaction confirmation (waiting for mining)\n * 3. Indexer sync (waiting for indexer to process)\n */\nexport const useTransactionWithIndexer = (options: UseTransactionWithIndexerOptions = {}) => {\n const { onSuccess, onError, onSlowSync, onTransactionConfirmed, onTransactionError, indexer: indexerParam } = options\n const provex = useOptionalProvex()\n const indexer = indexerParam ?? provex?.indexer\n\n const [phase, setPhase] = useState<TransactionPhase>('idle')\n const publicClient = useOptionalProvexPublicClient()\n\n const waitForTransaction = useCallback(async ({\n hash,\n chainId,\n action,\n }: TransactionSyncOptions) => {\n try {\n setPhase('confirming')\n await publicClient?.waitForTransactionReceipt({ hash })\n\n if (indexer) {\n setPhase('syncing')\n await checkTransactionIndexed({\n queryTransaction: indexer.getTransactionByHash,\n hash,\n onSlowSync,\n })\n }\n\n setPhase('complete')\n onTransactionConfirmed?.({ hash, chainId, action })\n onSuccess?.()\n } catch (e) {\n setPhase('error')\n const error = e instanceof Error ? e : new Error(String(e))\n onTransactionError?.(getUserFriendlyErrorMessage(error))\n onError?.(error)\n throw e\n }\n }, [publicClient, indexer, onSuccess, onError, onSlowSync, onTransactionConfirmed, onTransactionError])\n\n const waitForMutation = useCallback(async ({\n hash,\n depositId,\n chainId,\n status,\n action,\n }: MutationSyncOptions) => {\n try {\n setPhase('confirming')\n await publicClient?.waitForTransactionReceipt({ hash })\n\n if (indexer) {\n setPhase('syncing')\n\n const escrow = getLatestContract(chainId, 'escrow')!\n const depositIdHex = orderId.deposit.serialize({\n escrow,\n depositId,\n chainId,\n })\n\n await checkMutation({\n queryDeposit: indexer.getDepositById,\n depositIdHex,\n status,\n onSlowSync,\n })\n }\n\n setPhase('complete')\n onTransactionConfirmed?.({ hash, chainId, action })\n onSuccess?.()\n } catch (e) {\n setPhase('error')\n const error = e instanceof Error ? e : new Error(String(e))\n onTransactionError?.(getUserFriendlyErrorMessage(error))\n onError?.(error)\n throw e\n }\n }, [publicClient, indexer, onSuccess, onError, onSlowSync, onTransactionConfirmed, onTransactionError])\n\n const reset = useCallback(() => {\n setPhase('idle')\n }, [])\n\n const isLoading = phase === 'submitting' || phase === 'confirming' || phase === 'syncing'\n\n const loadingText = phase === 'syncing'\n ? 'Syncing...'\n : phase === 'confirming'\n ? 'Confirming...'\n : undefined\n\n return {\n phase,\n isLoading,\n loadingText,\n waitForTransaction,\n waitForMutation,\n reset,\n setPhase,\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/hooks/useAllowance.ts","../src/hooks/useCancelIntent.ts","../src/hooks/useReleaseFundsToPayer.ts","../src/hooks/useV3Escrow.ts","../src/hooks/useTransactionWithIndexer.ts"],"names":["useState","useMemo","encodeFunctionData","escrowAbi","getEscrowVersion","getLatestContract","supportsOrchestrator","useCallback","v3EscrowAbi"],"mappings":";;;;;;;;AA4BO,IAAM,eAAe,CAAC;AAAA,EAC3B,KAAA;AAAA,EACA,OAAA;AAAA,EACA,OAAA;AAAA,EACA,OAAA;AAAA,EACA,gBAAA,GAAmB,KAAA;AAAA,EACnB,SAAA;AAAA,EACA,OAAA;AAAA,EACA;AACF,CAAA,KAUM;AACJ,EAAA,MAAM,eAAA,GAAkB,QAAQ,MAAM;AACpC,IAAA,IAAI,gBAAA,KAAqB,aAAa,OAAA,EAAS;AAC7C,MAAA,OAAO,OAAA;AAAA,IACT;AACA,IAAA,OAAO,UAAA;AAAA,EACT,CAAA,EAAG,CAAC,gBAAA,EAAk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AAG;AACV,MAAA,QAAA,CAAS,OAAO,CAAA;AAChB,MAAA,MAAM,KAAA,GAAQ,aAAa,KAAA,GAAQ,CAAA,GAAI,IAAI,KAAA,CAAM,MAAA,CAAO,CAAC,CAAC,CAAA;AAC1D,MAAA,kBAAA,GAAqB,2BAAA,CAA4B,KAAK,CAAC,CAAA;AACvD,MAAA,OAAA,GAAU,KAAK,CAAA;AACf,MAAA,MAAM,CAAA;AAAA,IACR;AAAA,EACF,CAAA,EAAG,CAAC,YAAA,EAAc,OAAA,EAAS,WAAW,OAAA,EAAS,UAAA,EAAY,sBAAA,EAAwB,kBAAkB,CAAC,CAAA;AAEtG,EAAA,MAAM,KAAA,GAAQE,YAAY,MAAM;AAC9B,IAAA,QAAA,CAAS,MAAM,CAAA;AAAA,EACjB,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,MAAM,SAAA,GAAY,KAAA,KAAU,YAAA,IAAgB,KAAA,KAAU,gBAAgB,KAAA,KAAU,SAAA;AAEhF,EAAA,MAAM,cAAc,KAAA,KAAU,SAAA,GAC1B,YAAA,GACA,KAAA,KAAU,eACR,eAAA,GACA,MAAA;AAEN,EAAA,OAAO;AAAA,IACL,KAAA;AAAA,IACA,SAAA;AAAA,IACA,WAAA;AAAA,IACA,kBAAA;AAAA,IACA,eAAA;AAAA,IACA,KAAA;AAAA,IACA;AAAA,GACF;AACF","file":"index.js","sourcesContent":["/**\n * @fileoverview Hook for ERC20 token allowance checking and approval.\n *\n * Handles the common pattern of checking if a spender (escrow contract)\n * has sufficient allowance to transfer tokens, and prompting for approval\n * if needed.\n *\n * @remarks\n * Approval is required before createDeposit or addFunds can transfer\n * tokens to the escrow contract.\n *\n * Reads use the `publicClient` registered on `ProvexProvider` (auto-built\n * from `config.chain` if not supplied). Writes require a `wallet` on the\n * same provider.\n */\n\nimport { useMemo, useState } from \"react\"\nimport { encodeFunctionData, erc20Abi, maxUint256, type Hex } from \"viem\"\nimport { useContractRead } from \"../lib/contractRead\"\nimport { useOptionalProvexPublicClient, useOptionalProvexWallet } from \"../ProvexProvider\"\nimport { getTransactionGasInputs } from \"../lib/block\"\nimport type { TokenInfo } from \"@provex/utils/tokens\"\n\n/**\n * Phase of the approval transaction lifecycle.\n */\ntype ApprovalPhase = 'idle' | 'submitting' | 'confirming'\n\nexport const useAllowance = ({\n token,\n spender,\n account,\n balance,\n defaultAllowance = 'max',\n onSuccess,\n onError,\n onSettled,\n}: {\n token: TokenInfo\n spender: Hex\n /** The account address to check/write allowance for. If undefined, hook returns null allowance and writeApproval is a no-op. */\n account: Hex | undefined\n balance?: bigint\n defaultAllowance?: 'max' | 'balance'\n onSuccess?: (...args: unknown[]) => void\n onError?: (...args: unknown[]) => void\n onSettled?: (...args: unknown[]) => void\n}) => {\n const targetAllowance = useMemo(() => {\n if (defaultAllowance === 'balance' && balance) {\n return balance\n }\n return maxUint256\n }, [defaultAllowance, balance])\n\n const publicClient = useOptionalProvexPublicClient(token.chainId)\n const wallet = useOptionalProvexWallet()\n\n const { data, isLoading, error, refetch } = useContractRead<bigint>({\n address: token.address as Hex,\n abi: erc20Abi,\n functionName: 'allowance',\n args: account && spender ? [account, spender] : undefined,\n chainId: token.chainId,\n query: {\n enabled: !!account && !!spender && !!token.address,\n },\n })\n\n const [approvalPhase, setApprovalPhase] = useState<ApprovalPhase>('idle')\n const isWritingApproval = approvalPhase !== 'idle'\n const approvalLoadingText = approvalPhase === 'confirming' ? 'Confirming...' : `Approve ${token.symbol}`\n\n return {\n allowance: data ?? null,\n isLoading,\n isWritingApproval,\n /** Loading text for the approval button */\n approvalLoadingText,\n error,\n writeApproval: async () => {\n if (!account || !spender || !token.address || !publicClient || !wallet) {\n return\n }\n setApprovalPhase('submitting')\n try {\n const gasInputs = await getTransactionGasInputs(token.chainId)\n const callData = encodeFunctionData({\n abi: erc20Abi,\n functionName: 'approve',\n args: [spender, targetAllowance],\n })\n const hash = await wallet.sendTransaction({\n to: token.address as Hex,\n data: callData,\n value: 0n,\n chainId: token.chainId,\n maxFeePerGas: gasInputs.maxFeePerGas,\n maxPriorityFeePerGas: gasInputs.maxPriorityFeePerGas,\n })\n\n setApprovalPhase('confirming')\n await publicClient.waitForTransactionReceipt({ hash })\n await refetch()\n onSuccess?.(hash)\n } catch (err) {\n onError?.(err as Error)\n } finally {\n setApprovalPhase('idle')\n onSettled?.()\n }\n },\n }\n}\n","/**\n * @fileoverview Hook for canceling an active intent.\n *\n * v3 / v4 (orchestrator generations): delegate to ProveXClient.cancelIntent,\n * which targets the Orchestrator where cancelIntent lives.\n * v2 (legacy monolith): fall back to a direct viem transaction via\n * WalletAdapter, because on v2 cancelIntent lives on the Escrow itself.\n */\n\nimport { useState, useMemo, useCallback } from 'react'\nimport { encodeFunctionData, type Hex } from 'viem'\nimport { V2EscrowAbi as escrowAbi } from '@provex/abis'\nimport { getLatestContract, getEscrowVersion, supportsOrchestrator, type Version } from '@provex/utils/contracts'\nimport type { ChainId } from '@provex/utils/chain'\nimport { getTransactionGasInputs } from '../lib/block'\nimport { checkTransactionIndexed } from '../lib/updates'\nimport { useOptionalProvex, useOptionalProvexPublicClient, useOptionalProvexWallet } from '../ProvexProvider'\nimport { getUserFriendlyErrorMessage, isUserRejectionError } from '../lib/errors'\nimport { createProveXClient } from '../client/ProveXClient'\nimport { ProveXError, type WriteHookParams } from '../client/types'\n\n/** Status values for the cancel intent operation. */\nexport type CancelIntentStatus =\n | 'idle'\n | 'prompt_wallet_confirm'\n | 'writing_tx'\n | 'success'\n | 'error'\n\n/**\n * Hook to cancel an intent with automatic v2/v3 version detection.\n *\n * V3 delegates to ProveXClient. V2 falls back to a direct WalletAdapter\n * call. Both paths source the wallet + public client from ProvexProvider.\n */\nexport const useCancelIntent = ({\n onSuccess,\n onMutate,\n onError,\n onSettled,\n chainId,\n escrowAddress: providedEscrowAddress,\n version: explicitVersion,\n}: {\n onSuccess?: () => void\n onMutate?: () => void\n onError?: (error: Error) => void\n onSettled?: () => void\n chainId?: ChainId | null | undefined\n escrowAddress?: Hex | null | undefined\n version?: Version\n}) => {\n const provex = useOptionalProvex()\n const wallet = useOptionalProvexWallet()\n const publicClient = useOptionalProvexPublicClient(chainId ?? undefined)\n const [status, setStatus] = useState<CancelIntentStatus>('idle')\n const [errorMessage, setErrorMessage] = useState<string | null>(null)\n const isLoading = useMemo(() => status === 'prompt_wallet_confirm' || status === 'writing_tx', [status])\n\n const version = useMemo(() => {\n if (explicitVersion) return explicitVersion\n if (providedEscrowAddress) {\n const detected = getEscrowVersion(providedEscrowAddress)\n if (detected) return detected\n }\n return 'v3' as Version\n }, [explicitVersion, providedEscrowAddress])\n\n const escrowAddress = useMemo(() => {\n if (providedEscrowAddress) return providedEscrowAddress\n if (!chainId) return null\n return getLatestContract(chainId, 'escrow', version)\n }, [providedEscrowAddress, chainId, version])\n\n // Orchestrator client (memoized) — built for v3 and every newer generation.\n const client = useMemo(() => {\n if (!provex || !chainId || !supportsOrchestrator(version)) return null\n return createProveXClient({\n chain: provex.config.chain,\n apiUrl: provex.config.apiUrl,\n wallet,\n indexer: provex.indexer,\n escrowAddress: escrowAddress ?? undefined,\n })\n }, [provex, chainId, version, wallet, escrowAddress])\n\n const cancelIntent = useCallback(async (intentHash: Hex, hooks?: WriteHookParams) => {\n if (!intentHash || !chainId) return\n\n setStatus('prompt_wallet_confirm')\n setErrorMessage(null)\n onMutate?.()\n\n try {\n if (supportsOrchestrator(version) && client) {\n // v3 / v4: delegate to ProveXClient (targets the Orchestrator)\n await client.cancelIntent({ intentHash, ...hooks })\n } else {\n // v2: direct wallet call via WalletAdapter (cancelIntent on the Escrow)\n if (!escrowAddress) throw new Error('Missing escrow address')\n if (!wallet) throw new Error('No wallet configured on ProvexProvider')\n const gasInputs = await getTransactionGasInputs(chainId)\n const data = encodeFunctionData({\n abi: escrowAbi,\n functionName: 'cancelIntent',\n args: [intentHash],\n })\n const request = {\n to: escrowAddress,\n data,\n value: 0n,\n chainId,\n maxFeePerGas: gasInputs.maxFeePerGas,\n maxPriorityFeePerGas: gasInputs.maxPriorityFeePerGas,\n }\n const ctx = { chainId, request }\n hooks?.onAwaitingSignature?.(ctx)\n const hash = await wallet.sendTransaction(request)\n hooks?.onTransactionHash?.({ ...ctx, hash })\n if (publicClient) await publicClient.waitForTransactionReceipt({ hash })\n if (provex?.indexer) {\n await checkTransactionIndexed({ queryTransaction: provex.indexer.getTransactionByHash, hash })\n }\n }\n\n setStatus('success')\n onSuccess?.()\n } catch (error) {\n // V3 path's client fires onFailed internally with full TxContext;\n // V2 path errors before request construction can't synthesize one.\n // The outer wrapper deliberately doesn't double-fire.\n const isRejection = (error instanceof ProveXError && error.isRejection) || isUserRejectionError(error)\n if (isRejection) {\n setStatus('idle')\n } else {\n setStatus('error')\n setErrorMessage(getUserFriendlyErrorMessage(error))\n }\n onError?.(error as Error)\n } finally {\n onSettled?.()\n }\n }, [chainId, escrowAddress, version, client, publicClient, wallet, provex, onSuccess, onMutate, onError, onSettled])\n\n return {\n cancelIntent,\n status,\n isLoading,\n version,\n errorMessage,\n }\n}\n","/**\n * @fileoverview Hook for releasing funds back to payer.\n *\n * v3 / v4 (orchestrator generations): delegate to\n * ProveXClient.releaseFundsToPayer, which targets the Orchestrator.\n * v2 (legacy monolith): fall back to a direct viem transaction via\n * WalletAdapter, because on v2 releaseFundsToPayer lives on the Escrow.\n */\n\nimport { useState, useMemo, useCallback } from 'react'\nimport { encodeFunctionData, type Hex } from 'viem'\nimport { V2EscrowAbi as escrowAbi } from '@provex/abis'\nimport { getLatestContract, getEscrowVersion, supportsOrchestrator, type Version } from '@provex/utils/contracts'\nimport type { ChainId } from '@provex/utils/chain'\nimport { getTransactionGasInputs } from '../lib/block'\nimport { checkTransactionIndexed } from '../lib/updates'\nimport { useOptionalProvex, useOptionalProvexPublicClient, useOptionalProvexWallet } from '../ProvexProvider'\nimport { isUserRejectionError } from '../lib/errors'\nimport { createProveXClient } from '../client/ProveXClient'\nimport { ProveXError, type WriteHookParams } from '../client/types'\n\n/** Status values for the release funds operation. */\nexport type ReleaseFundsStatus =\n | 'idle'\n | 'prompt_wallet_confirm'\n | 'writing_tx'\n | 'success'\n | 'error'\n\n/**\n * Hook to release funds back to payer with automatic v2/v3 version detection.\n *\n * V3 delegates to ProveXClient. V2 falls back to a direct WalletAdapter\n * call. Both paths source the wallet + public client from ProvexProvider.\n */\nexport const useReleaseFundsToPayer = ({\n onSuccess,\n onSettled,\n chainId,\n escrowAddress: providedEscrowAddress,\n version: explicitVersion,\n}: {\n onSuccess?: () => void\n onSettled?: () => void\n chainId?: ChainId | null | undefined\n escrowAddress?: Hex | null | undefined\n version?: Version\n}) => {\n const provex = useOptionalProvex()\n const wallet = useOptionalProvexWallet()\n const publicClient = useOptionalProvexPublicClient(chainId ?? undefined)\n const [status, setStatus] = useState<ReleaseFundsStatus>('idle')\n const [errorMessage, setErrorMessage] = useState<string | null>(null)\n const isLoading = useMemo(\n () => status === 'prompt_wallet_confirm' || status === 'writing_tx',\n [status]\n )\n\n const version = useMemo(() => {\n if (explicitVersion) return explicitVersion\n if (providedEscrowAddress) {\n const detected = getEscrowVersion(providedEscrowAddress)\n if (detected) return detected\n }\n return 'v3' as Version\n }, [explicitVersion, providedEscrowAddress])\n\n const escrowAddress = useMemo(() => {\n if (providedEscrowAddress) return providedEscrowAddress\n if (!chainId) return null\n return getLatestContract(chainId, 'escrow', version)\n }, [providedEscrowAddress, chainId, version])\n\n // Orchestrator client — built for v3 and every newer generation.\n const client = useMemo(() => {\n if (!provex || !chainId || !supportsOrchestrator(version)) return null\n return createProveXClient({\n chain: provex.config.chain,\n apiUrl: provex.config.apiUrl,\n wallet,\n indexer: provex.indexer,\n escrowAddress: escrowAddress ?? undefined,\n })\n }, [provex, chainId, version, wallet, escrowAddress])\n\n const releaseFundsToPayer = useCallback(async (intentHash: Hex, hooks?: WriteHookParams) => {\n if (!intentHash || !chainId) return\n\n setStatus('prompt_wallet_confirm')\n setErrorMessage(null)\n\n try {\n if (supportsOrchestrator(version) && client) {\n // v3 / v4: delegate to ProveXClient (targets the Orchestrator)\n await client.releaseFundsToPayer({ intentHash, ...hooks })\n } else {\n // v2: direct wallet call via WalletAdapter (function on the Escrow)\n if (!escrowAddress) throw new Error('Missing escrow address')\n if (!wallet) throw new Error('No wallet configured on ProvexProvider')\n const gasInputs = await getTransactionGasInputs(chainId)\n const data = encodeFunctionData({\n abi: escrowAbi,\n functionName: 'releaseFundsToPayer',\n args: [intentHash],\n })\n const request = {\n to: escrowAddress,\n data,\n value: 0n,\n chainId,\n maxFeePerGas: gasInputs.maxFeePerGas,\n maxPriorityFeePerGas: gasInputs.maxPriorityFeePerGas,\n }\n const ctx = { chainId, request }\n hooks?.onAwaitingSignature?.(ctx)\n const hash = await wallet.sendTransaction(request)\n hooks?.onTransactionHash?.({ ...ctx, hash })\n if (publicClient) await publicClient.waitForTransactionReceipt({ hash })\n if (provex?.indexer) {\n await checkTransactionIndexed({ queryTransaction: provex.indexer.getTransactionByHash, hash })\n }\n }\n\n setStatus('success')\n onSuccess?.()\n } catch (error) {\n // V3 path's client already fires onFailed with full TxContext from\n // inside the SDK; no need to double-fire here. V2 path errors that\n // surface before request construction (gasInputs/encoding/connection)\n // also can't synthesize a meaningful request, so the outer onFailed\n // call is intentionally dropped — the per-call hook is best-effort\n // for the SDK-managed window, not the entire wrapper.\n const isRejection = (error instanceof ProveXError && error.isRejection) || isUserRejectionError(error)\n if (isRejection) {\n setStatus('idle')\n setErrorMessage(null)\n } else {\n setStatus('error')\n setErrorMessage(error instanceof Error ? error.message : 'Transaction failed')\n }\n } finally {\n onSettled?.()\n }\n }, [chainId, escrowAddress, version, client, publicClient, wallet, provex, onSuccess, onSettled])\n\n return {\n releaseFundsToPayer,\n status,\n isLoading,\n errorMessage,\n version,\n }\n}\n","/**\n * @fileoverview React hook for V3 Escrow contract interactions.\n *\n * Thin state wrapper around ProveXClient — manages status, error,\n * and loading state for each escrow write operation.\n *\n * Reads (orchestrator address, deposit counter) use the viem public\n * client from ProvexProvider for automatic cache invalidation.\n */\n\nimport { useState, useMemo, useCallback } from 'react'\nimport type { Hex } from 'viem'\nimport { useContractRead } from '../lib/contractRead'\nimport { V3EscrowAbi as v3EscrowAbi } from '@provex/abis'\nimport { useOrchestratorAddress } from './useOrchestratorAddress'\nimport { getLatestContract, getLatestConfiguredVersion } from '@provex/utils/contracts'\nimport type { ChainId } from '@provex/utils/chain'\nimport { useOptionalProvex, useOptionalProvexWallet } from '../ProvexProvider'\nimport { createProveXClient } from '../client/ProveXClient'\nimport { ProveXError, type TransactionResult, type WriteHookParams } from '../client/types'\nimport type { CreateDepositRawParams } from '../client/types'\n\n/**\n * Status values for escrow write operations.\n */\nexport type V3EscrowStatus =\n | 'idle'\n | 'prompt_wallet_confirm'\n | 'writing_tx'\n | 'confirming'\n | 'syncing'\n | 'success'\n | 'error'\n\n/** @deprecated Use `CreateDepositRawParams` from `@provex/react/client/types`. */\nexport type CreateDepositParams = CreateDepositRawParams\n\n/**\n * Hook for interacting with v3 Escrow contract.\n *\n * All write methods delegate to ProveXClient. Reads use the\n * ProvexProvider's public client with tanstack-query caching.\n */\nexport const useV3Escrow = ({\n chainId,\n escrowAddress,\n onSlowSync,\n onTransactionConfirmed,\n onError,\n}: {\n chainId?: ChainId | null\n escrowAddress?: Hex | null\n /** Called when indexer sync is taking longer than expected. */\n onSlowSync?: () => void\n /** Called after the transaction is confirmed on-chain. */\n onTransactionConfirmed?: (params: { hash: Hex; chainId: ChainId; action: string }) => void\n /** Called when a write method fails (contract revert, gas issues, etc). Not called on user rejection. */\n onError?: (error: Error) => void\n}) => {\n const provex = useOptionalProvex()\n const wallet = useOptionalProvexWallet()\n const [status, setStatus] = useState<V3EscrowStatus>('idle')\n const [error, setError] = useState<string | null>(null)\n const [txHash, setTxHash] = useState<Hex | null>(null)\n\n const escrow = useMemo(() => {\n if (escrowAddress) return escrowAddress\n if (!chainId) return null\n // Only reached when the caller named no deposit — a new-deposit write.\n // Those belong on the generation the chain currently runs, not a pinned v3.\n return getLatestContract(chainId, 'escrow', getLatestConfiguredVersion(chainId))\n }, [chainId, escrowAddress])\n\n const isLoading = useMemo(\n () =>\n status === 'prompt_wallet_confirm' ||\n status === 'writing_tx' ||\n status === 'confirming' ||\n status === 'syncing',\n [status]\n )\n\n // Memoized client — recreated when wallet or config changes\n const client = useMemo(() => {\n if (!provex || !chainId) return null\n return createProveXClient({\n chain: provex.config.chain,\n apiUrl: provex.config.apiUrl,\n wallet,\n indexer: provex.indexer,\n escrowAddress: escrow ?? undefined,\n onTransactionHash: (hash) => {\n setTxHash(hash)\n setStatus('confirming')\n },\n onSlowSync: () => {\n setStatus('syncing')\n onSlowSync?.()\n },\n })\n }, [provex, chainId, wallet, escrow, onSlowSync])\n\n // ─── Reads (viem via ProvexProvider) ──────────────────────────────────────\n\n const { data: orchestratorAddress, refetch: refetchOrchestrator } = useOrchestratorAddress({\n escrowAddress: escrow ?? undefined,\n chainId: chainId ?? 0,\n })\n\n const { data: depositCounter, refetch: refetchDepositCounter } = useContractRead<bigint>({\n address: escrow ?? undefined,\n abi: v3EscrowAbi,\n functionName: 'depositCounter',\n chainId: chainId ?? undefined,\n query: { enabled: !!escrow },\n })\n\n // ─── Generic write executor ───────────────────────────────────────────────\n\n const executeClientMethod = useCallback(async <T extends TransactionResult>(\n method: () => Promise<T>,\n action: string,\n ): Promise<Hex | null> => {\n if (!client || !chainId) {\n const msg = 'Client or chain not configured'\n setError(msg)\n onError?.(new Error(msg))\n return null\n }\n\n try {\n setStatus('prompt_wallet_confirm')\n setError(null)\n setTxHash(null)\n\n const result = await method()\n\n setStatus('success')\n onTransactionConfirmed?.({ hash: result.hash, chainId, action })\n return result.hash\n } catch (err) {\n // ProveXClient fires onFailed internally with full TxContext (chainId,\n // request, error). The outer wrapper here used to double-fire with\n // just an Error — drop it so consumers receive one well-formed event.\n if (err instanceof ProveXError && err.isRejection) {\n setStatus('idle')\n setError(null)\n return null\n }\n const errorObj = err instanceof Error ? err : new Error(String(err))\n setStatus('error')\n setError(errorObj.message)\n onError?.(errorObj)\n return null\n }\n }, [client, chainId, onTransactionConfirmed, onError])\n\n // ─── Write methods ────────────────────────────────────────────────────────\n\n const createDeposit = useCallback(\n (params: CreateDepositRawParams, hooks?: WriteHookParams) =>\n executeClientMethod(() => client!.createDepositRaw({ ...params, ...hooks }), 'Deposit created'),\n [client, executeClientMethod]\n )\n\n const addFunds = useCallback(\n (depositId: bigint, amount: bigint, hooks?: WriteHookParams) =>\n executeClientMethod(() => client!.addFunds({ depositId, amount, ...hooks }), 'Funds added'),\n [client, executeClientMethod]\n )\n\n const removeFunds = useCallback(\n (depositId: bigint, amount: bigint, hooks?: WriteHookParams) =>\n executeClientMethod(() => client!.removeFunds({ depositId, amount, ...hooks }), 'Funds removed'),\n [client, executeClientMethod]\n )\n\n const withdrawDeposit = useCallback(\n (depositId: bigint, hooks?: WriteHookParams) =>\n executeClientMethod(() => client!.withdrawDeposit({ depositId, ...hooks }), 'Deposit withdrawn'),\n [client, executeClientMethod]\n )\n\n const pruneExpiredIntents = useCallback(\n (depositId: bigint, hooks?: WriteHookParams) =>\n executeClientMethod(() => client!.pruneExpiredIntents({ depositId, ...hooks }), 'Expired intents pruned'),\n [client, executeClientMethod]\n )\n\n const setAcceptingIntents = useCallback(\n (depositId: bigint, accepting: boolean, hooks?: WriteHookParams) =>\n executeClientMethod(() => client!.setAcceptingIntents({ depositId, accepting, ...hooks }), 'Deposit updated'),\n [client, executeClientMethod]\n )\n\n const setRetainOnEmpty = useCallback(\n (depositId: bigint, retain: boolean, hooks?: WriteHookParams) =>\n executeClientMethod(() => client!.setRetainOnEmpty({ depositId, retain, ...hooks }), 'Deposit updated'),\n [client, executeClientMethod]\n )\n\n const setIntentRange = useCallback(\n (depositId: bigint, intentAmountRange: { min: bigint; max: bigint }, hooks?: WriteHookParams) =>\n executeClientMethod(() => client!.setIntentRange({ depositId, ...intentAmountRange, ...hooks }), 'Amount range updated'),\n [client, executeClientMethod]\n )\n\n const setPaymentMethodActive = useCallback(\n (depositId: bigint, paymentMethod: Hex, active: boolean, hooks?: WriteHookParams) =>\n executeClientMethod(() => client!.setPaymentMethodActive({ depositId, paymentMethod, active, ...hooks }), 'Platform updated'),\n [client, executeClientMethod]\n )\n\n const setCurrencyMinRate = useCallback(\n (params: { depositId: bigint; paymentMethod: Hex; currency: Hex; newMinConversionRate: bigint }, hooks?: WriteHookParams) =>\n executeClientMethod(() => client!.setCurrencyMinRate({\n depositId: params.depositId,\n paymentMethod: params.paymentMethod,\n currency: params.currency,\n rate: params.newMinConversionRate,\n ...hooks,\n }), 'Conversion rate updated'),\n [client, executeClientMethod]\n )\n\n const addCurrencies = useCallback(\n (params: { depositId: bigint; paymentMethod: Hex; currencies: Array<{ code: Hex; minConversionRate: bigint }> }, hooks?: WriteHookParams) =>\n executeClientMethod(() => client!.addCurrencies({ ...params, ...hooks }), 'Currencies added'),\n [client, executeClientMethod]\n )\n\n const deactivateCurrency = useCallback(\n (params: { depositId: bigint; paymentMethod: Hex; currencyCode: Hex }, hooks?: WriteHookParams) =>\n executeClientMethod(() => client!.deactivateCurrency({ ...params, ...hooks }), 'Currency deactivated'),\n [client, executeClientMethod]\n )\n\n const addPaymentMethods = useCallback(\n (params: {\n depositId: bigint\n paymentMethods: Hex[]\n paymentMethodData: Array<{ intentGatingService: Hex; payeeDetails: Hex; data: Hex }>\n currencies: Array<Array<{ code: Hex; minConversionRate: bigint }>>\n }, hooks?: WriteHookParams) =>\n executeClientMethod(() => client!.addPaymentMethods({ ...params, ...hooks }), 'Payment method added'),\n [client, executeClientMethod]\n )\n\n // ─── Read methods (delegate to client) ────────────────────────────────────\n\n const getDeposit = useCallback(\n async (depositId: bigint) => {\n if (!client) return null\n try { return await client.getDeposit(depositId) }\n catch { return null }\n },\n [client]\n )\n\n const getAccountDeposits = useCallback(\n async (account: Hex) => {\n if (!client) return []\n try { return await client.getAccountDeposits(account) }\n catch { return [] }\n },\n [client]\n )\n\n const reset = useCallback(() => {\n setStatus('idle')\n setError(null)\n setTxHash(null)\n }, [])\n\n return {\n status,\n error,\n isLoading,\n escrow,\n orchestratorAddress,\n depositCounter,\n txHash,\n createDeposit,\n addFunds,\n removeFunds,\n withdrawDeposit,\n pruneExpiredIntents,\n setAcceptingIntents,\n setRetainOnEmpty,\n setIntentRange,\n setPaymentMethodActive,\n setCurrencyMinRate,\n addCurrencies,\n deactivateCurrency,\n addPaymentMethods,\n getDeposit,\n getAccountDeposits,\n reset,\n refetchOrchestrator,\n refetchDepositCounter,\n }\n}\n","/**\n * @fileoverview Hook for tracking transactions through indexer sync.\n *\n * Manages the full transaction lifecycle: submission → confirmation → indexer sync.\n * Provides phase tracking and optional toast notifications for slow indexer syncs.\n *\n * @remarks\n * The indexer typically lags behind the blockchain by a few seconds.\n * This hook waits for the indexer to catch up before reporting success,\n * ensuring the UI shows consistent state after transactions.\n *\n * Requires a `ProvexProvider` ancestor (a public client is auto-built\n * from `config.chain` if one is not supplied).\n */\n\nimport { useState, useCallback } from 'react'\nimport type { Hex } from 'viem'\nimport type { ChainId } from '@provex/utils/chain'\nimport { orderId } from '@provex/utils/ids'\nimport { getLatestContract } from '@provex/utils/contracts'\nimport { checkTransactionIndexed, checkMutation, type IndexerAdapter } from '../lib/updates'\nimport { getUserFriendlyErrorMessage } from '../lib/errors'\nimport { useOptionalProvex, useOptionalProvexPublicClient } from '../ProvexProvider'\n\n/**\n * Phase of the transaction lifecycle.\n */\nexport type TransactionPhase = 'idle' | 'submitting' | 'confirming' | 'syncing' | 'complete' | 'error'\n\nexport interface UseTransactionWithIndexerOptions {\n /** Called when transaction is fully indexed */\n onSuccess?: () => void\n /** Called on any error */\n onError?: (error: Error) => void\n /** Called when indexer sync is taking longer than expected. */\n onSlowSync?: () => void\n /** Called after the transaction is confirmed on-chain. */\n onTransactionConfirmed?: (params: { hash: Hex; chainId: ChainId; action: string }) => void\n /** Called when a transaction-level error message is available. */\n onTransactionError?: (message: string) => void\n /** Indexer adapter. Falls back to ProvexProvider context, then skips sync. */\n indexer?: IndexerAdapter\n}\n\nexport interface TransactionSyncOptions {\n /** The transaction hash to track */\n hash: Hex\n /** Chain ID for the transaction */\n chainId: ChainId\n /** Action description (e.g., \"Deposit created\") */\n action: string\n}\n\nexport interface MutationSyncOptions {\n /** The transaction hash */\n hash: Hex\n /** Deposit local ID for mutation tracking */\n depositId: bigint\n /** Chain ID for the deposit */\n chainId: ChainId\n /** Target status to wait for */\n status: string\n /** Action description */\n action: string\n}\n\n/**\n * Hook for handling the three-phase transaction flow:\n * 1. Transaction submission (handled by caller)\n * 2. Transaction confirmation (waiting for mining)\n * 3. Indexer sync (waiting for indexer to process)\n */\nexport const useTransactionWithIndexer = (options: UseTransactionWithIndexerOptions = {}) => {\n const { onSuccess, onError, onSlowSync, onTransactionConfirmed, onTransactionError, indexer: indexerParam } = options\n const provex = useOptionalProvex()\n const indexer = indexerParam ?? provex?.indexer\n\n const [phase, setPhase] = useState<TransactionPhase>('idle')\n const publicClient = useOptionalProvexPublicClient()\n\n const waitForTransaction = useCallback(async ({\n hash,\n chainId,\n action,\n }: TransactionSyncOptions) => {\n try {\n setPhase('confirming')\n await publicClient?.waitForTransactionReceipt({ hash })\n\n if (indexer) {\n setPhase('syncing')\n await checkTransactionIndexed({\n queryTransaction: indexer.getTransactionByHash,\n hash,\n onSlowSync,\n })\n }\n\n setPhase('complete')\n onTransactionConfirmed?.({ hash, chainId, action })\n onSuccess?.()\n } catch (e) {\n setPhase('error')\n const error = e instanceof Error ? e : new Error(String(e))\n onTransactionError?.(getUserFriendlyErrorMessage(error))\n onError?.(error)\n throw e\n }\n }, [publicClient, indexer, onSuccess, onError, onSlowSync, onTransactionConfirmed, onTransactionError])\n\n const waitForMutation = useCallback(async ({\n hash,\n depositId,\n chainId,\n status,\n action,\n }: MutationSyncOptions) => {\n try {\n setPhase('confirming')\n await publicClient?.waitForTransactionReceipt({ hash })\n\n if (indexer) {\n setPhase('syncing')\n\n const escrow = getLatestContract(chainId, 'escrow')!\n const depositIdHex = orderId.deposit.serialize({\n escrow,\n depositId,\n chainId,\n })\n\n await checkMutation({\n queryDeposit: indexer.getDepositById,\n depositIdHex,\n status,\n onSlowSync,\n })\n }\n\n setPhase('complete')\n onTransactionConfirmed?.({ hash, chainId, action })\n onSuccess?.()\n } catch (e) {\n setPhase('error')\n const error = e instanceof Error ? e : new Error(String(e))\n onTransactionError?.(getUserFriendlyErrorMessage(error))\n onError?.(error)\n throw e\n }\n }, [publicClient, indexer, onSuccess, onError, onSlowSync, onTransactionConfirmed, onTransactionError])\n\n const reset = useCallback(() => {\n setPhase('idle')\n }, [])\n\n const isLoading = phase === 'submitting' || phase === 'confirming' || phase === 'syncing'\n\n const loadingText = phase === 'syncing'\n ? 'Syncing...'\n : phase === 'confirming'\n ? 'Confirming...'\n : undefined\n\n return {\n phase,\n isLoading,\n loadingText,\n waitForTransaction,\n waitForMutation,\n reset,\n setPhase,\n }\n}\n"]}
|