flowstack-sdk 0.2.1
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 +2278 -0
- package/dist/api/index.d.mts +1 -0
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.js +1065 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/index.mjs +977 -0
- package/dist/api/index.mjs.map +1 -0
- package/dist/index-BkACA2ls.d.mts +1546 -0
- package/dist/index-BkACA2ls.d.ts +1546 -0
- package/dist/index.d.mts +2325 -0
- package/dist/index.d.ts +2325 -0
- package/dist/index.js +10817 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +10610 -0
- package/dist/index.mjs.map +1 -0
- package/dist/types-BmCPwbGH.d.mts +153 -0
- package/dist/types-BmCPwbGH.d.ts +153 -0
- package/dist/wallet/index.d.mts +195 -0
- package/dist/wallet/index.d.ts +195 -0
- package/dist/wallet/index.js +1205 -0
- package/dist/wallet/index.js.map +1 -0
- package/dist/wallet/index.mjs +1190 -0
- package/dist/wallet/index.mjs.map +1 -0
- package/package.json +110 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for the wallet module (flowstack-sdk/wallet).
|
|
3
|
+
*/
|
|
4
|
+
interface WalletAuthState {
|
|
5
|
+
/** Whether a wallet is connected and authenticated */
|
|
6
|
+
isConnected: boolean;
|
|
7
|
+
/** Loading state during auth */
|
|
8
|
+
isLoading: boolean;
|
|
9
|
+
/** Connected wallet address (checksummed) */
|
|
10
|
+
address: string | null;
|
|
11
|
+
/** Whether this is a Privy embedded wallet (vs MetaMask) */
|
|
12
|
+
isEmbeddedWallet: boolean;
|
|
13
|
+
/** Auth method used */
|
|
14
|
+
authMethod: 'privy' | 'siwe' | null;
|
|
15
|
+
/** Error message if auth failed */
|
|
16
|
+
error: string | null;
|
|
17
|
+
}
|
|
18
|
+
interface UseWalletAuthReturn extends WalletAuthState {
|
|
19
|
+
/** Login via Privy (email/Google) or external wallet (MetaMask) */
|
|
20
|
+
login: (method?: 'privy' | 'wallet') => Promise<void>;
|
|
21
|
+
/** Disconnect wallet and clear session */
|
|
22
|
+
logout: () => void;
|
|
23
|
+
}
|
|
24
|
+
interface InferBalance {
|
|
25
|
+
/** Raw on-chain balance in wei */
|
|
26
|
+
balanceWei: string;
|
|
27
|
+
/** Held amount in wei (pending query charges) */
|
|
28
|
+
heldWei: string;
|
|
29
|
+
/** Available balance in wei (balance - held) */
|
|
30
|
+
availableWei: string;
|
|
31
|
+
/** Human-readable INFER token balance */
|
|
32
|
+
balance: number;
|
|
33
|
+
/** Human-readable available balance */
|
|
34
|
+
available: number;
|
|
35
|
+
/** Number of queries this balance can cover */
|
|
36
|
+
queryCredits: number;
|
|
37
|
+
}
|
|
38
|
+
interface UseInferBalanceReturn {
|
|
39
|
+
/** Current balance data (null if not loaded) */
|
|
40
|
+
data: InferBalance | null;
|
|
41
|
+
/** Whether balance is being fetched */
|
|
42
|
+
isLoading: boolean;
|
|
43
|
+
/** Error message */
|
|
44
|
+
error: string | null;
|
|
45
|
+
/** Manually refresh balance */
|
|
46
|
+
refetch: () => Promise<void>;
|
|
47
|
+
}
|
|
48
|
+
interface UseDepositReturn {
|
|
49
|
+
/** Execute approve + deposit flow */
|
|
50
|
+
deposit: (amount: number) => Promise<string | null>;
|
|
51
|
+
/** Whether deposit is in progress */
|
|
52
|
+
isDepositing: boolean;
|
|
53
|
+
/** Transaction hash of last deposit */
|
|
54
|
+
txHash: string | null;
|
|
55
|
+
/** Error message */
|
|
56
|
+
error: string | null;
|
|
57
|
+
}
|
|
58
|
+
interface UseBuyInferReturn {
|
|
59
|
+
/** Open fiat on-ramp widget */
|
|
60
|
+
buy: (amount?: number) => void;
|
|
61
|
+
/** Whether purchase flow is active */
|
|
62
|
+
isBuying: boolean;
|
|
63
|
+
/** Purchase status */
|
|
64
|
+
status: 'idle' | 'pending' | 'completed' | 'failed';
|
|
65
|
+
/** Error message */
|
|
66
|
+
error: string | null;
|
|
67
|
+
}
|
|
68
|
+
interface AgentBalance {
|
|
69
|
+
/** Raw on-chain AGENT balance in wei */
|
|
70
|
+
balanceWei: string;
|
|
71
|
+
/** Held amount in wei (active query charges) */
|
|
72
|
+
heldWei: string;
|
|
73
|
+
/** Available balance in wei (balance - held) */
|
|
74
|
+
availableWei: string;
|
|
75
|
+
/** Human-readable AGENT token balance */
|
|
76
|
+
balance: number;
|
|
77
|
+
/** Human-readable available AGENT balance */
|
|
78
|
+
available: number;
|
|
79
|
+
/** Number of build credits equivalent */
|
|
80
|
+
buildCredits: number;
|
|
81
|
+
}
|
|
82
|
+
interface UseAgentBalanceReturn {
|
|
83
|
+
/** Current AGENT balance data (null if not loaded or no wallet) */
|
|
84
|
+
data: AgentBalance | null;
|
|
85
|
+
/** Whether balance is being fetched */
|
|
86
|
+
isLoading: boolean;
|
|
87
|
+
/** Error message */
|
|
88
|
+
error: string | null;
|
|
89
|
+
/** Manually refresh balance */
|
|
90
|
+
refetch: () => Promise<void>;
|
|
91
|
+
}
|
|
92
|
+
interface NeedsAgentProps {
|
|
93
|
+
/** Minimum AGENT balance required to proceed */
|
|
94
|
+
amountNeeded: number;
|
|
95
|
+
/** Called when balance is sufficient and user clicks the gated action */
|
|
96
|
+
onProceed: () => void;
|
|
97
|
+
/** Current page URL to return to after OIF purchase (defaults to window.location.href) */
|
|
98
|
+
returnUrl?: string;
|
|
99
|
+
/** Content to show when user has sufficient AGENT */
|
|
100
|
+
children?: React.ReactNode;
|
|
101
|
+
/** OIF base URL (default: 'https://openinferencefoundation.org') */
|
|
102
|
+
oifBaseUrl?: string;
|
|
103
|
+
}
|
|
104
|
+
interface AppAccessStatus {
|
|
105
|
+
/** Whether the end-user has access to this built app */
|
|
106
|
+
hasAccess: boolean;
|
|
107
|
+
/** Number of free queries used this month */
|
|
108
|
+
queriesUsed: number;
|
|
109
|
+
/** Remaining free queries this month (null = unlimited — paid access) */
|
|
110
|
+
queriesRemaining: number | null;
|
|
111
|
+
/** Payment mode configured by the builder */
|
|
112
|
+
paymentMode: 'stripe' | 'agent' | 'both' | null;
|
|
113
|
+
/** One-time unlock price in USD cents (null = free or not configured) */
|
|
114
|
+
unlockPriceCents: number | null;
|
|
115
|
+
/** Human-readable unlock price label */
|
|
116
|
+
unlockPriceLabel: string | null;
|
|
117
|
+
}
|
|
118
|
+
interface UseAppAccessReturn extends AppAccessStatus {
|
|
119
|
+
/** Whether the access check is being fetched */
|
|
120
|
+
isLoading: boolean;
|
|
121
|
+
/** Error message if the status check failed */
|
|
122
|
+
error: string | null;
|
|
123
|
+
/** Open Stripe Checkout to unlock this app */
|
|
124
|
+
checkout: (opts?: {
|
|
125
|
+
successUrl?: string;
|
|
126
|
+
cancelUrl?: string;
|
|
127
|
+
}) => Promise<void>;
|
|
128
|
+
/** Manually refresh the access status */
|
|
129
|
+
refetch: () => Promise<void>;
|
|
130
|
+
}
|
|
131
|
+
interface AppPaywallProps {
|
|
132
|
+
/** Site ID of the built app (typically config.appScope) */
|
|
133
|
+
siteId: string;
|
|
134
|
+
/** Builder's tenant ID — needed to load app config */
|
|
135
|
+
builderTenantId?: string;
|
|
136
|
+
/** Content to show when the user has access */
|
|
137
|
+
children: React.ReactNode;
|
|
138
|
+
/** Called when the backend returns an app_paywall SSE event */
|
|
139
|
+
onBlocked?: (reason: string) => void;
|
|
140
|
+
}
|
|
141
|
+
interface WalletProviderProps {
|
|
142
|
+
children: React.ReactNode;
|
|
143
|
+
/** Privy app ID (enables embedded wallet flow) */
|
|
144
|
+
privyAppId?: string;
|
|
145
|
+
/** Chain to use */
|
|
146
|
+
chain?: 'arbitrum-sepolia' | 'arbitrum';
|
|
147
|
+
/** Casino API base URL */
|
|
148
|
+
baseUrl?: string;
|
|
149
|
+
/** WalletConnect v2 Cloud project ID — enables the WalletConnect connector in Privy's login modal */
|
|
150
|
+
walletConnectProjectId?: string;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export type { AppPaywallProps as A, InferBalance as I, NeedsAgentProps as N, UseWalletAuthReturn as U, WalletProviderProps as W, UseInferBalanceReturn as a, UseAgentBalanceReturn as b, UseDepositReturn as c, UseBuyInferReturn as d, UseAppAccessReturn as e, WalletAuthState as f, AgentBalance as g, AppAccessStatus as h };
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for the wallet module (flowstack-sdk/wallet).
|
|
3
|
+
*/
|
|
4
|
+
interface WalletAuthState {
|
|
5
|
+
/** Whether a wallet is connected and authenticated */
|
|
6
|
+
isConnected: boolean;
|
|
7
|
+
/** Loading state during auth */
|
|
8
|
+
isLoading: boolean;
|
|
9
|
+
/** Connected wallet address (checksummed) */
|
|
10
|
+
address: string | null;
|
|
11
|
+
/** Whether this is a Privy embedded wallet (vs MetaMask) */
|
|
12
|
+
isEmbeddedWallet: boolean;
|
|
13
|
+
/** Auth method used */
|
|
14
|
+
authMethod: 'privy' | 'siwe' | null;
|
|
15
|
+
/** Error message if auth failed */
|
|
16
|
+
error: string | null;
|
|
17
|
+
}
|
|
18
|
+
interface UseWalletAuthReturn extends WalletAuthState {
|
|
19
|
+
/** Login via Privy (email/Google) or external wallet (MetaMask) */
|
|
20
|
+
login: (method?: 'privy' | 'wallet') => Promise<void>;
|
|
21
|
+
/** Disconnect wallet and clear session */
|
|
22
|
+
logout: () => void;
|
|
23
|
+
}
|
|
24
|
+
interface InferBalance {
|
|
25
|
+
/** Raw on-chain balance in wei */
|
|
26
|
+
balanceWei: string;
|
|
27
|
+
/** Held amount in wei (pending query charges) */
|
|
28
|
+
heldWei: string;
|
|
29
|
+
/** Available balance in wei (balance - held) */
|
|
30
|
+
availableWei: string;
|
|
31
|
+
/** Human-readable INFER token balance */
|
|
32
|
+
balance: number;
|
|
33
|
+
/** Human-readable available balance */
|
|
34
|
+
available: number;
|
|
35
|
+
/** Number of queries this balance can cover */
|
|
36
|
+
queryCredits: number;
|
|
37
|
+
}
|
|
38
|
+
interface UseInferBalanceReturn {
|
|
39
|
+
/** Current balance data (null if not loaded) */
|
|
40
|
+
data: InferBalance | null;
|
|
41
|
+
/** Whether balance is being fetched */
|
|
42
|
+
isLoading: boolean;
|
|
43
|
+
/** Error message */
|
|
44
|
+
error: string | null;
|
|
45
|
+
/** Manually refresh balance */
|
|
46
|
+
refetch: () => Promise<void>;
|
|
47
|
+
}
|
|
48
|
+
interface UseDepositReturn {
|
|
49
|
+
/** Execute approve + deposit flow */
|
|
50
|
+
deposit: (amount: number) => Promise<string | null>;
|
|
51
|
+
/** Whether deposit is in progress */
|
|
52
|
+
isDepositing: boolean;
|
|
53
|
+
/** Transaction hash of last deposit */
|
|
54
|
+
txHash: string | null;
|
|
55
|
+
/** Error message */
|
|
56
|
+
error: string | null;
|
|
57
|
+
}
|
|
58
|
+
interface UseBuyInferReturn {
|
|
59
|
+
/** Open fiat on-ramp widget */
|
|
60
|
+
buy: (amount?: number) => void;
|
|
61
|
+
/** Whether purchase flow is active */
|
|
62
|
+
isBuying: boolean;
|
|
63
|
+
/** Purchase status */
|
|
64
|
+
status: 'idle' | 'pending' | 'completed' | 'failed';
|
|
65
|
+
/** Error message */
|
|
66
|
+
error: string | null;
|
|
67
|
+
}
|
|
68
|
+
interface AgentBalance {
|
|
69
|
+
/** Raw on-chain AGENT balance in wei */
|
|
70
|
+
balanceWei: string;
|
|
71
|
+
/** Held amount in wei (active query charges) */
|
|
72
|
+
heldWei: string;
|
|
73
|
+
/** Available balance in wei (balance - held) */
|
|
74
|
+
availableWei: string;
|
|
75
|
+
/** Human-readable AGENT token balance */
|
|
76
|
+
balance: number;
|
|
77
|
+
/** Human-readable available AGENT balance */
|
|
78
|
+
available: number;
|
|
79
|
+
/** Number of build credits equivalent */
|
|
80
|
+
buildCredits: number;
|
|
81
|
+
}
|
|
82
|
+
interface UseAgentBalanceReturn {
|
|
83
|
+
/** Current AGENT balance data (null if not loaded or no wallet) */
|
|
84
|
+
data: AgentBalance | null;
|
|
85
|
+
/** Whether balance is being fetched */
|
|
86
|
+
isLoading: boolean;
|
|
87
|
+
/** Error message */
|
|
88
|
+
error: string | null;
|
|
89
|
+
/** Manually refresh balance */
|
|
90
|
+
refetch: () => Promise<void>;
|
|
91
|
+
}
|
|
92
|
+
interface NeedsAgentProps {
|
|
93
|
+
/** Minimum AGENT balance required to proceed */
|
|
94
|
+
amountNeeded: number;
|
|
95
|
+
/** Called when balance is sufficient and user clicks the gated action */
|
|
96
|
+
onProceed: () => void;
|
|
97
|
+
/** Current page URL to return to after OIF purchase (defaults to window.location.href) */
|
|
98
|
+
returnUrl?: string;
|
|
99
|
+
/** Content to show when user has sufficient AGENT */
|
|
100
|
+
children?: React.ReactNode;
|
|
101
|
+
/** OIF base URL (default: 'https://openinferencefoundation.org') */
|
|
102
|
+
oifBaseUrl?: string;
|
|
103
|
+
}
|
|
104
|
+
interface AppAccessStatus {
|
|
105
|
+
/** Whether the end-user has access to this built app */
|
|
106
|
+
hasAccess: boolean;
|
|
107
|
+
/** Number of free queries used this month */
|
|
108
|
+
queriesUsed: number;
|
|
109
|
+
/** Remaining free queries this month (null = unlimited — paid access) */
|
|
110
|
+
queriesRemaining: number | null;
|
|
111
|
+
/** Payment mode configured by the builder */
|
|
112
|
+
paymentMode: 'stripe' | 'agent' | 'both' | null;
|
|
113
|
+
/** One-time unlock price in USD cents (null = free or not configured) */
|
|
114
|
+
unlockPriceCents: number | null;
|
|
115
|
+
/** Human-readable unlock price label */
|
|
116
|
+
unlockPriceLabel: string | null;
|
|
117
|
+
}
|
|
118
|
+
interface UseAppAccessReturn extends AppAccessStatus {
|
|
119
|
+
/** Whether the access check is being fetched */
|
|
120
|
+
isLoading: boolean;
|
|
121
|
+
/** Error message if the status check failed */
|
|
122
|
+
error: string | null;
|
|
123
|
+
/** Open Stripe Checkout to unlock this app */
|
|
124
|
+
checkout: (opts?: {
|
|
125
|
+
successUrl?: string;
|
|
126
|
+
cancelUrl?: string;
|
|
127
|
+
}) => Promise<void>;
|
|
128
|
+
/** Manually refresh the access status */
|
|
129
|
+
refetch: () => Promise<void>;
|
|
130
|
+
}
|
|
131
|
+
interface AppPaywallProps {
|
|
132
|
+
/** Site ID of the built app (typically config.appScope) */
|
|
133
|
+
siteId: string;
|
|
134
|
+
/** Builder's tenant ID — needed to load app config */
|
|
135
|
+
builderTenantId?: string;
|
|
136
|
+
/** Content to show when the user has access */
|
|
137
|
+
children: React.ReactNode;
|
|
138
|
+
/** Called when the backend returns an app_paywall SSE event */
|
|
139
|
+
onBlocked?: (reason: string) => void;
|
|
140
|
+
}
|
|
141
|
+
interface WalletProviderProps {
|
|
142
|
+
children: React.ReactNode;
|
|
143
|
+
/** Privy app ID (enables embedded wallet flow) */
|
|
144
|
+
privyAppId?: string;
|
|
145
|
+
/** Chain to use */
|
|
146
|
+
chain?: 'arbitrum-sepolia' | 'arbitrum';
|
|
147
|
+
/** Casino API base URL */
|
|
148
|
+
baseUrl?: string;
|
|
149
|
+
/** WalletConnect v2 Cloud project ID — enables the WalletConnect connector in Privy's login modal */
|
|
150
|
+
walletConnectProjectId?: string;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export type { AppPaywallProps as A, InferBalance as I, NeedsAgentProps as N, UseWalletAuthReturn as U, WalletProviderProps as W, UseInferBalanceReturn as a, UseAgentBalanceReturn as b, UseDepositReturn as c, UseBuyInferReturn as d, UseAppAccessReturn as e, WalletAuthState as f, AgentBalance as g, AppAccessStatus as h };
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { U as UseWalletAuthReturn, a as UseInferBalanceReturn, b as UseAgentBalanceReturn, c as UseDepositReturn, d as UseBuyInferReturn, e as UseAppAccessReturn, W as WalletProviderProps, N as NeedsAgentProps, A as AppPaywallProps } from '../types-BmCPwbGH.mjs';
|
|
2
|
+
export { g as AgentBalance, h as AppAccessStatus, I as InferBalance, f as WalletAuthState } from '../types-BmCPwbGH.mjs';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
+
import { createConfig } from '@privy-io/wagmi';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* useWalletAuth — handles both Privy (embedded) and SIWE (external) auth paths.
|
|
9
|
+
*
|
|
10
|
+
* Both paths produce the same result: a JWT with a wallet_address claim
|
|
11
|
+
* stored via the existing FlowstackProvider credential flow.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
declare function useWalletAuth(): UseWalletAuthReturn;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* useInferBalance — polls the backend for INFER token balance.
|
|
18
|
+
*
|
|
19
|
+
* Uses GET /billing/infer/balance which reads on-chain balance
|
|
20
|
+
* and subtracts active holds.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
declare function useInferBalance(): UseInferBalanceReturn;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* useAgentBalance — polls the backend for AGENT token balance.
|
|
27
|
+
*
|
|
28
|
+
* Uses GET /billing/agent/balance which reads on-chain AGENT balance
|
|
29
|
+
* from the AgentPayment contract and subtracts active holds.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
declare function useAgentBalance(): UseAgentBalanceReturn;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* useDeposit — approve + deposit INFER tokens into InferencePayment contract.
|
|
36
|
+
*
|
|
37
|
+
* For crypto-native users who already have INFER tokens.
|
|
38
|
+
* Handles the two-step ERC-20 flow: approve → deposit.
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
declare function useDeposit(chain?: string): UseDepositReturn;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* useBuyInfer — opens fiat on-ramp widget (MoonPay/Transak).
|
|
45
|
+
*
|
|
46
|
+
* Handles: credit card → INFER → auto-deposit. User never touches crypto.
|
|
47
|
+
* The on-ramp provider delivers INFER to the user's embedded wallet,
|
|
48
|
+
* then the SDK auto-deposits into InferencePayment.
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
interface BuyInferOptions {
|
|
52
|
+
/** MoonPay or Transak API key */
|
|
53
|
+
apiKey?: string;
|
|
54
|
+
/** sandbox or production */
|
|
55
|
+
environment?: 'sandbox' | 'production';
|
|
56
|
+
/** Wallet address to receive INFER */
|
|
57
|
+
walletAddress?: string;
|
|
58
|
+
}
|
|
59
|
+
declare function useBuyInfer(options?: BuyInferOptions): UseBuyInferReturn;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* useAppAccess — checks whether the authenticated end-user has access to a
|
|
63
|
+
* monetized built app, and provides a checkout function to unlock it.
|
|
64
|
+
*
|
|
65
|
+
* Polls GET /billing/app-access/status every 60 seconds.
|
|
66
|
+
* On `checkout()` call, opens a Stripe Checkout session for one-time purchase.
|
|
67
|
+
*
|
|
68
|
+
* Usage:
|
|
69
|
+
* const { hasAccess, queriesRemaining, checkout } = useAppAccess(config.appScope);
|
|
70
|
+
* if (!hasAccess) return <AppPaywall siteId={config.appScope} ... />;
|
|
71
|
+
*/
|
|
72
|
+
|
|
73
|
+
declare function useAppAccess(siteId: string, opts?: {
|
|
74
|
+
builderTenantId?: string;
|
|
75
|
+
}): UseAppAccessReturn;
|
|
76
|
+
|
|
77
|
+
declare global {
|
|
78
|
+
interface Window {
|
|
79
|
+
__wagmiConfig?: ReturnType<typeof createConfig>;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
declare function WalletProvider({ children, privyAppId, chain, baseUrl, walletConnectProjectId, }: WalletProviderProps): react_jsx_runtime.JSX.Element;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* LoginButton — "Sign up with Google" / "Connect Wallet" toggle.
|
|
86
|
+
*
|
|
87
|
+
* Default: Privy (email/Google) signup. Toggle to external wallet (MetaMask).
|
|
88
|
+
*/
|
|
89
|
+
interface LoginButtonProps {
|
|
90
|
+
/** Callback after successful auth */
|
|
91
|
+
onSuccess?: (walletAddress: string) => void;
|
|
92
|
+
/** Callback on auth error */
|
|
93
|
+
onError?: (error: string) => void;
|
|
94
|
+
/** Show wallet connect option */
|
|
95
|
+
showWalletOption?: boolean;
|
|
96
|
+
/** CSS class name */
|
|
97
|
+
className?: string;
|
|
98
|
+
}
|
|
99
|
+
declare function LoginButton({ onSuccess, onError, showWalletOption, className, }: LoginButtonProps): react_jsx_runtime.JSX.Element;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* InferBalanceBadge — shows INFER balance in a compact badge.
|
|
103
|
+
*
|
|
104
|
+
* Displays query credits remaining. Shows "Buy More" when low.
|
|
105
|
+
*/
|
|
106
|
+
interface InferBalanceBadgeProps {
|
|
107
|
+
/** Threshold to show "Buy More" warning */
|
|
108
|
+
lowBalanceThreshold?: number;
|
|
109
|
+
/** Callback when "Buy More" is clicked */
|
|
110
|
+
onBuyMore?: () => void;
|
|
111
|
+
/** CSS class name */
|
|
112
|
+
className?: string;
|
|
113
|
+
}
|
|
114
|
+
declare function InferBalanceBadge({ lowBalanceThreshold, onBuyMore, className, }: InferBalanceBadgeProps): react_jsx_runtime.JSX.Element | null;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* AgentBalanceBadge — shows AGENT token balance in a compact badge.
|
|
118
|
+
*
|
|
119
|
+
* Displays build credits remaining. Shows "Buy More" when low.
|
|
120
|
+
*/
|
|
121
|
+
interface AgentBalanceBadgeProps {
|
|
122
|
+
/** Threshold to show "Buy More" warning */
|
|
123
|
+
lowBalanceThreshold?: number;
|
|
124
|
+
/** Callback when "Buy More" is clicked */
|
|
125
|
+
onBuyMore?: () => void;
|
|
126
|
+
/** CSS class name */
|
|
127
|
+
className?: string;
|
|
128
|
+
}
|
|
129
|
+
declare function AgentBalanceBadge({ lowBalanceThreshold, onBuyMore, className, }: AgentBalanceBadgeProps): react_jsx_runtime.JSX.Element | null;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* NeedsAgent — gating component for AGENT-token-gated features in built apps.
|
|
133
|
+
*
|
|
134
|
+
* Checks the user's AGENT balance. If sufficient, renders children and calls
|
|
135
|
+
* onProceed when the user activates the gated action. If insufficient, renders
|
|
136
|
+
* a "Get AGENT" CTA that deep-links to the OIF /buy page with returnTo + need
|
|
137
|
+
* params so the user lands back in the app after purchasing.
|
|
138
|
+
*
|
|
139
|
+
* Usage:
|
|
140
|
+
* <NeedsAgent amountNeeded={2} onProceed={generateAlbumArt} returnUrl={window.location.href}>
|
|
141
|
+
* <p>Generate a new design for 2 AGENT</p>
|
|
142
|
+
* </NeedsAgent>
|
|
143
|
+
*
|
|
144
|
+
* The user never sees a seed phrase — Privy handles wallet creation on OIF.
|
|
145
|
+
* No auth setup required in the built app: the component works for anonymous users
|
|
146
|
+
* (balance will read 0) and authenticated wallet users alike.
|
|
147
|
+
*/
|
|
148
|
+
|
|
149
|
+
declare function NeedsAgent({ amountNeeded, onProceed, returnUrl, children, oifBaseUrl, }: NeedsAgentProps): React.ReactElement;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* PaymentRequired — shown when user's INFER balance is insufficient (402).
|
|
153
|
+
*
|
|
154
|
+
* Displays current balance and a "Buy INFER" CTA.
|
|
155
|
+
*/
|
|
156
|
+
interface PaymentRequiredProps {
|
|
157
|
+
/** Current balance in query credits */
|
|
158
|
+
queryCredits?: number;
|
|
159
|
+
/** INFER tokens needed per query */
|
|
160
|
+
inferPerQuery?: number;
|
|
161
|
+
/** Callback to open buy flow */
|
|
162
|
+
onBuy?: () => void;
|
|
163
|
+
/** Callback to dismiss */
|
|
164
|
+
onDismiss?: () => void;
|
|
165
|
+
/** CSS class name */
|
|
166
|
+
className?: string;
|
|
167
|
+
}
|
|
168
|
+
declare function PaymentRequired({ queryCredits, inferPerQuery, onBuy, onDismiss, className, }: PaymentRequiredProps): react_jsx_runtime.JSX.Element;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* BuyInferModal — fiat on-ramp widget for purchasing INFER with a credit card.
|
|
172
|
+
*
|
|
173
|
+
* Wraps MoonPay/Transak with Casino-branded pricing tiers.
|
|
174
|
+
*/
|
|
175
|
+
interface BuyInferModalProps {
|
|
176
|
+
/** Whether the modal is open */
|
|
177
|
+
isOpen: boolean;
|
|
178
|
+
/** Close callback */
|
|
179
|
+
onClose: () => void;
|
|
180
|
+
/** MoonPay/Transak API key */
|
|
181
|
+
apiKey: string;
|
|
182
|
+
/** sandbox or production */
|
|
183
|
+
environment?: 'sandbox' | 'production';
|
|
184
|
+
/** User's wallet address */
|
|
185
|
+
walletAddress: string;
|
|
186
|
+
/** INFER per query (for pricing display) */
|
|
187
|
+
inferPerQuery?: number;
|
|
188
|
+
/** CSS class name */
|
|
189
|
+
className?: string;
|
|
190
|
+
}
|
|
191
|
+
declare function BuyInferModal({ isOpen, onClose, apiKey, environment, walletAddress, inferPerQuery, className, }: BuyInferModalProps): react_jsx_runtime.JSX.Element | null;
|
|
192
|
+
|
|
193
|
+
declare function AppPaywall({ siteId, builderTenantId, children, onBlocked }: AppPaywallProps): react_jsx_runtime.JSX.Element;
|
|
194
|
+
|
|
195
|
+
export { AgentBalanceBadge, AppPaywall, AppPaywallProps, BuyInferModal, InferBalanceBadge, LoginButton, NeedsAgent, NeedsAgentProps, PaymentRequired, UseAgentBalanceReturn, UseAppAccessReturn, UseBuyInferReturn, UseDepositReturn, UseInferBalanceReturn, UseWalletAuthReturn, WalletProvider, WalletProviderProps, useAgentBalance, useAppAccess, useBuyInfer, useDeposit, useInferBalance, useWalletAuth };
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { U as UseWalletAuthReturn, a as UseInferBalanceReturn, b as UseAgentBalanceReturn, c as UseDepositReturn, d as UseBuyInferReturn, e as UseAppAccessReturn, W as WalletProviderProps, N as NeedsAgentProps, A as AppPaywallProps } from '../types-BmCPwbGH.js';
|
|
2
|
+
export { g as AgentBalance, h as AppAccessStatus, I as InferBalance, f as WalletAuthState } from '../types-BmCPwbGH.js';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
+
import { createConfig } from '@privy-io/wagmi';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* useWalletAuth — handles both Privy (embedded) and SIWE (external) auth paths.
|
|
9
|
+
*
|
|
10
|
+
* Both paths produce the same result: a JWT with a wallet_address claim
|
|
11
|
+
* stored via the existing FlowstackProvider credential flow.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
declare function useWalletAuth(): UseWalletAuthReturn;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* useInferBalance — polls the backend for INFER token balance.
|
|
18
|
+
*
|
|
19
|
+
* Uses GET /billing/infer/balance which reads on-chain balance
|
|
20
|
+
* and subtracts active holds.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
declare function useInferBalance(): UseInferBalanceReturn;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* useAgentBalance — polls the backend for AGENT token balance.
|
|
27
|
+
*
|
|
28
|
+
* Uses GET /billing/agent/balance which reads on-chain AGENT balance
|
|
29
|
+
* from the AgentPayment contract and subtracts active holds.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
declare function useAgentBalance(): UseAgentBalanceReturn;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* useDeposit — approve + deposit INFER tokens into InferencePayment contract.
|
|
36
|
+
*
|
|
37
|
+
* For crypto-native users who already have INFER tokens.
|
|
38
|
+
* Handles the two-step ERC-20 flow: approve → deposit.
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
declare function useDeposit(chain?: string): UseDepositReturn;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* useBuyInfer — opens fiat on-ramp widget (MoonPay/Transak).
|
|
45
|
+
*
|
|
46
|
+
* Handles: credit card → INFER → auto-deposit. User never touches crypto.
|
|
47
|
+
* The on-ramp provider delivers INFER to the user's embedded wallet,
|
|
48
|
+
* then the SDK auto-deposits into InferencePayment.
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
interface BuyInferOptions {
|
|
52
|
+
/** MoonPay or Transak API key */
|
|
53
|
+
apiKey?: string;
|
|
54
|
+
/** sandbox or production */
|
|
55
|
+
environment?: 'sandbox' | 'production';
|
|
56
|
+
/** Wallet address to receive INFER */
|
|
57
|
+
walletAddress?: string;
|
|
58
|
+
}
|
|
59
|
+
declare function useBuyInfer(options?: BuyInferOptions): UseBuyInferReturn;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* useAppAccess — checks whether the authenticated end-user has access to a
|
|
63
|
+
* monetized built app, and provides a checkout function to unlock it.
|
|
64
|
+
*
|
|
65
|
+
* Polls GET /billing/app-access/status every 60 seconds.
|
|
66
|
+
* On `checkout()` call, opens a Stripe Checkout session for one-time purchase.
|
|
67
|
+
*
|
|
68
|
+
* Usage:
|
|
69
|
+
* const { hasAccess, queriesRemaining, checkout } = useAppAccess(config.appScope);
|
|
70
|
+
* if (!hasAccess) return <AppPaywall siteId={config.appScope} ... />;
|
|
71
|
+
*/
|
|
72
|
+
|
|
73
|
+
declare function useAppAccess(siteId: string, opts?: {
|
|
74
|
+
builderTenantId?: string;
|
|
75
|
+
}): UseAppAccessReturn;
|
|
76
|
+
|
|
77
|
+
declare global {
|
|
78
|
+
interface Window {
|
|
79
|
+
__wagmiConfig?: ReturnType<typeof createConfig>;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
declare function WalletProvider({ children, privyAppId, chain, baseUrl, walletConnectProjectId, }: WalletProviderProps): react_jsx_runtime.JSX.Element;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* LoginButton — "Sign up with Google" / "Connect Wallet" toggle.
|
|
86
|
+
*
|
|
87
|
+
* Default: Privy (email/Google) signup. Toggle to external wallet (MetaMask).
|
|
88
|
+
*/
|
|
89
|
+
interface LoginButtonProps {
|
|
90
|
+
/** Callback after successful auth */
|
|
91
|
+
onSuccess?: (walletAddress: string) => void;
|
|
92
|
+
/** Callback on auth error */
|
|
93
|
+
onError?: (error: string) => void;
|
|
94
|
+
/** Show wallet connect option */
|
|
95
|
+
showWalletOption?: boolean;
|
|
96
|
+
/** CSS class name */
|
|
97
|
+
className?: string;
|
|
98
|
+
}
|
|
99
|
+
declare function LoginButton({ onSuccess, onError, showWalletOption, className, }: LoginButtonProps): react_jsx_runtime.JSX.Element;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* InferBalanceBadge — shows INFER balance in a compact badge.
|
|
103
|
+
*
|
|
104
|
+
* Displays query credits remaining. Shows "Buy More" when low.
|
|
105
|
+
*/
|
|
106
|
+
interface InferBalanceBadgeProps {
|
|
107
|
+
/** Threshold to show "Buy More" warning */
|
|
108
|
+
lowBalanceThreshold?: number;
|
|
109
|
+
/** Callback when "Buy More" is clicked */
|
|
110
|
+
onBuyMore?: () => void;
|
|
111
|
+
/** CSS class name */
|
|
112
|
+
className?: string;
|
|
113
|
+
}
|
|
114
|
+
declare function InferBalanceBadge({ lowBalanceThreshold, onBuyMore, className, }: InferBalanceBadgeProps): react_jsx_runtime.JSX.Element | null;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* AgentBalanceBadge — shows AGENT token balance in a compact badge.
|
|
118
|
+
*
|
|
119
|
+
* Displays build credits remaining. Shows "Buy More" when low.
|
|
120
|
+
*/
|
|
121
|
+
interface AgentBalanceBadgeProps {
|
|
122
|
+
/** Threshold to show "Buy More" warning */
|
|
123
|
+
lowBalanceThreshold?: number;
|
|
124
|
+
/** Callback when "Buy More" is clicked */
|
|
125
|
+
onBuyMore?: () => void;
|
|
126
|
+
/** CSS class name */
|
|
127
|
+
className?: string;
|
|
128
|
+
}
|
|
129
|
+
declare function AgentBalanceBadge({ lowBalanceThreshold, onBuyMore, className, }: AgentBalanceBadgeProps): react_jsx_runtime.JSX.Element | null;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* NeedsAgent — gating component for AGENT-token-gated features in built apps.
|
|
133
|
+
*
|
|
134
|
+
* Checks the user's AGENT balance. If sufficient, renders children and calls
|
|
135
|
+
* onProceed when the user activates the gated action. If insufficient, renders
|
|
136
|
+
* a "Get AGENT" CTA that deep-links to the OIF /buy page with returnTo + need
|
|
137
|
+
* params so the user lands back in the app after purchasing.
|
|
138
|
+
*
|
|
139
|
+
* Usage:
|
|
140
|
+
* <NeedsAgent amountNeeded={2} onProceed={generateAlbumArt} returnUrl={window.location.href}>
|
|
141
|
+
* <p>Generate a new design for 2 AGENT</p>
|
|
142
|
+
* </NeedsAgent>
|
|
143
|
+
*
|
|
144
|
+
* The user never sees a seed phrase — Privy handles wallet creation on OIF.
|
|
145
|
+
* No auth setup required in the built app: the component works for anonymous users
|
|
146
|
+
* (balance will read 0) and authenticated wallet users alike.
|
|
147
|
+
*/
|
|
148
|
+
|
|
149
|
+
declare function NeedsAgent({ amountNeeded, onProceed, returnUrl, children, oifBaseUrl, }: NeedsAgentProps): React.ReactElement;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* PaymentRequired — shown when user's INFER balance is insufficient (402).
|
|
153
|
+
*
|
|
154
|
+
* Displays current balance and a "Buy INFER" CTA.
|
|
155
|
+
*/
|
|
156
|
+
interface PaymentRequiredProps {
|
|
157
|
+
/** Current balance in query credits */
|
|
158
|
+
queryCredits?: number;
|
|
159
|
+
/** INFER tokens needed per query */
|
|
160
|
+
inferPerQuery?: number;
|
|
161
|
+
/** Callback to open buy flow */
|
|
162
|
+
onBuy?: () => void;
|
|
163
|
+
/** Callback to dismiss */
|
|
164
|
+
onDismiss?: () => void;
|
|
165
|
+
/** CSS class name */
|
|
166
|
+
className?: string;
|
|
167
|
+
}
|
|
168
|
+
declare function PaymentRequired({ queryCredits, inferPerQuery, onBuy, onDismiss, className, }: PaymentRequiredProps): react_jsx_runtime.JSX.Element;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* BuyInferModal — fiat on-ramp widget for purchasing INFER with a credit card.
|
|
172
|
+
*
|
|
173
|
+
* Wraps MoonPay/Transak with Casino-branded pricing tiers.
|
|
174
|
+
*/
|
|
175
|
+
interface BuyInferModalProps {
|
|
176
|
+
/** Whether the modal is open */
|
|
177
|
+
isOpen: boolean;
|
|
178
|
+
/** Close callback */
|
|
179
|
+
onClose: () => void;
|
|
180
|
+
/** MoonPay/Transak API key */
|
|
181
|
+
apiKey: string;
|
|
182
|
+
/** sandbox or production */
|
|
183
|
+
environment?: 'sandbox' | 'production';
|
|
184
|
+
/** User's wallet address */
|
|
185
|
+
walletAddress: string;
|
|
186
|
+
/** INFER per query (for pricing display) */
|
|
187
|
+
inferPerQuery?: number;
|
|
188
|
+
/** CSS class name */
|
|
189
|
+
className?: string;
|
|
190
|
+
}
|
|
191
|
+
declare function BuyInferModal({ isOpen, onClose, apiKey, environment, walletAddress, inferPerQuery, className, }: BuyInferModalProps): react_jsx_runtime.JSX.Element | null;
|
|
192
|
+
|
|
193
|
+
declare function AppPaywall({ siteId, builderTenantId, children, onBlocked }: AppPaywallProps): react_jsx_runtime.JSX.Element;
|
|
194
|
+
|
|
195
|
+
export { AgentBalanceBadge, AppPaywall, AppPaywallProps, BuyInferModal, InferBalanceBadge, LoginButton, NeedsAgent, NeedsAgentProps, PaymentRequired, UseAgentBalanceReturn, UseAppAccessReturn, UseBuyInferReturn, UseDepositReturn, UseInferBalanceReturn, UseWalletAuthReturn, WalletProvider, WalletProviderProps, useAgentBalance, useAppAccess, useBuyInfer, useDeposit, useInferBalance, useWalletAuth };
|