@provex/react 1.2.5 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ProvexProvider-DWxHsaR8.d.cts +1013 -0
- package/dist/ProvexProvider-DWxHsaR8.d.ts +1013 -0
- package/dist/chunk-7BVFQVKS.js +2165 -0
- package/dist/chunk-7BVFQVKS.js.map +1 -0
- package/dist/index.cjs +174 -107
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +35 -1030
- package/dist/index.d.ts +35 -1030
- package/dist/index.js +79 -2174
- package/dist/index.js.map +1 -1
- package/dist/wagmi.cjs +2142 -0
- package/dist/wagmi.cjs.map +1 -0
- package/dist/wagmi.d.cts +82 -0
- package/dist/wagmi.d.ts +82 -0
- package/dist/wagmi.js +72 -0
- package/dist/wagmi.js.map +1 -0
- package/package.json +16 -5
package/dist/wagmi.d.cts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { j as WalletAdapter, s as ProvexProviderProps, o as ProvexTheme } from './ProvexProvider-DWxHsaR8.cjs';
|
|
2
|
+
import { PublicClient } from 'viem';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
+
import React__default from 'react';
|
|
5
|
+
import { ProviderKey } from '@provex/utils/payment';
|
|
6
|
+
import '@tanstack/react-query';
|
|
7
|
+
import '@provex/utils/chain';
|
|
8
|
+
import '@provex/utils/reputation';
|
|
9
|
+
import '@provex/utils/currencies';
|
|
10
|
+
import '@provex/utils/tokens';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @fileoverview Bridge wagmi's wallet to the WalletAdapter interface.
|
|
14
|
+
*
|
|
15
|
+
* Creates a memoized WalletAdapter from wagmi's `useWalletClient` and
|
|
16
|
+
* `useAccount` hooks. Pass the result to `useProveXClient(wallet)` or
|
|
17
|
+
* directly to any hook that accepts a WalletAdapter.
|
|
18
|
+
*
|
|
19
|
+
* This hook lives in `@provex/react/wagmi` so that the main entry
|
|
20
|
+
* does not import `wagmi`. Consumers without wagmi ignore it.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Create a WalletAdapter from the connected wagmi wallet.
|
|
25
|
+
*
|
|
26
|
+
* Returns `null` when no wallet is connected.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```tsx
|
|
30
|
+
* import { useWagmiWallet } from '@provex/react/wagmi'
|
|
31
|
+
* const wallet = useWagmiWallet()
|
|
32
|
+
* const client = useProveXClient(wallet ?? undefined)
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
declare function useWagmiWallet(): WalletAdapter | null;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @fileoverview Build a ProvexProvider `publicClients` map from wagmi config.
|
|
39
|
+
*
|
|
40
|
+
* Reads every configured chain from WagmiProvider and exposes each chain's
|
|
41
|
+
* public client so Provex hooks can make RPC calls without invoking
|
|
42
|
+
* wagmi APIs directly.
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Returns a `{ chainId: publicClient }` map ready to pass to `ProvexProvider`'s
|
|
47
|
+
* `publicClients` prop. Covers every chain registered on the surrounding
|
|
48
|
+
* WagmiProvider.
|
|
49
|
+
*/
|
|
50
|
+
declare function useWagmiPublicClients(): Record<number, PublicClient>;
|
|
51
|
+
|
|
52
|
+
type WagmiProvexProviderProps = Omit<ProvexProviderProps, 'publicClient' | 'publicClients' | 'wallet'>;
|
|
53
|
+
/**
|
|
54
|
+
* ProvexProvider preset for wagmi apps. Equivalent to manually passing
|
|
55
|
+
* `publicClients={useWagmiPublicClients()}` and `wallet={useWagmiWallet()}`.
|
|
56
|
+
*/
|
|
57
|
+
declare function WagmiProvexProvider(props: WagmiProvexProviderProps): react_jsx_runtime.JSX.Element;
|
|
58
|
+
|
|
59
|
+
/** Props for the ProvexBuyWagmi component. Same as BuyProps minus `wallet`. */
|
|
60
|
+
interface ProvexBuyWagmiProps {
|
|
61
|
+
/** Called when the user signals intent (USDC reserved). */
|
|
62
|
+
onIntentSignaled?: (intentHash: string, chainId: number) => void;
|
|
63
|
+
/** Called when the full flow completes (USDC released). */
|
|
64
|
+
onComplete?: (intentHash: string, chainId: number) => void;
|
|
65
|
+
/** Restrict to specific payment methods. */
|
|
66
|
+
paymentMethods?: ProviderKey[];
|
|
67
|
+
/** CSS class name for the root container. */
|
|
68
|
+
className?: string;
|
|
69
|
+
/** Inline styles for the root container. */
|
|
70
|
+
style?: React__default.CSSProperties;
|
|
71
|
+
/** Theme overrides applied as CSS custom properties. */
|
|
72
|
+
theme?: ProvexTheme;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* ProvexBuyWagmi — drop-in buy widget for wagmi apps.
|
|
76
|
+
*
|
|
77
|
+
* Reads the connected wallet from wagmi context automatically.
|
|
78
|
+
* No need to create a WalletAdapter manually.
|
|
79
|
+
*/
|
|
80
|
+
declare function ProvexBuyWagmi({ onIntentSignaled, onComplete, paymentMethods, className, style, theme, }: ProvexBuyWagmiProps): react_jsx_runtime.JSX.Element;
|
|
81
|
+
|
|
82
|
+
export { ProvexBuyWagmi, type ProvexBuyWagmiProps, WagmiProvexProvider, type WagmiProvexProviderProps, useWagmiPublicClients, useWagmiWallet };
|
package/dist/wagmi.d.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { j as WalletAdapter, s as ProvexProviderProps, o as ProvexTheme } from './ProvexProvider-DWxHsaR8.js';
|
|
2
|
+
import { PublicClient } from 'viem';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
+
import React__default from 'react';
|
|
5
|
+
import { ProviderKey } from '@provex/utils/payment';
|
|
6
|
+
import '@tanstack/react-query';
|
|
7
|
+
import '@provex/utils/chain';
|
|
8
|
+
import '@provex/utils/reputation';
|
|
9
|
+
import '@provex/utils/currencies';
|
|
10
|
+
import '@provex/utils/tokens';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @fileoverview Bridge wagmi's wallet to the WalletAdapter interface.
|
|
14
|
+
*
|
|
15
|
+
* Creates a memoized WalletAdapter from wagmi's `useWalletClient` and
|
|
16
|
+
* `useAccount` hooks. Pass the result to `useProveXClient(wallet)` or
|
|
17
|
+
* directly to any hook that accepts a WalletAdapter.
|
|
18
|
+
*
|
|
19
|
+
* This hook lives in `@provex/react/wagmi` so that the main entry
|
|
20
|
+
* does not import `wagmi`. Consumers without wagmi ignore it.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Create a WalletAdapter from the connected wagmi wallet.
|
|
25
|
+
*
|
|
26
|
+
* Returns `null` when no wallet is connected.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```tsx
|
|
30
|
+
* import { useWagmiWallet } from '@provex/react/wagmi'
|
|
31
|
+
* const wallet = useWagmiWallet()
|
|
32
|
+
* const client = useProveXClient(wallet ?? undefined)
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
declare function useWagmiWallet(): WalletAdapter | null;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @fileoverview Build a ProvexProvider `publicClients` map from wagmi config.
|
|
39
|
+
*
|
|
40
|
+
* Reads every configured chain from WagmiProvider and exposes each chain's
|
|
41
|
+
* public client so Provex hooks can make RPC calls without invoking
|
|
42
|
+
* wagmi APIs directly.
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Returns a `{ chainId: publicClient }` map ready to pass to `ProvexProvider`'s
|
|
47
|
+
* `publicClients` prop. Covers every chain registered on the surrounding
|
|
48
|
+
* WagmiProvider.
|
|
49
|
+
*/
|
|
50
|
+
declare function useWagmiPublicClients(): Record<number, PublicClient>;
|
|
51
|
+
|
|
52
|
+
type WagmiProvexProviderProps = Omit<ProvexProviderProps, 'publicClient' | 'publicClients' | 'wallet'>;
|
|
53
|
+
/**
|
|
54
|
+
* ProvexProvider preset for wagmi apps. Equivalent to manually passing
|
|
55
|
+
* `publicClients={useWagmiPublicClients()}` and `wallet={useWagmiWallet()}`.
|
|
56
|
+
*/
|
|
57
|
+
declare function WagmiProvexProvider(props: WagmiProvexProviderProps): react_jsx_runtime.JSX.Element;
|
|
58
|
+
|
|
59
|
+
/** Props for the ProvexBuyWagmi component. Same as BuyProps minus `wallet`. */
|
|
60
|
+
interface ProvexBuyWagmiProps {
|
|
61
|
+
/** Called when the user signals intent (USDC reserved). */
|
|
62
|
+
onIntentSignaled?: (intentHash: string, chainId: number) => void;
|
|
63
|
+
/** Called when the full flow completes (USDC released). */
|
|
64
|
+
onComplete?: (intentHash: string, chainId: number) => void;
|
|
65
|
+
/** Restrict to specific payment methods. */
|
|
66
|
+
paymentMethods?: ProviderKey[];
|
|
67
|
+
/** CSS class name for the root container. */
|
|
68
|
+
className?: string;
|
|
69
|
+
/** Inline styles for the root container. */
|
|
70
|
+
style?: React__default.CSSProperties;
|
|
71
|
+
/** Theme overrides applied as CSS custom properties. */
|
|
72
|
+
theme?: ProvexTheme;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* ProvexBuyWagmi — drop-in buy widget for wagmi apps.
|
|
76
|
+
*
|
|
77
|
+
* Reads the connected wallet from wagmi context automatically.
|
|
78
|
+
* No need to create a WalletAdapter manually.
|
|
79
|
+
*/
|
|
80
|
+
declare function ProvexBuyWagmi({ onIntentSignaled, onComplete, paymentMethods, className, style, theme, }: ProvexBuyWagmiProps): react_jsx_runtime.JSX.Element;
|
|
81
|
+
|
|
82
|
+
export { ProvexBuyWagmi, type ProvexBuyWagmiProps, WagmiProvexProvider, type WagmiProvexProviderProps, useWagmiPublicClients, useWagmiWallet };
|
package/dist/wagmi.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { ProvexProvider, ProvexBuy } from './chunk-7BVFQVKS.js';
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { useAccount, useWalletClient, useConfig } from 'wagmi';
|
|
4
|
+
import { getPublicClient } from 'wagmi/actions';
|
|
5
|
+
import { jsx } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
function useWagmiWallet() {
|
|
8
|
+
const { address } = useAccount();
|
|
9
|
+
const { data: walletClient } = useWalletClient();
|
|
10
|
+
return useMemo(() => {
|
|
11
|
+
if (!walletClient || !address) return null;
|
|
12
|
+
return {
|
|
13
|
+
address,
|
|
14
|
+
async sendTransaction(tx) {
|
|
15
|
+
return walletClient.sendTransaction({
|
|
16
|
+
to: tx.to,
|
|
17
|
+
data: tx.data,
|
|
18
|
+
value: tx.value ?? 0n,
|
|
19
|
+
chain: walletClient.chain,
|
|
20
|
+
maxFeePerGas: tx.maxFeePerGas,
|
|
21
|
+
maxPriorityFeePerGas: tx.maxPriorityFeePerGas
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}, [walletClient, address]);
|
|
26
|
+
}
|
|
27
|
+
function useWagmiPublicClients() {
|
|
28
|
+
const config = useConfig();
|
|
29
|
+
return useMemo(() => {
|
|
30
|
+
const clients = {};
|
|
31
|
+
for (const chain of config.chains) {
|
|
32
|
+
const client = getPublicClient(config, { chainId: chain.id });
|
|
33
|
+
if (client) clients[chain.id] = client;
|
|
34
|
+
}
|
|
35
|
+
return clients;
|
|
36
|
+
}, [config]);
|
|
37
|
+
}
|
|
38
|
+
function WagmiProvexProvider(props) {
|
|
39
|
+
const publicClients = useWagmiPublicClients();
|
|
40
|
+
const wallet = useWagmiWallet() ?? void 0;
|
|
41
|
+
return /* @__PURE__ */ jsx(ProvexProvider, { ...props, publicClients, wallet });
|
|
42
|
+
}
|
|
43
|
+
var DISCONNECTED_WALLET = {
|
|
44
|
+
address: void 0,
|
|
45
|
+
sendTransaction: () => Promise.reject(new Error("Wallet not connected"))
|
|
46
|
+
};
|
|
47
|
+
function ProvexBuyWagmi({
|
|
48
|
+
onIntentSignaled,
|
|
49
|
+
onComplete,
|
|
50
|
+
paymentMethods,
|
|
51
|
+
className,
|
|
52
|
+
style,
|
|
53
|
+
theme
|
|
54
|
+
}) {
|
|
55
|
+
const wallet = useWagmiWallet() ?? DISCONNECTED_WALLET;
|
|
56
|
+
return /* @__PURE__ */ jsx(
|
|
57
|
+
ProvexBuy,
|
|
58
|
+
{
|
|
59
|
+
wallet,
|
|
60
|
+
onIntentSignaled,
|
|
61
|
+
onComplete,
|
|
62
|
+
paymentMethods,
|
|
63
|
+
className,
|
|
64
|
+
style,
|
|
65
|
+
theme
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export { ProvexBuyWagmi, WagmiProvexProvider, useWagmiPublicClients, useWagmiWallet };
|
|
71
|
+
//# sourceMappingURL=wagmi.js.map
|
|
72
|
+
//# sourceMappingURL=wagmi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/wagmi/useWagmiWallet.ts","../src/wagmi/useWagmiPublicClients.ts","../src/wagmi/WagmiProvexProvider.tsx","../src/wagmi/ProvexBuyWagmi.tsx"],"names":["useMemo","jsx"],"mappings":";;;;;;AA4BO,SAAS,cAAA,GAAuC;AACrD,EAAA,MAAM,EAAE,OAAA,EAAQ,GAAI,UAAA,EAAW;AAC/B,EAAA,MAAM,EAAE,IAAA,EAAM,YAAA,EAAa,GAAI,eAAA,EAAgB;AAE/C,EAAA,OAAO,QAAQ,MAAM;AACnB,IAAA,IAAI,CAAC,YAAA,IAAgB,CAAC,OAAA,EAAS,OAAO,IAAA;AAEtC,IAAA,OAAO;AAAA,MACL,OAAA;AAAA,MACA,MAAM,gBAAgB,EAAA,EAAI;AACxB,QAAA,OAAO,aAAa,eAAA,CAAgB;AAAA,UAClC,IAAI,EAAA,CAAG,EAAA;AAAA,UACP,MAAM,EAAA,CAAG,IAAA;AAAA,UACT,KAAA,EAAO,GAAG,KAAA,IAAS,EAAA;AAAA,UACnB,OAAO,YAAA,CAAa,KAAA;AAAA,UACpB,cAAc,EAAA,CAAG,YAAA;AAAA,UACjB,sBAAsB,EAAA,CAAG;AAAA,SAC1B,CAAA;AAAA,MACH;AAAA,KACF;AAAA,EACF,CAAA,EAAG,CAAC,YAAA,EAAc,OAAO,CAAC,CAAA;AAC5B;AC/BO,SAAS,qBAAA,GAAsD;AACpE,EAAA,MAAM,SAAS,SAAA,EAAU;AAEzB,EAAA,OAAOA,QAAQ,MAAM;AACnB,IAAA,MAAM,UAAwC,EAAC;AAC/C,IAAA,KAAA,MAAW,KAAA,IAAS,OAAO,MAAA,EAAQ;AACjC,MAAA,MAAM,SAAS,eAAA,CAAgB,MAAA,EAAQ,EAAE,OAAA,EAAS,KAAA,CAAM,IAAI,CAAA;AAC5D,MAAA,IAAI,MAAA,EAAQ,OAAA,CAAQ,KAAA,CAAM,EAAE,CAAA,GAAI,MAAA;AAAA,IAClC;AACA,IAAA,OAAO,OAAA;AAAA,EACT,CAAA,EAAG,CAAC,MAAM,CAAC,CAAA;AACb;ACQO,SAAS,oBAAoB,KAAA,EAAiC;AACnE,EAAA,MAAM,gBAAgB,qBAAA,EAAsB;AAC5C,EAAA,MAAM,MAAA,GAAS,gBAAe,IAAK,MAAA;AAEnC,EAAA,uBACE,GAAA,CAAC,cAAA,EAAA,EAAgB,GAAG,KAAA,EAAO,eAA8B,MAAA,EAAgB,CAAA;AAE7E;ACAA,IAAM,mBAAA,GAAsB;AAAA,EAC1B,OAAA,EAAS,MAAA;AAAA,EACT,iBAAiB,MAAM,OAAA,CAAQ,OAAO,IAAI,KAAA,CAAM,sBAAsB,CAAC;AACzE,CAAA;AAQO,SAAS,cAAA,CAAe;AAAA,EAC7B,gBAAA;AAAA,EACA,UAAA;AAAA,EACA,cAAA;AAAA,EACA,SAAA;AAAA,EACA,KAAA;AAAA,EACA;AACF,CAAA,EAAwB;AACtB,EAAA,MAAM,MAAA,GAAS,gBAAe,IAAK,mBAAA;AAEnC,EAAA,uBACEC,GAAAA;AAAA,IAAC,SAAA;AAAA,IAAA;AAAA,MACC,MAAA;AAAA,MACA,gBAAA;AAAA,MACA,UAAA;AAAA,MACA,cAAA;AAAA,MACA,SAAA;AAAA,MACA,KAAA;AAAA,MACA;AAAA;AAAA,GACF;AAEJ","file":"wagmi.js","sourcesContent":["/**\n * @fileoverview Bridge wagmi's wallet to the WalletAdapter interface.\n *\n * Creates a memoized WalletAdapter from wagmi's `useWalletClient` and\n * `useAccount` hooks. Pass the result to `useProveXClient(wallet)` or\n * directly to any hook that accepts a WalletAdapter.\n *\n * This hook lives in `@provex/react/wagmi` so that the main entry\n * does not import `wagmi`. Consumers without wagmi ignore it.\n */\n\nimport { useMemo } from 'react'\nimport { useAccount, useWalletClient } from 'wagmi'\nimport type { Hex } from 'viem'\nimport type { WalletAdapter } from '../client/types'\n\n/**\n * Create a WalletAdapter from the connected wagmi wallet.\n *\n * Returns `null` when no wallet is connected.\n *\n * @example\n * ```tsx\n * import { useWagmiWallet } from '@provex/react/wagmi'\n * const wallet = useWagmiWallet()\n * const client = useProveXClient(wallet ?? undefined)\n * ```\n */\nexport function useWagmiWallet(): WalletAdapter | null {\n const { address } = useAccount()\n const { data: walletClient } = useWalletClient()\n\n return useMemo(() => {\n if (!walletClient || !address) return null\n\n return {\n address: address as Hex,\n async sendTransaction(tx) {\n return walletClient.sendTransaction({\n to: tx.to,\n data: tx.data,\n value: tx.value ?? 0n,\n chain: walletClient.chain,\n maxFeePerGas: tx.maxFeePerGas,\n maxPriorityFeePerGas: tx.maxPriorityFeePerGas,\n })\n },\n }\n }, [walletClient, address])\n}\n","/**\n * @fileoverview Build a ProvexProvider `publicClients` map from wagmi config.\n *\n * Reads every configured chain from WagmiProvider and exposes each chain's\n * public client so Provex hooks can make RPC calls without invoking\n * wagmi APIs directly.\n */\n\nimport { useMemo } from 'react'\nimport { useConfig } from 'wagmi'\nimport { getPublicClient } from 'wagmi/actions'\nimport type { PublicClient } from 'viem'\n\n/**\n * Returns a `{ chainId: publicClient }` map ready to pass to `ProvexProvider`'s\n * `publicClients` prop. Covers every chain registered on the surrounding\n * WagmiProvider.\n */\nexport function useWagmiPublicClients(): Record<number, PublicClient> {\n const config = useConfig()\n\n return useMemo(() => {\n const clients: Record<number, PublicClient> = {}\n for (const chain of config.chains) {\n const client = getPublicClient(config, { chainId: chain.id })\n if (client) clients[chain.id] = client as unknown as PublicClient\n }\n return clients\n }, [config])\n}\n","/**\n * @fileoverview Drop-in provider that wires wagmi into ProvexProvider.\n *\n * Must be placed inside a `WagmiProvider`. Reads wagmi's configured chains\n * and wallet, then hands them to ProvexProvider so Provex hooks can work\n * without importing wagmi themselves.\n *\n * @example\n * ```tsx\n * import { WagmiProvider } from 'wagmi'\n * import { WagmiProvexProvider } from '@provex/react/wagmi'\n * import { createPonderAdapter } from '@provex/indexer-client'\n *\n * <WagmiProvider config={wagmiConfig}>\n * <WagmiProvexProvider\n * config={{ apiUrl: 'https://app.provex.com', chain: base }}\n * indexer={createPonderAdapter()}\n * >\n * <App />\n * </WagmiProvexProvider>\n * </WagmiProvider>\n * ```\n */\n\nimport { ProvexProvider, type ProvexProviderProps } from '../ProvexProvider'\nimport { useWagmiWallet } from './useWagmiWallet'\nimport { useWagmiPublicClients } from './useWagmiPublicClients'\n\nexport type WagmiProvexProviderProps = Omit<\n ProvexProviderProps,\n 'publicClient' | 'publicClients' | 'wallet'\n>\n\n/**\n * ProvexProvider preset for wagmi apps. Equivalent to manually passing\n * `publicClients={useWagmiPublicClients()}` and `wallet={useWagmiWallet()}`.\n */\nexport function WagmiProvexProvider(props: WagmiProvexProviderProps) {\n const publicClients = useWagmiPublicClients()\n const wallet = useWagmiWallet() ?? undefined\n\n return (\n <ProvexProvider {...props} publicClients={publicClients} wallet={wallet} />\n )\n}\n","/**\n * @fileoverview ProvexBuyWagmi — convenience wrapper for wagmi apps.\n *\n * Reads the connected wallet from wagmi context via `useWagmiWallet()`\n * and passes it to the standard `ProvexBuy` widget. Consumers only need\n * `WagmiProvider` + `ProvexProvider` (or `WagmiProvexProvider`) above\n * this component.\n *\n * When no wallet is connected, the widget still renders in browse mode\n * (showing deposits and rates) with the submit button disabled.\n *\n * @example\n * ```tsx\n * import { ProvexBuyWagmi } from '@provex/react/wagmi'\n * import '@provex/react/styles'\n *\n * <ProvexBuyWagmi\n * onComplete={(hash, chainId) => console.log('Done!', hash)}\n * />\n * ```\n */\n\nimport React from 'react'\nimport { ProvexBuy } from '../ProvexBuy'\nimport { useWagmiWallet } from './useWagmiWallet'\nimport type { ProvexTheme } from '../types'\nimport type { ProviderKey } from '@provex/utils/payment'\n\n/** Props for the ProvexBuyWagmi component. Same as BuyProps minus `wallet`. */\nexport interface ProvexBuyWagmiProps {\n /** Called when the user signals intent (USDC reserved). */\n onIntentSignaled?: (intentHash: string, chainId: number) => void\n /** Called when the full flow completes (USDC released). */\n onComplete?: (intentHash: string, chainId: number) => void\n /** Restrict to specific payment methods. */\n paymentMethods?: ProviderKey[]\n /** CSS class name for the root container. */\n className?: string\n /** Inline styles for the root container. */\n style?: React.CSSProperties\n /** Theme overrides applied as CSS custom properties. */\n theme?: ProvexTheme\n}\n\nconst DISCONNECTED_WALLET = {\n address: undefined,\n sendTransaction: () => Promise.reject(new Error('Wallet not connected')),\n} as const\n\n/**\n * ProvexBuyWagmi — drop-in buy widget for wagmi apps.\n *\n * Reads the connected wallet from wagmi context automatically.\n * No need to create a WalletAdapter manually.\n */\nexport function ProvexBuyWagmi({\n onIntentSignaled,\n onComplete,\n paymentMethods,\n className,\n style,\n theme,\n}: ProvexBuyWagmiProps) {\n const wallet = useWagmiWallet() ?? DISCONNECTED_WALLET\n\n return (\n <ProvexBuy\n wallet={wallet}\n onIntentSignaled={onIntentSignaled}\n onComplete={onComplete}\n paymentMethods={paymentMethods}\n className={className}\n style={style}\n theme={theme}\n />\n )\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@provex/react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Portable React buy-flow component and hooks for the Provex protocol",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -17,6 +17,11 @@
|
|
|
17
17
|
"import": "./dist/index.js",
|
|
18
18
|
"require": "./dist/index.cjs"
|
|
19
19
|
},
|
|
20
|
+
"./wagmi": {
|
|
21
|
+
"types": "./dist/wagmi.d.ts",
|
|
22
|
+
"import": "./dist/wagmi.js",
|
|
23
|
+
"require": "./dist/wagmi.cjs"
|
|
24
|
+
},
|
|
20
25
|
"./styles": "./dist/styles/default.css"
|
|
21
26
|
},
|
|
22
27
|
"publishConfig": {
|
|
@@ -35,15 +40,20 @@
|
|
|
35
40
|
},
|
|
36
41
|
"dependencies": {
|
|
37
42
|
"@ponder/client": "^0.16.0",
|
|
38
|
-
"@provex/abis": "1.
|
|
39
|
-
"@provex/utils": "1.
|
|
43
|
+
"@provex/abis": "1.3.0",
|
|
44
|
+
"@provex/utils": "1.3.0"
|
|
40
45
|
},
|
|
41
46
|
"peerDependencies": {
|
|
42
47
|
"@tanstack/react-query": "^5.0.0",
|
|
43
|
-
"react": "^18.0.0",
|
|
48
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
44
49
|
"viem": "^2.0.0",
|
|
45
50
|
"wagmi": "^2.0.0"
|
|
46
51
|
},
|
|
52
|
+
"peerDependenciesMeta": {
|
|
53
|
+
"wagmi": {
|
|
54
|
+
"optional": true
|
|
55
|
+
}
|
|
56
|
+
},
|
|
47
57
|
"devDependencies": {
|
|
48
58
|
"@testing-library/dom": "^10.0.0",
|
|
49
59
|
"@testing-library/react": "^16.0.0",
|
|
@@ -52,6 +62,7 @@
|
|
|
52
62
|
"react-dom": "^18.0.0",
|
|
53
63
|
"tsup": "^8.0.0",
|
|
54
64
|
"typescript": "^5.9.2",
|
|
55
|
-
"vitest": "^3.0.0"
|
|
65
|
+
"vitest": "^3.0.0",
|
|
66
|
+
"wagmi": "^2.0.0"
|
|
56
67
|
}
|
|
57
68
|
}
|