@diviswap/sdk 1.7.6
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 +510 -0
- package/bin/create-diviswap-app.js +25 -0
- package/bin/diviswap-sdk.js +4 -0
- package/dist/cli/index.js +1888 -0
- package/dist/cli/templates/nextjs-app/actions.ts.hbs +259 -0
- package/dist/cli/templates/nextjs-app/api-hooks.ts.hbs +439 -0
- package/dist/cli/templates/nextjs-app/api-route.ts.hbs +502 -0
- package/dist/cli/templates/nextjs-app/auth-context.tsx.hbs +59 -0
- package/dist/cli/templates/nextjs-app/client.ts.hbs +116 -0
- package/dist/cli/templates/nextjs-app/dashboard-hooks.ts.hbs +180 -0
- package/dist/cli/templates/nextjs-app/example-page.tsx.hbs +276 -0
- package/dist/cli/templates/nextjs-app/hooks.ts.hbs +252 -0
- package/dist/cli/templates/nextjs-app/kyc-hooks.ts.hbs +87 -0
- package/dist/cli/templates/nextjs-app/kyc-wizard.css.hbs +433 -0
- package/dist/cli/templates/nextjs-app/kyc-wizard.tsx.hbs +711 -0
- package/dist/cli/templates/nextjs-app/layout-wrapper.tsx.hbs +13 -0
- package/dist/cli/templates/nextjs-app/layout.tsx.hbs +13 -0
- package/dist/cli/templates/nextjs-app/middleware.ts.hbs +49 -0
- package/dist/cli/templates/nextjs-app/provider-wrapper.tsx.hbs +8 -0
- package/dist/cli/templates/nextjs-app/provider.tsx.hbs +408 -0
- package/dist/cli/templates/nextjs-app/setup-provider.tsx.hbs +25 -0
- package/dist/cli/templates/nextjs-app/types.ts.hbs +159 -0
- package/dist/cli/templates/react/api-client-wrapper.ts.hbs +89 -0
- package/dist/cli/templates/react/example.tsx.hbs +69 -0
- package/dist/cli/templates/react/tanstack-hooks.ts.hbs +185 -0
- package/dist/cli/templates/webhooks/nextjs.hbs +98 -0
- package/dist/index.d.mts +91 -0
- package/dist/index.d.ts +91 -0
- package/dist/index.js +2339 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2313 -0
- package/dist/index.mjs.map +1 -0
- package/dist/react/index.d.mts +192 -0
- package/dist/react/index.d.ts +192 -0
- package/dist/react/index.js +1083 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/index.mjs +1064 -0
- package/dist/react/index.mjs.map +1 -0
- package/dist/wallet-BEGvzNtB.d.mts +1614 -0
- package/dist/wallet-BEGvzNtB.d.ts +1614 -0
- package/package.json +102 -0
- package/src/cli/templates/index.ts +65 -0
- package/src/cli/templates/nextjs-app/actions.ts.hbs +259 -0
- package/src/cli/templates/nextjs-app/api-hooks.ts.hbs +439 -0
- package/src/cli/templates/nextjs-app/api-route.ts.hbs +502 -0
- package/src/cli/templates/nextjs-app/auth-context.tsx.hbs +59 -0
- package/src/cli/templates/nextjs-app/client.ts.hbs +116 -0
- package/src/cli/templates/nextjs-app/dashboard-hooks.ts.hbs +180 -0
- package/src/cli/templates/nextjs-app/example-page.tsx.hbs +276 -0
- package/src/cli/templates/nextjs-app/hooks.ts.hbs +252 -0
- package/src/cli/templates/nextjs-app/kyc-hooks.ts.hbs +87 -0
- package/src/cli/templates/nextjs-app/kyc-wizard.css.hbs +433 -0
- package/src/cli/templates/nextjs-app/kyc-wizard.tsx.hbs +711 -0
- package/src/cli/templates/nextjs-app/layout-wrapper.tsx.hbs +13 -0
- package/src/cli/templates/nextjs-app/layout.tsx.hbs +13 -0
- package/src/cli/templates/nextjs-app/middleware.ts.hbs +49 -0
- package/src/cli/templates/nextjs-app/provider-wrapper.tsx.hbs +8 -0
- package/src/cli/templates/nextjs-app/provider.tsx.hbs +408 -0
- package/src/cli/templates/nextjs-app/setup-provider.tsx.hbs +25 -0
- package/src/cli/templates/nextjs-app/types.ts.hbs +159 -0
- package/src/cli/templates/react/api-client-wrapper.ts.hbs +89 -0
- package/src/cli/templates/react/example.tsx.hbs +69 -0
- package/src/cli/templates/react/tanstack-hooks.ts.hbs +185 -0
- package/src/cli/templates/shared/client.ts +78 -0
- package/src/cli/templates/webhooks/nextjs.hbs +98 -0
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { U as User, T as Transaction, P as Payee, D as Diviswap, d as Address, e as CreateAddressRequest, g as ChainName, l as WalletTrackingConfig, W as WalletConnection, k as EthereumWallet, i as WalletTracker } from '../wallet-BEGvzNtB.js';
|
|
3
|
+
|
|
4
|
+
interface DiviswapContextValue {
|
|
5
|
+
user: User | null;
|
|
6
|
+
loading: boolean;
|
|
7
|
+
error: Error | null;
|
|
8
|
+
login: (email: string, password: string) => Promise<void>;
|
|
9
|
+
logout: () => Promise<void>;
|
|
10
|
+
register: (data: any) => Promise<void>;
|
|
11
|
+
createTransaction: (data: any) => Promise<Transaction>;
|
|
12
|
+
getTransactions: (filters?: any) => Promise<Transaction[]>;
|
|
13
|
+
createPayee: (data: any) => Promise<Payee>;
|
|
14
|
+
getPayees: () => Promise<Payee[]>;
|
|
15
|
+
deletePayee: (id: string) => Promise<void>;
|
|
16
|
+
calculateFees?: (amount: number) => Promise<any>;
|
|
17
|
+
getIntegratorFees?: () => Promise<any>;
|
|
18
|
+
}
|
|
19
|
+
interface DiviswapProviderProps {
|
|
20
|
+
children: ReactNode;
|
|
21
|
+
}
|
|
22
|
+
declare function DiviswapProvider({ children }: DiviswapProviderProps): React.JSX.Element;
|
|
23
|
+
declare function useDiviswap(): DiviswapContextValue;
|
|
24
|
+
/** @deprecated Use DiviswapProvider instead */
|
|
25
|
+
declare const LiberExProvider: typeof DiviswapProvider;
|
|
26
|
+
/** @deprecated Use DiviswapContextValue instead */
|
|
27
|
+
type LiberExContextValue = DiviswapContextValue;
|
|
28
|
+
/** @deprecated Use DiviswapProviderProps instead */
|
|
29
|
+
type LiberExProviderProps = DiviswapProviderProps;
|
|
30
|
+
|
|
31
|
+
interface DiviswapFarcasterProviderProps {
|
|
32
|
+
children: ReactNode;
|
|
33
|
+
/** Where to store the session token: 'memory' for Farcaster mini apps, 'localStorage' for regular web apps */
|
|
34
|
+
tokenStorage?: 'memory' | 'localStorage';
|
|
35
|
+
}
|
|
36
|
+
declare function DiviswapFarcasterProvider({ children, tokenStorage }: DiviswapFarcasterProviderProps): React.JSX.Element;
|
|
37
|
+
/** @deprecated Use DiviswapFarcasterProvider instead */
|
|
38
|
+
declare const LiberExFarcasterProvider: typeof DiviswapFarcasterProvider;
|
|
39
|
+
/** @deprecated Use DiviswapFarcasterProviderProps instead */
|
|
40
|
+
type LiberExFarcasterProviderProps = DiviswapFarcasterProviderProps;
|
|
41
|
+
|
|
42
|
+
declare function useAuth(): {
|
|
43
|
+
user: User | null;
|
|
44
|
+
login: (email: string, password: string) => Promise<void>;
|
|
45
|
+
logout: () => Promise<void>;
|
|
46
|
+
register: (data: any) => Promise<void>;
|
|
47
|
+
loading: boolean;
|
|
48
|
+
error: Error | null;
|
|
49
|
+
isAuthenticated: boolean;
|
|
50
|
+
isLoading: boolean;
|
|
51
|
+
};
|
|
52
|
+
declare function useTransactions(): {
|
|
53
|
+
transactions: Transaction[];
|
|
54
|
+
loading: boolean;
|
|
55
|
+
error: Error | null;
|
|
56
|
+
fetchTransactions: (filters?: {
|
|
57
|
+
limit?: number;
|
|
58
|
+
offset?: number;
|
|
59
|
+
status?: "pending" | "processing" | "completed" | "failed";
|
|
60
|
+
type?: "onramp" | "offramp";
|
|
61
|
+
}) => Promise<Transaction[]>;
|
|
62
|
+
createTransaction: (data: any) => Promise<Transaction>;
|
|
63
|
+
refresh: (filters?: {
|
|
64
|
+
limit?: number;
|
|
65
|
+
offset?: number;
|
|
66
|
+
status?: "pending" | "processing" | "completed" | "failed";
|
|
67
|
+
type?: "onramp" | "offramp";
|
|
68
|
+
}) => Promise<Transaction[]>;
|
|
69
|
+
};
|
|
70
|
+
declare function usePayees(): {
|
|
71
|
+
payees: Payee[];
|
|
72
|
+
loading: boolean;
|
|
73
|
+
error: Error | null;
|
|
74
|
+
createPayee: (data: any) => Promise<Payee>;
|
|
75
|
+
deletePayee: (id: string) => Promise<void>;
|
|
76
|
+
refresh: () => Promise<Payee[]>;
|
|
77
|
+
defaultPayee: Payee | null;
|
|
78
|
+
};
|
|
79
|
+
interface KYCStatus {
|
|
80
|
+
kycStatus: 'NOT_STARTED' | 'PENDING' | 'APPROVED' | 'REJECTED' | 'EXPIRED';
|
|
81
|
+
kybStatus: 'NOT_REQUIRED' | 'NOT_STARTED' | 'PENDING' | 'APPROVED' | 'REJECTED';
|
|
82
|
+
canTransact: boolean;
|
|
83
|
+
requiresAction: boolean;
|
|
84
|
+
verificationLevel: 'none' | 'basic' | 'full';
|
|
85
|
+
nextStep?: 'COMPLETE_KYC' | 'COMPLETE_KYB' | 'WAIT_FOR_APPROVAL';
|
|
86
|
+
kycMetadata?: {
|
|
87
|
+
rejectLabels?: string[];
|
|
88
|
+
reviewRejectType?: string;
|
|
89
|
+
clientComment?: string;
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
interface UseKYCStatusOptions {
|
|
93
|
+
customerId?: string | null;
|
|
94
|
+
customerEmail?: string | null;
|
|
95
|
+
}
|
|
96
|
+
declare function useKYCStatus(options?: UseKYCStatusOptions): {
|
|
97
|
+
kycStatus: KYCStatus | null;
|
|
98
|
+
loading: boolean;
|
|
99
|
+
error: string | null;
|
|
100
|
+
refetch: () => void;
|
|
101
|
+
isKycApproved: boolean;
|
|
102
|
+
isKycPending: boolean;
|
|
103
|
+
isKycRejected: boolean;
|
|
104
|
+
needsKyc: boolean | undefined;
|
|
105
|
+
canTransact: boolean;
|
|
106
|
+
verificationLevel: "none" | "basic" | "full";
|
|
107
|
+
};
|
|
108
|
+
interface DashboardStats {
|
|
109
|
+
totalVolume: number;
|
|
110
|
+
pendingTransactions: number;
|
|
111
|
+
completedTransactions: number;
|
|
112
|
+
failedTransactions: number;
|
|
113
|
+
}
|
|
114
|
+
interface ChartDataPoint {
|
|
115
|
+
date: string;
|
|
116
|
+
volume: number;
|
|
117
|
+
transactions: number;
|
|
118
|
+
}
|
|
119
|
+
interface UseDashboardOptions {
|
|
120
|
+
customerId?: string | null;
|
|
121
|
+
customerEmail?: string | null;
|
|
122
|
+
}
|
|
123
|
+
declare function useDashboard(options?: UseDashboardOptions): {
|
|
124
|
+
stats: DashboardStats;
|
|
125
|
+
chartData: ChartDataPoint[];
|
|
126
|
+
transactions: Transaction[];
|
|
127
|
+
payees: Payee[];
|
|
128
|
+
loading: boolean;
|
|
129
|
+
refresh: () => Promise<void>;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Hook for managing user addresses
|
|
134
|
+
*/
|
|
135
|
+
declare function useAddresses(diviswap?: Diviswap): {
|
|
136
|
+
addresses: Address[];
|
|
137
|
+
loading: boolean;
|
|
138
|
+
error: Error | null;
|
|
139
|
+
fetchAddresses: () => Promise<void>;
|
|
140
|
+
createAddress: (data: CreateAddressRequest) => Promise<Address>;
|
|
141
|
+
setDefaultAddress: (data: {
|
|
142
|
+
chain_id: number;
|
|
143
|
+
address: string;
|
|
144
|
+
}) => Promise<void>;
|
|
145
|
+
deleteAddress: (data: {
|
|
146
|
+
chain_id: number;
|
|
147
|
+
address: string;
|
|
148
|
+
}) => Promise<void>;
|
|
149
|
+
getByChain: (chainIdOrName: number | ChainName) => Address[];
|
|
150
|
+
getDefault: (chainIdOrName: number | ChainName) => Address | null;
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* Hook for wallet connection and automatic address tracking
|
|
154
|
+
*/
|
|
155
|
+
declare function useWalletConnection(diviswap?: Diviswap, config?: WalletTrackingConfig): {
|
|
156
|
+
connections: WalletConnection[];
|
|
157
|
+
isConnecting: boolean;
|
|
158
|
+
isTracking: boolean;
|
|
159
|
+
error: Error | null;
|
|
160
|
+
connect: (wallet?: EthereumWallet) => Promise<WalletConnection[]>;
|
|
161
|
+
trackCurrent: (wallet?: EthereumWallet) => Promise<WalletConnection[]>;
|
|
162
|
+
setupTracking: (wallet?: EthereumWallet) => WalletTracker;
|
|
163
|
+
};
|
|
164
|
+
/**
|
|
165
|
+
* Hook that combines address management with wallet tracking
|
|
166
|
+
*/
|
|
167
|
+
declare function useWalletAddresses(diviswap?: Diviswap, config?: WalletTrackingConfig): {
|
|
168
|
+
connections: WalletConnection[];
|
|
169
|
+
isConnecting: boolean;
|
|
170
|
+
isTracking: boolean;
|
|
171
|
+
walletError: Error | null;
|
|
172
|
+
connectAndTrack: (wallet?: EthereumWallet) => Promise<WalletConnection[]>;
|
|
173
|
+
trackCurrentAndRefresh: (wallet?: EthereumWallet) => Promise<WalletConnection[]>;
|
|
174
|
+
setupTracking: (wallet?: EthereumWallet) => WalletTracker;
|
|
175
|
+
addresses: Address[];
|
|
176
|
+
loading: boolean;
|
|
177
|
+
error: Error | null;
|
|
178
|
+
fetchAddresses: () => Promise<void>;
|
|
179
|
+
createAddress: (data: CreateAddressRequest) => Promise<Address>;
|
|
180
|
+
setDefaultAddress: (data: {
|
|
181
|
+
chain_id: number;
|
|
182
|
+
address: string;
|
|
183
|
+
}) => Promise<void>;
|
|
184
|
+
deleteAddress: (data: {
|
|
185
|
+
chain_id: number;
|
|
186
|
+
address: string;
|
|
187
|
+
}) => Promise<void>;
|
|
188
|
+
getByChain: (chainIdOrName: number | ChainName) => Address[];
|
|
189
|
+
getDefault: (chainIdOrName: number | ChainName) => Address | null;
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
export { type ChartDataPoint, type DashboardStats, type DiviswapContextValue, DiviswapFarcasterProvider, type DiviswapFarcasterProviderProps, DiviswapProvider, type DiviswapProviderProps, type KYCStatus, type LiberExContextValue, LiberExFarcasterProvider, type LiberExFarcasterProviderProps, LiberExProvider, type LiberExProviderProps, type UseDashboardOptions, type UseKYCStatusOptions, useAddresses, useAuth, useDashboard, useDiviswap, useKYCStatus, useDiviswap as useLiberEx, usePayees, useTransactions, useWalletAddresses, useWalletConnection };
|