@provex/react 1.6.2 → 1.7.0-rc.20260522201545.020a3eb
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/LICENSE +21 -0
- package/README.md +1 -1
- package/dist/{ProvexProvider-BQ5vZkHO.d.cts → ProvexProvider-eG_i0Yz3.d.cts} +13 -4
- package/dist/{ProvexProvider-BQ5vZkHO.d.ts → ProvexProvider-eG_i0Yz3.d.ts} +13 -4
- package/dist/{chunk-VWWANYB2.js → chunk-NAGOACEK.js} +22 -11
- package/dist/chunk-NAGOACEK.js.map +1 -0
- package/dist/index.cjs +19 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/wagmi.cjs +19 -8
- 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 +7 -5
- package/skills/react-integration/SKILL.md +246 -0
- package/dist/chunk-VWWANYB2.js.map +0 -1
package/dist/wagmi.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { j as WalletAdapter, s as ProvexProviderProps, o as ProvexTheme } from './ProvexProvider-
|
|
1
|
+
import { j as WalletAdapter, s as ProvexProviderProps, o as ProvexTheme } from './ProvexProvider-eG_i0Yz3.cjs';
|
|
2
2
|
import { PublicClient } from 'viem';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import React__default from 'react';
|
package/dist/wagmi.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { j as WalletAdapter, s as ProvexProviderProps, o as ProvexTheme } from './ProvexProvider-
|
|
1
|
+
import { j as WalletAdapter, s as ProvexProviderProps, o as ProvexTheme } from './ProvexProvider-eG_i0Yz3.js';
|
|
2
2
|
import { PublicClient } from 'viem';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import React__default from 'react';
|
package/dist/wagmi.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ProvexProvider, ProvexBuy } from './chunk-
|
|
1
|
+
import { ProvexProvider, ProvexBuy } from './chunk-NAGOACEK.js';
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
3
|
import { useAccount, useWalletClient, useConfig } from 'wagmi';
|
|
4
4
|
import { getPublicClient } from 'wagmi/actions';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@provex/react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0-rc.20260522201545.020a3eb",
|
|
4
4
|
"description": "Portable React buy-flow component and hooks for the Provex protocol",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -25,10 +25,12 @@
|
|
|
25
25
|
"./styles": "./dist/styles/default.css"
|
|
26
26
|
},
|
|
27
27
|
"publishConfig": {
|
|
28
|
-
"access": "
|
|
28
|
+
"access": "public"
|
|
29
29
|
},
|
|
30
|
+
"license": "MIT",
|
|
30
31
|
"files": [
|
|
31
32
|
"dist",
|
|
33
|
+
"skills",
|
|
32
34
|
"README.md"
|
|
33
35
|
],
|
|
34
36
|
"scripts": {
|
|
@@ -40,9 +42,9 @@
|
|
|
40
42
|
},
|
|
41
43
|
"dependencies": {
|
|
42
44
|
"@ponder/client": "^0.16.0",
|
|
43
|
-
"@provex/abis": "1.
|
|
44
|
-
"@provex/utils": "1.
|
|
45
|
-
"@valve-tech/wallet-adapter": "^0.
|
|
45
|
+
"@provex/abis": "1.7.0-rc.20260522201545.020a3eb",
|
|
46
|
+
"@provex/utils": "1.7.0-rc.20260522201545.020a3eb",
|
|
47
|
+
"@valve-tech/wallet-adapter": "^0.15.0"
|
|
46
48
|
},
|
|
47
49
|
"peerDependencies": {
|
|
48
50
|
"@tanstack/react-query": "^5.0.0",
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: react-integration
|
|
3
|
+
description: Use when integrating `@provex/react` — when adding the Provex buy flow to a React app, when choosing between the drop-in widget / composable phases / headless hook / framework-agnostic core, when mounting ProvexProvider, when implementing WalletAdapter against a wagmi/Privy/Walletkit/raw-viem wallet stack, when styling the widget via CSS variables or theme prop, or when handling user-rejection vs real-revert error paths. Covers the four-layer API choice, the canonical provider mount order, the WalletAdapter contract, and the dismiss-vs-fail terminal pattern that's central to the UX.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# `@provex/react` Integration
|
|
7
|
+
|
|
8
|
+
The Provex buy flow SDK — a state machine, a set of hooks, and three layers of UI on top. Framework-agnostic core; React surface layered on top.
|
|
9
|
+
|
|
10
|
+
## Four layers — pick the highest that fits
|
|
11
|
+
|
|
12
|
+
| Layer | Export | Use when |
|
|
13
|
+
|---|---|---|
|
|
14
|
+
| 3 (highest) | `<ProvexBuy>` / `<ProvexBuyWagmi>` | You want a drop-in widget; zero UI code |
|
|
15
|
+
| 2 | `<ProvexBuyProvider>` + `<BrowsePhase>` / `<CommittedPhase>` / `<ProvingPhase>` / `<CompletePhase>` | You want custom layout but our state machine |
|
|
16
|
+
| 1 | `useProvexBuy()` | You want fully custom UI; we manage state |
|
|
17
|
+
| 0 (lowest) | `createProveXClient()` | You're outside React (Node, smart account, relayer) |
|
|
18
|
+
|
|
19
|
+
Start at layer 3; drop down only when you outgrow the abstraction.
|
|
20
|
+
|
|
21
|
+
## Mount order (non-negotiable)
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
25
|
+
import { WagmiProvider } from 'wagmi' // only if using wagmi
|
|
26
|
+
import { ZKTLSProvider } from '@provex/extension-react'
|
|
27
|
+
import { ProvexProvider } from '@provex/react'
|
|
28
|
+
import { createPonderAdapter } from '@provex/indexer-client'
|
|
29
|
+
|
|
30
|
+
const queryClient = new QueryClient()
|
|
31
|
+
const indexer = createPonderAdapter()
|
|
32
|
+
|
|
33
|
+
function App() {
|
|
34
|
+
return (
|
|
35
|
+
<QueryClientProvider client={queryClient}>
|
|
36
|
+
<WagmiProvider config={wagmiConfig}>
|
|
37
|
+
<ZKTLSProvider>
|
|
38
|
+
<ProvexProvider
|
|
39
|
+
config={{ apiUrl: 'https://app.provex.com', chain: pulsechain }}
|
|
40
|
+
indexer={indexer}
|
|
41
|
+
>
|
|
42
|
+
<BuyPage />
|
|
43
|
+
</ProvexProvider>
|
|
44
|
+
</ZKTLSProvider>
|
|
45
|
+
</WagmiProvider>
|
|
46
|
+
</QueryClientProvider>
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Order rationale:
|
|
52
|
+
- `QueryClientProvider` outermost — many hooks need React Query.
|
|
53
|
+
- `WagmiProvider` next — only needed for the wagmi subpath; skip if you're wagmi-free.
|
|
54
|
+
- `ZKTLSProvider` — proof generation context lives above `ProvexProvider` because the SDK pulls it from inside.
|
|
55
|
+
- `ProvexProvider` — the state machine container.
|
|
56
|
+
|
|
57
|
+
## WalletAdapter contract
|
|
58
|
+
|
|
59
|
+
The SDK consumes any object satisfying:
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
interface WalletAdapter {
|
|
63
|
+
address?: `0x${string}`
|
|
64
|
+
sendTransaction(tx: {
|
|
65
|
+
to: `0x${string}`
|
|
66
|
+
data: `0x${string}`
|
|
67
|
+
value?: bigint
|
|
68
|
+
chainId: number
|
|
69
|
+
maxFeePerGas?: bigint
|
|
70
|
+
maxPriorityFeePerGas?: bigint
|
|
71
|
+
}): Promise<`0x${string}`>
|
|
72
|
+
readContract?(params: {
|
|
73
|
+
address: `0x${string}`
|
|
74
|
+
abi: readonly unknown[]
|
|
75
|
+
functionName: string
|
|
76
|
+
args?: readonly unknown[]
|
|
77
|
+
chainId?: number
|
|
78
|
+
}): Promise<unknown>
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Only `sendTransaction` is required. `readContract` is optional — without it, the SDK falls back to a public viem client built from `config.chain`.
|
|
83
|
+
|
|
84
|
+
### Bridges per wallet stack
|
|
85
|
+
|
|
86
|
+
| Stack | Bridge |
|
|
87
|
+
|---|---|
|
|
88
|
+
| wagmi | `useWagmiWallet()` from `@provex/react` |
|
|
89
|
+
| Privy | wrap Privy's `sendTransaction` |
|
|
90
|
+
| Walletkit | wrap the active WC session |
|
|
91
|
+
| raw viem | wrap a `WalletClient` |
|
|
92
|
+
| Safe SDK / multisig | use the layer-0 `createProveXClient()` with `prepare`-only methods |
|
|
93
|
+
|
|
94
|
+
## Drop-in widget — Layer 3
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
import { ProvexBuy } from '@provex/react'
|
|
98
|
+
import '@provex/react/styles'
|
|
99
|
+
|
|
100
|
+
<ProvexBuy
|
|
101
|
+
wallet={wallet}
|
|
102
|
+
onIntentSignaled={(intentHash, chainId) => track('Locked', { intentHash })}
|
|
103
|
+
onComplete={(intentHash, chainId) => navigate('/done')}
|
|
104
|
+
paymentMethods={['venmo', 'zelle']} // optional filter
|
|
105
|
+
/>
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
With wagmi:
|
|
109
|
+
|
|
110
|
+
```tsx
|
|
111
|
+
import { ProvexBuyWagmi } from '@provex/react'
|
|
112
|
+
<ProvexBuyWagmi onComplete={...} />
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
`ProvexBuyWagmi` reads the connected account from wagmi context — no `wallet` prop needed.
|
|
116
|
+
|
|
117
|
+
## Composable phases — Layer 2
|
|
118
|
+
|
|
119
|
+
```tsx
|
|
120
|
+
import { ProvexBuyProvider, BrowsePhase, CommittedPhase, ProvingPhase, CompletePhase } from '@provex/react'
|
|
121
|
+
|
|
122
|
+
<ProvexBuyProvider wallet={wallet} onComplete={handleDone}>
|
|
123
|
+
<div className="my-layout">
|
|
124
|
+
<Header />
|
|
125
|
+
<BrowsePhase />
|
|
126
|
+
<CommittedPhase />
|
|
127
|
+
<ProvingPhase />
|
|
128
|
+
<CompletePhase />
|
|
129
|
+
<Footer />
|
|
130
|
+
</div>
|
|
131
|
+
</ProvexBuyProvider>
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Only one phase renders at a time based on internal state — they're already mutually exclusive.
|
|
135
|
+
|
|
136
|
+
## Headless hook — Layer 1
|
|
137
|
+
|
|
138
|
+
```tsx
|
|
139
|
+
import { useProvexBuy } from '@provex/react'
|
|
140
|
+
|
|
141
|
+
function CustomBuy({ wallet }) {
|
|
142
|
+
const {
|
|
143
|
+
phase, // 'browse' | 'committed' | 'proving' | 'complete'
|
|
144
|
+
amount, setAmount,
|
|
145
|
+
deposits, selectedDeposit,
|
|
146
|
+
rate, rateDisplay,
|
|
147
|
+
canSubmit, validationMessage,
|
|
148
|
+
submitOrder, confirmPayment, reset,
|
|
149
|
+
} = useProvexBuy({ wallet })
|
|
150
|
+
// Render your own UI
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Framework-agnostic core — Layer 0
|
|
155
|
+
|
|
156
|
+
```ts
|
|
157
|
+
import { createProveXClient } from '@provex/react'
|
|
158
|
+
import { pulsechain } from 'viem/chains'
|
|
159
|
+
|
|
160
|
+
const client = createProveXClient({ chain: pulsechain, wallet })
|
|
161
|
+
|
|
162
|
+
// Standard call (signs and sends)
|
|
163
|
+
const { intentHash } = await client.signalIntent({ ... })
|
|
164
|
+
|
|
165
|
+
// Prepare-only (for Safe, Privy, multisigs, relayers)
|
|
166
|
+
const prepared = await client.addFunds.prepare({ depositId: 1n, amount: 500_000000n })
|
|
167
|
+
// → { to, data, value, chainId } — hand to any signer
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Every write method has a `.prepare(...)` variant returning the calldata without signing. Use this for smart-account batching, EIP-7702 relays, or any flow where the signing happens outside the SDK.
|
|
171
|
+
|
|
172
|
+
## Specialized hooks
|
|
173
|
+
|
|
174
|
+
| Hook | Returns | Use case |
|
|
175
|
+
|---|---|---|
|
|
176
|
+
| `useDeposits` | Available deposits filtered by token + payment method | Browse phase |
|
|
177
|
+
| `useSignalIntent` | `startOrder(...)`, status, message | Buyer commits |
|
|
178
|
+
| `useReputation` | Tier and cooldown for an address | Reputation badge |
|
|
179
|
+
| `useReputationLimits` | Effective cap, cooldown remaining | Pre-commit limit display |
|
|
180
|
+
| `useProtocolFees` | Fee info from on-chain Orchestrator | Fee preview |
|
|
181
|
+
| `usePayeeDetails` | Intent + payee info | Verification flow |
|
|
182
|
+
| `useWagmiWallet` | `WalletAdapter \| null` from wagmi | Adapt wagmi to our interface |
|
|
183
|
+
|
|
184
|
+
## Dismiss vs. fail — terminal contract
|
|
185
|
+
|
|
186
|
+
The SDK distinguishes two terminal states for transactions, and they look very different to the user:
|
|
187
|
+
|
|
188
|
+
| Terminal | When | Effect |
|
|
189
|
+
|---|---|---|
|
|
190
|
+
| `dismissTx` | User rejected the wallet popup | Silent — strip drops, no toast. The user knows they cancelled. |
|
|
191
|
+
| `failTx` | Real revert / RPC error | Strip lingers 10s with the error reason; toast surfaces the friendly message |
|
|
192
|
+
|
|
193
|
+
If you wire `WriteHookParams` for custom write sites, branch on `isUserRejectionError` before deciding which terminal to call. Conflating the two produces a doom-toast on every accidental wallet-popup-X-out, which trains users to ignore real errors.
|
|
194
|
+
|
|
195
|
+
## Styling
|
|
196
|
+
|
|
197
|
+
Import the baseline stylesheet:
|
|
198
|
+
|
|
199
|
+
```tsx
|
|
200
|
+
import '@provex/react/styles'
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Override CSS variables on `[data-provex-root]`:
|
|
204
|
+
|
|
205
|
+
```css
|
|
206
|
+
[data-provex-root] {
|
|
207
|
+
--provex-color-primary: #00d4aa;
|
|
208
|
+
--provex-color-bg: #0f0f23;
|
|
209
|
+
--provex-color-text: #ffffff;
|
|
210
|
+
--provex-border-radius: 12px;
|
|
211
|
+
--provex-max-width: 480px;
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
Or pass theme overrides as a prop:
|
|
216
|
+
|
|
217
|
+
```tsx
|
|
218
|
+
<ProvexBuy
|
|
219
|
+
wallet={wallet}
|
|
220
|
+
theme={{ accent: '#00d4aa', background: '#0f0f23', text: '#ffffff', radius: '12px' }}
|
|
221
|
+
/>
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
Data attributes (`data-provex-*`) are set on every element for fine-grained CSS targeting. Full reference in the package README.
|
|
225
|
+
|
|
226
|
+
## Chain support
|
|
227
|
+
|
|
228
|
+
| Chain | ID | Status |
|
|
229
|
+
|---|---|---|
|
|
230
|
+
| PulseChain | `369` | primary — production protocol |
|
|
231
|
+
| Base | `8453` | peer-trade contracts only |
|
|
232
|
+
|
|
233
|
+
Use `pulsechain` from `viem/chains` for the canonical setup. The SDK uses `@provex/utils/contracts` internally for address resolution — you don't need to thread addresses through props.
|
|
234
|
+
|
|
235
|
+
## Common pitfalls
|
|
236
|
+
|
|
237
|
+
- **Mounting `WagmiProvider` and `WagmiProvexProvider` from different package versions.** Yarn workspaces can dup-bundle wagmi when peer ranges don't align; `WagmiProviderNotFoundError` is the fingerprint. Add wagmi to `resolve.dedupe` if it happens.
|
|
238
|
+
- **Forgetting `QueryClientProvider` above `ProvexProvider`.** Hooks throw "no QueryClient" — non-obvious because the message doesn't mention Provex.
|
|
239
|
+
- **Conflating null indexer values with terminal state.** Intent timing fields can be `null` for a few seconds after submission. Use the helpers in `@provex/utils/intent/timing`.
|
|
240
|
+
- **Using Chakra's `Tooltip` instead of `@provex/components`' `Tooltip`.** The former misbehaves on mobile; this is a recurring footgun.
|
|
241
|
+
|
|
242
|
+
## When NOT to import from this package
|
|
243
|
+
|
|
244
|
+
- **You're on Node-only / serverless** → use the layer-0 `createProveXClient()` (also exported from this package) and skip React entirely.
|
|
245
|
+
- **You only need on-chain reads, no buy flow** → use `@provex/abis` + viem directly.
|
|
246
|
+
- **You want indexer queries without the buy state machine** → use `@provex/indexer-client` hooks standalone.
|