pepay-streams-sdk 0.1.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.
Files changed (62) hide show
  1. package/README.md +405 -0
  2. package/dist/api/index.d.mts +321 -0
  3. package/dist/api/index.d.ts +321 -0
  4. package/dist/api/index.js +312 -0
  5. package/dist/api/index.js.map +1 -0
  6. package/dist/api/index.mjs +306 -0
  7. package/dist/api/index.mjs.map +1 -0
  8. package/dist/automation/index.d.mts +140 -0
  9. package/dist/automation/index.d.ts +140 -0
  10. package/dist/automation/index.js +331 -0
  11. package/dist/automation/index.js.map +1 -0
  12. package/dist/automation/index.mjs +326 -0
  13. package/dist/automation/index.mjs.map +1 -0
  14. package/dist/campaigns/index.d.mts +286 -0
  15. package/dist/campaigns/index.d.ts +286 -0
  16. package/dist/campaigns/index.js +652 -0
  17. package/dist/campaigns/index.js.map +1 -0
  18. package/dist/campaigns/index.mjs +645 -0
  19. package/dist/campaigns/index.mjs.map +1 -0
  20. package/dist/claims/index.d.mts +190 -0
  21. package/dist/claims/index.d.ts +190 -0
  22. package/dist/claims/index.js +414 -0
  23. package/dist/claims/index.js.map +1 -0
  24. package/dist/claims/index.mjs +409 -0
  25. package/dist/claims/index.mjs.map +1 -0
  26. package/dist/index-BTG0TRJt.d.mts +555 -0
  27. package/dist/index-BTG0TRJt.d.ts +555 -0
  28. package/dist/index.d.mts +170 -0
  29. package/dist/index.d.ts +170 -0
  30. package/dist/index.js +2926 -0
  31. package/dist/index.js.map +1 -0
  32. package/dist/index.mjs +2888 -0
  33. package/dist/index.mjs.map +1 -0
  34. package/dist/marketplace/index.d.mts +225 -0
  35. package/dist/marketplace/index.d.ts +225 -0
  36. package/dist/marketplace/index.js +529 -0
  37. package/dist/marketplace/index.js.map +1 -0
  38. package/dist/marketplace/index.mjs +524 -0
  39. package/dist/marketplace/index.mjs.map +1 -0
  40. package/dist/react/index.d.mts +185 -0
  41. package/dist/react/index.d.ts +185 -0
  42. package/dist/react/index.js +340 -0
  43. package/dist/react/index.js.map +1 -0
  44. package/dist/react/index.mjs +333 -0
  45. package/dist/react/index.mjs.map +1 -0
  46. package/dist/staking/index.d.mts +158 -0
  47. package/dist/staking/index.d.ts +158 -0
  48. package/dist/staking/index.js +359 -0
  49. package/dist/staking/index.js.map +1 -0
  50. package/dist/staking/index.mjs +354 -0
  51. package/dist/staking/index.mjs.map +1 -0
  52. package/package.json +106 -0
  53. package/src/api/index.ts +577 -0
  54. package/src/automation/index.ts +436 -0
  55. package/src/campaigns/index.ts +835 -0
  56. package/src/claims/index.ts +530 -0
  57. package/src/client.ts +518 -0
  58. package/src/index.ts +101 -0
  59. package/src/marketplace/index.ts +730 -0
  60. package/src/react/index.ts +498 -0
  61. package/src/staking/index.ts +449 -0
  62. package/src/types/index.ts +631 -0
@@ -0,0 +1,185 @@
1
+ import { Address } from 'viem';
2
+ import { P as PepayStreamsConfig } from '../index-BTG0TRJt.mjs';
3
+ import { PepayStreamsClient, PepayStreamsClientWithSigner } from '../index.mjs';
4
+ import '../campaigns/index.mjs';
5
+ import '../claims/index.mjs';
6
+ import '../staking/index.mjs';
7
+ import '../marketplace/index.mjs';
8
+ import '../automation/index.mjs';
9
+ import '../api/index.mjs';
10
+ import '@pepay-streams/shared';
11
+
12
+ /**
13
+ * React Integration Helpers
14
+ *
15
+ * Provides React-friendly patterns for using the SDK:
16
+ * - Context provider
17
+ * - Hooks for common operations
18
+ * - Type-safe query helpers
19
+ */
20
+
21
+ /**
22
+ * SDK context value type for React context
23
+ */
24
+ interface PepayStreamsContextValue {
25
+ /** SDK client instance */
26
+ client: PepayStreamsClient | PepayStreamsClientWithSigner | null;
27
+ /** Whether the client has a signer */
28
+ isConnected: boolean;
29
+ /** Connected wallet address */
30
+ address: Address | null;
31
+ /** Chain ID */
32
+ chainId: number;
33
+ /** Diamond contract address */
34
+ diamondAddress: Address;
35
+ }
36
+ /**
37
+ * Configuration for creating SDK context
38
+ */
39
+ interface CreateContextConfig extends PepayStreamsConfig {
40
+ /** Auto-connect on mount */
41
+ autoConnect?: boolean;
42
+ }
43
+ /**
44
+ * Helper to create SDK client configuration from environment
45
+ */
46
+ declare function getConfigFromEnv(): Partial<PepayStreamsConfig>;
47
+ /**
48
+ * Example React context creation pattern
49
+ *
50
+ * @example
51
+ * ```tsx
52
+ * // contexts/PepayStreams.tsx
53
+ * import { createContext, useContext, useState, useEffect } from 'react';
54
+ * import { PepayStreamsClient, PepayStreamsClientWithSigner } from '@pepay-streams/sdk';
55
+ * import { useWalletClient, usePublicClient, useAccount } from 'wagmi';
56
+ *
57
+ * const PepayStreamsContext = createContext<PepayStreamsContextValue | null>(null);
58
+ *
59
+ * export function PepayStreamsProvider({ children, config }) {
60
+ * const { address, isConnected } = useAccount();
61
+ * const publicClient = usePublicClient();
62
+ * const { data: walletClient } = useWalletClient();
63
+ * const [client, setClient] = useState<PepayStreamsClient | null>(null);
64
+ *
65
+ * useEffect(() => {
66
+ * if (!publicClient) return;
67
+ *
68
+ * if (walletClient && isConnected) {
69
+ * setClient(new PepayStreamsClient(config).withSigner(walletClient));
70
+ * } else {
71
+ * setClient(new PepayStreamsClient(config));
72
+ * }
73
+ * }, [publicClient, walletClient, isConnected]);
74
+ *
75
+ * return (
76
+ * <PepayStreamsContext.Provider value={{ client, isConnected, address, ... }}>
77
+ * {children}
78
+ * </PepayStreamsContext.Provider>
79
+ * );
80
+ * }
81
+ *
82
+ * export function usePepayStreams() {
83
+ * const context = useContext(PepayStreamsContext);
84
+ * if (!context) throw new Error('Must be used within PepayStreamsProvider');
85
+ * return context;
86
+ * }
87
+ * ```
88
+ */
89
+ declare const CONTEXT_EXAMPLE = "\n// Example usage with wagmi and React\n\nimport { createContext, useContext, useState, useEffect, ReactNode } from 'react';\nimport { PepayStreamsClient, PepayStreamsClientWithSigner, PepayStreamsConfig } from '@pepay-streams/sdk';\nimport { useWalletClient, usePublicClient, useAccount, useChainId } from 'wagmi';\n\ninterface PepayStreamsContextValue {\n client: PepayStreamsClient | PepayStreamsClientWithSigner | null;\n isConnected: boolean;\n isLoading: boolean;\n}\n\nconst PepayStreamsContext = createContext<PepayStreamsContextValue>({\n client: null,\n isConnected: false,\n isLoading: true,\n});\n\nexport function PepayStreamsProvider({\n children,\n config,\n}: {\n children: ReactNode;\n config: PepayStreamsConfig;\n}) {\n const { isConnected } = useAccount();\n const chainId = useChainId();\n const { data: walletClient, isLoading: walletLoading } = useWalletClient();\n const [client, setClient] = useState<PepayStreamsClient | null>(null);\n\n useEffect(() => {\n const newClient = new PepayStreamsClient({\n ...config,\n chainId,\n });\n\n if (walletClient && isConnected) {\n setClient(newClient.withSigner(walletClient));\n } else {\n setClient(newClient);\n }\n }, [walletClient, isConnected, chainId, config]);\n\n return (\n <PepayStreamsContext.Provider\n value={{\n client,\n isConnected,\n isLoading: walletLoading,\n }}\n >\n {children}\n </PepayStreamsContext.Provider>\n );\n}\n\nexport function usePepayStreams() {\n return useContext(PepayStreamsContext);\n}\n\n// Usage in components:\nfunction ClaimButton({ campaignId }: { campaignId: bigint }) {\n const { client, isConnected } = usePepayStreams();\n const [loading, setLoading] = useState(false);\n\n const handleClaim = async () => {\n if (!client || !isConnected) return;\n\n setLoading(true);\n try {\n const result = await client.claims.claim({ campaignId });\n await result.wait();\n console.log('Claimed!');\n } catch (error) {\n console.error('Claim failed:', error);\n } finally {\n setLoading(false);\n }\n };\n\n return (\n <button onClick={handleClaim} disabled={!isConnected || loading}>\n {loading ? 'Claiming...' : 'Claim'}\n </button>\n );\n}\n";
90
+ /**
91
+ * Query key factories for react-query integration
92
+ *
93
+ * @example
94
+ * ```tsx
95
+ * import { useQuery } from '@tanstack/react-query';
96
+ * import { queryKeys, usePepayStreams } from '@pepay-streams/sdk/react';
97
+ *
98
+ * function CampaignDetails({ id }) {
99
+ * const { client } = usePepayStreams();
100
+ *
101
+ * const { data: campaign, isLoading } = useQuery({
102
+ * queryKey: queryKeys.campaign(id),
103
+ * queryFn: () => client.campaigns.getCampaign(BigInt(id)),
104
+ * enabled: !!client,
105
+ * });
106
+ *
107
+ * if (isLoading) return <div>Loading...</div>;
108
+ * return <div>{campaign?.name}</div>;
109
+ * }
110
+ * ```
111
+ */
112
+ declare const queryKeys: {
113
+ campaigns: (params?: Record<string, unknown>) => readonly ["pepay", "campaigns", Record<string, unknown> | undefined];
114
+ campaign: (id: string | bigint) => readonly ["pepay", "campaign", string];
115
+ campaignRecipients: (id: string | bigint, page?: number) => readonly ["pepay", "campaign", string, "recipients", number | undefined];
116
+ campaignActivity: (id: string | bigint, page?: number) => readonly ["pepay", "campaign", string, "activity", number | undefined];
117
+ dueAmount: (campaignId: bigint, address: Address) => readonly ["pepay", "dueAmount", string, `0x${string}`];
118
+ recipientStatus: (campaignId: bigint, address: Address) => readonly ["pepay", "recipientStatus", string, `0x${string}`];
119
+ stakingPools: (params?: Record<string, unknown>) => readonly ["pepay", "staking", "pools", Record<string, unknown> | undefined];
120
+ stakingPool: (id: string | bigint) => readonly ["pepay", "staking", "pool", string];
121
+ userStake: (poolId: bigint, address: Address) => readonly ["pepay", "staking", "userStake", string, `0x${string}`];
122
+ pendingRewards: (poolId: bigint, address: Address) => readonly ["pepay", "staking", "pendingRewards", string, `0x${string}`];
123
+ orders: (params?: Record<string, unknown>) => readonly ["pepay", "marketplace", "orders", Record<string, unknown> | undefined];
124
+ order: (id: string | bigint) => readonly ["pepay", "marketplace", "order", string];
125
+ orderQuote: (id: string | bigint) => readonly ["pepay", "marketplace", "order", string, "quote"];
126
+ walletActivity: (address: Address) => readonly ["pepay", "wallet", `0x${string}`, "activity"];
127
+ walletPositions: (address: Address) => readonly ["pepay", "wallet", `0x${string}`, "positions"];
128
+ walletClaims: (address: Address, page?: number) => readonly ["pepay", "wallet", `0x${string}`, "claims", number | undefined];
129
+ tokenBalance: (token: Address, address: Address) => readonly ["pepay", "token", `0x${string}`, "balance", `0x${string}`];
130
+ tokenAllowance: (token: Address, owner: Address, spender: Address) => readonly ["pepay", "token", `0x${string}`, "allowance", `0x${string}`, `0x${string}`];
131
+ tokenInfo: (token: Address) => readonly ["pepay", "token", `0x${string}`, "info"];
132
+ autoWithdrawStatus: (campaignId: bigint) => readonly ["pepay", "automation", "autoWithdraw", string];
133
+ autoReleaseStatus: (campaignId: bigint) => readonly ["pepay", "automation", "autoRelease", string];
134
+ };
135
+ /**
136
+ * Mutation key factories for react-query
137
+ */
138
+ declare const mutationKeys: {
139
+ claim: (campaignId: bigint) => readonly ["pepay", "mutation", "claim", string];
140
+ claimBatch: () => readonly ["pepay", "mutation", "claimBatch"];
141
+ stake: (poolId: bigint) => readonly ["pepay", "mutation", "stake", string];
142
+ unstake: (poolId: bigint) => readonly ["pepay", "mutation", "unstake", string];
143
+ fillOrder: (orderId: bigint) => readonly ["pepay", "mutation", "fillOrder", string];
144
+ cancelOrder: (orderId: bigint) => readonly ["pepay", "mutation", "cancelOrder", string];
145
+ approve: (token: Address) => readonly ["pepay", "mutation", "approve", `0x${string}`];
146
+ };
147
+ /**
148
+ * Example hook patterns for common operations
149
+ */
150
+ declare const HOOK_EXAMPLES = "\n// Custom hooks for common operations\n\nimport { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';\nimport { usePepayStreams, queryKeys, mutationKeys } from '@pepay-streams/sdk/react';\nimport { parseEther } from 'viem';\n\n// Hook: Get campaign with due amount\nexport function useCampaignWithDue(campaignId: bigint, recipientAddress: Address) {\n const { client } = usePepayStreams();\n\n const campaign = useQuery({\n queryKey: queryKeys.campaign(campaignId),\n queryFn: () => client!.campaigns.getCampaign(campaignId),\n enabled: !!client,\n });\n\n const dueAmount = useQuery({\n queryKey: queryKeys.dueAmount(campaignId, recipientAddress),\n queryFn: () => client!.claims.getDueAmount(campaignId, recipientAddress),\n enabled: !!client && !!recipientAddress,\n refetchInterval: 30000, // Refresh every 30s\n });\n\n return {\n campaign: campaign.data,\n dueAmount: dueAmount.data,\n isLoading: campaign.isLoading || dueAmount.isLoading,\n };\n}\n\n// Hook: Claim mutation with optimistic updates\nexport function useClaim() {\n const { client } = usePepayStreams();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async ({ campaignId }: { campaignId: bigint }) => {\n const result = await client!.claims.claim({ campaignId });\n return result.wait();\n },\n onSuccess: (_, { campaignId }) => {\n // Invalidate related queries\n queryClient.invalidateQueries({ queryKey: queryKeys.campaign(campaignId) });\n queryClient.invalidateQueries({ queryKey: ['pepay', 'dueAmount', String(campaignId)] });\n },\n });\n}\n\n// Hook: Stake with approval check\nexport function useStake() {\n const { client } = usePepayStreams();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async ({\n poolId,\n amount,\n stakeToken,\n }: {\n poolId: bigint;\n amount: bigint;\n stakeToken: Address;\n }) => {\n // Check and approve if needed\n const approval = await (client as PepayStreamsClientWithSigner).ensureAllowance(stakeToken, amount);\n if (approval) {\n await approval.wait();\n }\n\n // Stake\n const result = await client!.staking.stake(poolId, amount);\n return result.wait();\n },\n onSuccess: (_, { poolId }) => {\n queryClient.invalidateQueries({ queryKey: queryKeys.stakingPool(poolId) });\n queryClient.invalidateQueries({ queryKey: ['pepay', 'staking', 'userStake', String(poolId)] });\n },\n });\n}\n\n// Hook: Fill order with price display\nexport function useOrderWithQuote(orderId: bigint) {\n const { client } = usePepayStreams();\n\n const order = useQuery({\n queryKey: queryKeys.order(orderId),\n queryFn: () => client!.marketplace.getOrder(orderId),\n enabled: !!client,\n });\n\n const quote = useQuery({\n queryKey: queryKeys.orderQuote(orderId),\n queryFn: () => client!.marketplace.getQuote(orderId),\n enabled: !!client && order.data?.status === 'open',\n refetchInterval: 10000, // Refresh quote every 10s\n });\n\n return {\n order: order.data,\n quote: quote.data,\n isLoading: order.isLoading || quote.isLoading,\n canFill: quote.data?.isValid ?? false,\n };\n}\n";
151
+ /**
152
+ * Format helpers for display
153
+ */
154
+ declare const formatters: {
155
+ /**
156
+ * Format token amount with decimals
157
+ */
158
+ formatTokenAmount(amount: bigint, decimals?: number, maxDecimals?: number): string;
159
+ /**
160
+ * Format USD amount
161
+ */
162
+ formatUsd(amount: number | string): string;
163
+ /**
164
+ * Format percentage
165
+ */
166
+ formatPercent(value: number, decimals?: number): string;
167
+ /**
168
+ * Format timestamp to date string
169
+ */
170
+ formatDate(timestamp: number): string;
171
+ /**
172
+ * Format timestamp to relative time
173
+ */
174
+ formatRelativeTime(timestamp: number): string;
175
+ /**
176
+ * Format vesting progress
177
+ */
178
+ formatVestingProgress(claimed: bigint, allocated: bigint): string;
179
+ /**
180
+ * Shorten address for display
181
+ */
182
+ shortenAddress(address: Address, chars?: number): string;
183
+ };
184
+
185
+ export { CONTEXT_EXAMPLE, type CreateContextConfig, HOOK_EXAMPLES, type PepayStreamsContextValue, formatters, getConfigFromEnv, mutationKeys, queryKeys };
@@ -0,0 +1,185 @@
1
+ import { Address } from 'viem';
2
+ import { P as PepayStreamsConfig } from '../index-BTG0TRJt.js';
3
+ import { PepayStreamsClient, PepayStreamsClientWithSigner } from '../index.js';
4
+ import '../campaigns/index.js';
5
+ import '../claims/index.js';
6
+ import '../staking/index.js';
7
+ import '../marketplace/index.js';
8
+ import '../automation/index.js';
9
+ import '../api/index.js';
10
+ import '@pepay-streams/shared';
11
+
12
+ /**
13
+ * React Integration Helpers
14
+ *
15
+ * Provides React-friendly patterns for using the SDK:
16
+ * - Context provider
17
+ * - Hooks for common operations
18
+ * - Type-safe query helpers
19
+ */
20
+
21
+ /**
22
+ * SDK context value type for React context
23
+ */
24
+ interface PepayStreamsContextValue {
25
+ /** SDK client instance */
26
+ client: PepayStreamsClient | PepayStreamsClientWithSigner | null;
27
+ /** Whether the client has a signer */
28
+ isConnected: boolean;
29
+ /** Connected wallet address */
30
+ address: Address | null;
31
+ /** Chain ID */
32
+ chainId: number;
33
+ /** Diamond contract address */
34
+ diamondAddress: Address;
35
+ }
36
+ /**
37
+ * Configuration for creating SDK context
38
+ */
39
+ interface CreateContextConfig extends PepayStreamsConfig {
40
+ /** Auto-connect on mount */
41
+ autoConnect?: boolean;
42
+ }
43
+ /**
44
+ * Helper to create SDK client configuration from environment
45
+ */
46
+ declare function getConfigFromEnv(): Partial<PepayStreamsConfig>;
47
+ /**
48
+ * Example React context creation pattern
49
+ *
50
+ * @example
51
+ * ```tsx
52
+ * // contexts/PepayStreams.tsx
53
+ * import { createContext, useContext, useState, useEffect } from 'react';
54
+ * import { PepayStreamsClient, PepayStreamsClientWithSigner } from '@pepay-streams/sdk';
55
+ * import { useWalletClient, usePublicClient, useAccount } from 'wagmi';
56
+ *
57
+ * const PepayStreamsContext = createContext<PepayStreamsContextValue | null>(null);
58
+ *
59
+ * export function PepayStreamsProvider({ children, config }) {
60
+ * const { address, isConnected } = useAccount();
61
+ * const publicClient = usePublicClient();
62
+ * const { data: walletClient } = useWalletClient();
63
+ * const [client, setClient] = useState<PepayStreamsClient | null>(null);
64
+ *
65
+ * useEffect(() => {
66
+ * if (!publicClient) return;
67
+ *
68
+ * if (walletClient && isConnected) {
69
+ * setClient(new PepayStreamsClient(config).withSigner(walletClient));
70
+ * } else {
71
+ * setClient(new PepayStreamsClient(config));
72
+ * }
73
+ * }, [publicClient, walletClient, isConnected]);
74
+ *
75
+ * return (
76
+ * <PepayStreamsContext.Provider value={{ client, isConnected, address, ... }}>
77
+ * {children}
78
+ * </PepayStreamsContext.Provider>
79
+ * );
80
+ * }
81
+ *
82
+ * export function usePepayStreams() {
83
+ * const context = useContext(PepayStreamsContext);
84
+ * if (!context) throw new Error('Must be used within PepayStreamsProvider');
85
+ * return context;
86
+ * }
87
+ * ```
88
+ */
89
+ declare const CONTEXT_EXAMPLE = "\n// Example usage with wagmi and React\n\nimport { createContext, useContext, useState, useEffect, ReactNode } from 'react';\nimport { PepayStreamsClient, PepayStreamsClientWithSigner, PepayStreamsConfig } from '@pepay-streams/sdk';\nimport { useWalletClient, usePublicClient, useAccount, useChainId } from 'wagmi';\n\ninterface PepayStreamsContextValue {\n client: PepayStreamsClient | PepayStreamsClientWithSigner | null;\n isConnected: boolean;\n isLoading: boolean;\n}\n\nconst PepayStreamsContext = createContext<PepayStreamsContextValue>({\n client: null,\n isConnected: false,\n isLoading: true,\n});\n\nexport function PepayStreamsProvider({\n children,\n config,\n}: {\n children: ReactNode;\n config: PepayStreamsConfig;\n}) {\n const { isConnected } = useAccount();\n const chainId = useChainId();\n const { data: walletClient, isLoading: walletLoading } = useWalletClient();\n const [client, setClient] = useState<PepayStreamsClient | null>(null);\n\n useEffect(() => {\n const newClient = new PepayStreamsClient({\n ...config,\n chainId,\n });\n\n if (walletClient && isConnected) {\n setClient(newClient.withSigner(walletClient));\n } else {\n setClient(newClient);\n }\n }, [walletClient, isConnected, chainId, config]);\n\n return (\n <PepayStreamsContext.Provider\n value={{\n client,\n isConnected,\n isLoading: walletLoading,\n }}\n >\n {children}\n </PepayStreamsContext.Provider>\n );\n}\n\nexport function usePepayStreams() {\n return useContext(PepayStreamsContext);\n}\n\n// Usage in components:\nfunction ClaimButton({ campaignId }: { campaignId: bigint }) {\n const { client, isConnected } = usePepayStreams();\n const [loading, setLoading] = useState(false);\n\n const handleClaim = async () => {\n if (!client || !isConnected) return;\n\n setLoading(true);\n try {\n const result = await client.claims.claim({ campaignId });\n await result.wait();\n console.log('Claimed!');\n } catch (error) {\n console.error('Claim failed:', error);\n } finally {\n setLoading(false);\n }\n };\n\n return (\n <button onClick={handleClaim} disabled={!isConnected || loading}>\n {loading ? 'Claiming...' : 'Claim'}\n </button>\n );\n}\n";
90
+ /**
91
+ * Query key factories for react-query integration
92
+ *
93
+ * @example
94
+ * ```tsx
95
+ * import { useQuery } from '@tanstack/react-query';
96
+ * import { queryKeys, usePepayStreams } from '@pepay-streams/sdk/react';
97
+ *
98
+ * function CampaignDetails({ id }) {
99
+ * const { client } = usePepayStreams();
100
+ *
101
+ * const { data: campaign, isLoading } = useQuery({
102
+ * queryKey: queryKeys.campaign(id),
103
+ * queryFn: () => client.campaigns.getCampaign(BigInt(id)),
104
+ * enabled: !!client,
105
+ * });
106
+ *
107
+ * if (isLoading) return <div>Loading...</div>;
108
+ * return <div>{campaign?.name}</div>;
109
+ * }
110
+ * ```
111
+ */
112
+ declare const queryKeys: {
113
+ campaigns: (params?: Record<string, unknown>) => readonly ["pepay", "campaigns", Record<string, unknown> | undefined];
114
+ campaign: (id: string | bigint) => readonly ["pepay", "campaign", string];
115
+ campaignRecipients: (id: string | bigint, page?: number) => readonly ["pepay", "campaign", string, "recipients", number | undefined];
116
+ campaignActivity: (id: string | bigint, page?: number) => readonly ["pepay", "campaign", string, "activity", number | undefined];
117
+ dueAmount: (campaignId: bigint, address: Address) => readonly ["pepay", "dueAmount", string, `0x${string}`];
118
+ recipientStatus: (campaignId: bigint, address: Address) => readonly ["pepay", "recipientStatus", string, `0x${string}`];
119
+ stakingPools: (params?: Record<string, unknown>) => readonly ["pepay", "staking", "pools", Record<string, unknown> | undefined];
120
+ stakingPool: (id: string | bigint) => readonly ["pepay", "staking", "pool", string];
121
+ userStake: (poolId: bigint, address: Address) => readonly ["pepay", "staking", "userStake", string, `0x${string}`];
122
+ pendingRewards: (poolId: bigint, address: Address) => readonly ["pepay", "staking", "pendingRewards", string, `0x${string}`];
123
+ orders: (params?: Record<string, unknown>) => readonly ["pepay", "marketplace", "orders", Record<string, unknown> | undefined];
124
+ order: (id: string | bigint) => readonly ["pepay", "marketplace", "order", string];
125
+ orderQuote: (id: string | bigint) => readonly ["pepay", "marketplace", "order", string, "quote"];
126
+ walletActivity: (address: Address) => readonly ["pepay", "wallet", `0x${string}`, "activity"];
127
+ walletPositions: (address: Address) => readonly ["pepay", "wallet", `0x${string}`, "positions"];
128
+ walletClaims: (address: Address, page?: number) => readonly ["pepay", "wallet", `0x${string}`, "claims", number | undefined];
129
+ tokenBalance: (token: Address, address: Address) => readonly ["pepay", "token", `0x${string}`, "balance", `0x${string}`];
130
+ tokenAllowance: (token: Address, owner: Address, spender: Address) => readonly ["pepay", "token", `0x${string}`, "allowance", `0x${string}`, `0x${string}`];
131
+ tokenInfo: (token: Address) => readonly ["pepay", "token", `0x${string}`, "info"];
132
+ autoWithdrawStatus: (campaignId: bigint) => readonly ["pepay", "automation", "autoWithdraw", string];
133
+ autoReleaseStatus: (campaignId: bigint) => readonly ["pepay", "automation", "autoRelease", string];
134
+ };
135
+ /**
136
+ * Mutation key factories for react-query
137
+ */
138
+ declare const mutationKeys: {
139
+ claim: (campaignId: bigint) => readonly ["pepay", "mutation", "claim", string];
140
+ claimBatch: () => readonly ["pepay", "mutation", "claimBatch"];
141
+ stake: (poolId: bigint) => readonly ["pepay", "mutation", "stake", string];
142
+ unstake: (poolId: bigint) => readonly ["pepay", "mutation", "unstake", string];
143
+ fillOrder: (orderId: bigint) => readonly ["pepay", "mutation", "fillOrder", string];
144
+ cancelOrder: (orderId: bigint) => readonly ["pepay", "mutation", "cancelOrder", string];
145
+ approve: (token: Address) => readonly ["pepay", "mutation", "approve", `0x${string}`];
146
+ };
147
+ /**
148
+ * Example hook patterns for common operations
149
+ */
150
+ declare const HOOK_EXAMPLES = "\n// Custom hooks for common operations\n\nimport { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';\nimport { usePepayStreams, queryKeys, mutationKeys } from '@pepay-streams/sdk/react';\nimport { parseEther } from 'viem';\n\n// Hook: Get campaign with due amount\nexport function useCampaignWithDue(campaignId: bigint, recipientAddress: Address) {\n const { client } = usePepayStreams();\n\n const campaign = useQuery({\n queryKey: queryKeys.campaign(campaignId),\n queryFn: () => client!.campaigns.getCampaign(campaignId),\n enabled: !!client,\n });\n\n const dueAmount = useQuery({\n queryKey: queryKeys.dueAmount(campaignId, recipientAddress),\n queryFn: () => client!.claims.getDueAmount(campaignId, recipientAddress),\n enabled: !!client && !!recipientAddress,\n refetchInterval: 30000, // Refresh every 30s\n });\n\n return {\n campaign: campaign.data,\n dueAmount: dueAmount.data,\n isLoading: campaign.isLoading || dueAmount.isLoading,\n };\n}\n\n// Hook: Claim mutation with optimistic updates\nexport function useClaim() {\n const { client } = usePepayStreams();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async ({ campaignId }: { campaignId: bigint }) => {\n const result = await client!.claims.claim({ campaignId });\n return result.wait();\n },\n onSuccess: (_, { campaignId }) => {\n // Invalidate related queries\n queryClient.invalidateQueries({ queryKey: queryKeys.campaign(campaignId) });\n queryClient.invalidateQueries({ queryKey: ['pepay', 'dueAmount', String(campaignId)] });\n },\n });\n}\n\n// Hook: Stake with approval check\nexport function useStake() {\n const { client } = usePepayStreams();\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: async ({\n poolId,\n amount,\n stakeToken,\n }: {\n poolId: bigint;\n amount: bigint;\n stakeToken: Address;\n }) => {\n // Check and approve if needed\n const approval = await (client as PepayStreamsClientWithSigner).ensureAllowance(stakeToken, amount);\n if (approval) {\n await approval.wait();\n }\n\n // Stake\n const result = await client!.staking.stake(poolId, amount);\n return result.wait();\n },\n onSuccess: (_, { poolId }) => {\n queryClient.invalidateQueries({ queryKey: queryKeys.stakingPool(poolId) });\n queryClient.invalidateQueries({ queryKey: ['pepay', 'staking', 'userStake', String(poolId)] });\n },\n });\n}\n\n// Hook: Fill order with price display\nexport function useOrderWithQuote(orderId: bigint) {\n const { client } = usePepayStreams();\n\n const order = useQuery({\n queryKey: queryKeys.order(orderId),\n queryFn: () => client!.marketplace.getOrder(orderId),\n enabled: !!client,\n });\n\n const quote = useQuery({\n queryKey: queryKeys.orderQuote(orderId),\n queryFn: () => client!.marketplace.getQuote(orderId),\n enabled: !!client && order.data?.status === 'open',\n refetchInterval: 10000, // Refresh quote every 10s\n });\n\n return {\n order: order.data,\n quote: quote.data,\n isLoading: order.isLoading || quote.isLoading,\n canFill: quote.data?.isValid ?? false,\n };\n}\n";
151
+ /**
152
+ * Format helpers for display
153
+ */
154
+ declare const formatters: {
155
+ /**
156
+ * Format token amount with decimals
157
+ */
158
+ formatTokenAmount(amount: bigint, decimals?: number, maxDecimals?: number): string;
159
+ /**
160
+ * Format USD amount
161
+ */
162
+ formatUsd(amount: number | string): string;
163
+ /**
164
+ * Format percentage
165
+ */
166
+ formatPercent(value: number, decimals?: number): string;
167
+ /**
168
+ * Format timestamp to date string
169
+ */
170
+ formatDate(timestamp: number): string;
171
+ /**
172
+ * Format timestamp to relative time
173
+ */
174
+ formatRelativeTime(timestamp: number): string;
175
+ /**
176
+ * Format vesting progress
177
+ */
178
+ formatVestingProgress(claimed: bigint, allocated: bigint): string;
179
+ /**
180
+ * Shorten address for display
181
+ */
182
+ shortenAddress(address: Address, chars?: number): string;
183
+ };
184
+
185
+ export { CONTEXT_EXAMPLE, type CreateContextConfig, HOOK_EXAMPLES, type PepayStreamsContextValue, formatters, getConfigFromEnv, mutationKeys, queryKeys };