@ab-org/predicate-market-sdk 0.1.1 → 1.0.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.
Files changed (91) hide show
  1. package/dist/index.d.ts +672 -22
  2. package/dist/index.js +4700 -23
  3. package/package.json +6 -5
  4. package/dist/auth/autoReconnect.d.ts +0 -11
  5. package/dist/auth/autoReconnect.js +0 -36
  6. package/dist/auth/bundledConfig.d.ts +0 -2
  7. package/dist/auth/bundledConfig.js +0 -19
  8. package/dist/auth/config.d.ts +0 -29
  9. package/dist/auth/config.js +0 -53
  10. package/dist/auth/google.d.ts +0 -43
  11. package/dist/auth/google.js +0 -147
  12. package/dist/auth/oidcRelay.d.ts +0 -11
  13. package/dist/auth/oidcRelay.js +0 -107
  14. package/dist/auth/twitter.d.ts +0 -7
  15. package/dist/auth/twitter.js +0 -94
  16. package/dist/auth/walletAccount.d.ts +0 -20
  17. package/dist/auth/walletAccount.js +0 -267
  18. package/dist/constants/chains.d.ts +0 -2
  19. package/dist/constants/chains.js +0 -3
  20. package/dist/modules/api.d.ts +0 -149
  21. package/dist/modules/api.js +0 -95
  22. package/dist/modules/balanceQuery.d.ts +0 -27
  23. package/dist/modules/balanceQuery.js +0 -60
  24. package/dist/modules/deposit.d.ts +0 -31
  25. package/dist/modules/deposit.js +0 -58
  26. package/dist/modules/marketData.d.ts +0 -8
  27. package/dist/modules/marketData.js +0 -107
  28. package/dist/modules/withdraw.d.ts +0 -31
  29. package/dist/modules/withdraw.js +0 -61
  30. package/dist/modules/withdrawDirect.d.ts +0 -14
  31. package/dist/modules/withdrawDirect.js +0 -33
  32. package/dist/modules/withdrawExecutor.d.ts +0 -56
  33. package/dist/modules/withdrawExecutor.js +0 -210
  34. package/dist/policyAdapter.d.ts +0 -11
  35. package/dist/policyAdapter.js +0 -38
  36. package/dist/types.d.ts +0 -62
  37. package/dist/types.js +0 -1
  38. package/dist/ui/DepositModal.d.ts +0 -36
  39. package/dist/ui/DepositModal.js +0 -354
  40. package/dist/ui/SignInModal.d.ts +0 -22
  41. package/dist/ui/SignInModal.js +0 -77
  42. package/dist/ui/SignInModal.sections.d.ts +0 -33
  43. package/dist/ui/SignInModal.sections.js +0 -45
  44. package/dist/ui/SignInModal.shared.d.ts +0 -15
  45. package/dist/ui/SignInModal.shared.js +0 -126
  46. package/dist/ui/WalletSelectionModal.d.ts +0 -14
  47. package/dist/ui/WalletSelectionModal.js +0 -54
  48. package/dist/ui/WithdrawModal.d.ts +0 -57
  49. package/dist/ui/WithdrawModal.js +0 -574
  50. package/dist/ui/components/CloseButton.d.ts +0 -4
  51. package/dist/ui/components/CloseButton.js +0 -15
  52. package/dist/ui/components/Countdown.d.ts +0 -16
  53. package/dist/ui/components/Countdown.js +0 -42
  54. package/dist/ui/components/DepositDetailsPanel.d.ts +0 -8
  55. package/dist/ui/components/DepositDetailsPanel.js +0 -143
  56. package/dist/ui/components/DropdownField.d.ts +0 -19
  57. package/dist/ui/components/DropdownField.js +0 -81
  58. package/dist/ui/components/Field.d.ts +0 -10
  59. package/dist/ui/components/Field.js +0 -21
  60. package/dist/ui/components/LoginRequiredOverlay.d.ts +0 -6
  61. package/dist/ui/components/LoginRequiredOverlay.js +0 -31
  62. package/dist/ui/components/ModalCard.d.ts +0 -9
  63. package/dist/ui/components/ModalCard.js +0 -14
  64. package/dist/ui/components/ModalFrame.d.ts +0 -9
  65. package/dist/ui/components/ModalFrame.js +0 -18
  66. package/dist/ui/components/PrimaryButton.d.ts +0 -2
  67. package/dist/ui/components/PrimaryButton.js +0 -14
  68. package/dist/ui/components/QRCodePanel.d.ts +0 -4
  69. package/dist/ui/components/QRCodePanel.js +0 -43
  70. package/dist/ui/components/Select.d.ts +0 -12
  71. package/dist/ui/components/Select.js +0 -29
  72. package/dist/ui/components/StepIndicator.d.ts +0 -7
  73. package/dist/ui/components/StepIndicator.js +0 -35
  74. package/dist/ui/components/Success.d.ts +0 -1
  75. package/dist/ui/components/Success.js +0 -4
  76. package/dist/ui/components/Toast.d.ts +0 -8
  77. package/dist/ui/components/Toast.js +0 -51
  78. package/dist/ui/hooks/useSession.d.ts +0 -2
  79. package/dist/ui/hooks/useSession.js +0 -10
  80. package/dist/ui/signInTypes.d.ts +0 -28
  81. package/dist/ui/signInTypes.js +0 -1
  82. package/dist/ui/theme.d.ts +0 -31
  83. package/dist/ui/theme.js +0 -31
  84. package/dist/ui/useSignInModalController.d.ts +0 -25
  85. package/dist/ui/useSignInModalController.js +0 -119
  86. package/dist/utils/env.d.ts +0 -1
  87. package/dist/utils/env.js +0 -63
  88. package/dist/utils/explorer.d.ts +0 -3
  89. package/dist/utils/explorer.js +0 -47
  90. package/dist/walletUtils.d.ts +0 -3
  91. package/dist/walletUtils.js +0 -3
package/dist/index.d.ts CHANGED
@@ -1,22 +1,672 @@
1
- export * from "./types.js";
2
- export * from "./auth/config.js";
3
- export * from "./auth/autoReconnect.js";
4
- export * from "./auth/google.js";
5
- export * from "./auth/twitter.js";
6
- export * from "./modules/deposit.js";
7
- export * from "./modules/withdraw.js";
8
- export * from "./modules/marketData.js";
9
- export * from "./modules/balanceQuery.js";
10
- export * from "./modules/withdrawExecutor.js";
11
- export * from "./modules/api.js";
12
- export * from "./modules/withdrawDirect.js";
13
- export * from "./policyAdapter.js";
14
- export * from "./ui/SignInModal.js";
15
- export * from "./ui/signInTypes.js";
16
- export * from "./ui/WalletSelectionModal.js";
17
- export * from "./ui/DepositModal.js";
18
- export * from "./ui/WithdrawModal.js";
19
- export * from "./ui/components/DropdownField.js";
20
- export * from "./ui/components/DepositDetailsPanel.js";
21
- export * from "./walletUtils.js";
22
- export * from "./constants/chains.js";
1
+ import { SessionCapabilityPolicy, CubeSignerConfig, WalletSession, SupportedToken, SupportedChain, WalletCapability, CubeSignerSession } from '@ab-org/sdk-core';
2
+ import { ReactNode, ChangeEventHandler } from 'react';
3
+ import { AxiosInstance } from 'axios';
4
+ import * as react_jsx_runtime_js from 'react/jsx-runtime.js';
5
+ export { ClientIds, DEFAULT_FUNDING_CHAIN_ID, DEFAULT_FUNDING_TOKEN_ADDRESS, EvmChainInfo, getChainInfo, getFundingTokenAddress } from '@ab-org/wallet-utils';
6
+
7
+ interface CustodyAdapter {
8
+ getDepositStatus(depositId: string): Promise<{
9
+ status: string;
10
+ txHash?: string;
11
+ }>;
12
+ requestWithdraw(params: {
13
+ amount: string;
14
+ token: string;
15
+ chain: string;
16
+ targetAddress: string;
17
+ }): Promise<{
18
+ requestId: string;
19
+ }>;
20
+ getWithdrawStatus(requestId: string): Promise<{
21
+ status: string;
22
+ txHash?: string;
23
+ etaSeconds?: number;
24
+ }>;
25
+ }
26
+ interface ModalController<TConfig> {
27
+ open(config?: TConfig): void;
28
+ }
29
+ interface TokenInfo {
30
+ symbol: string;
31
+ name: string;
32
+ decimals: number;
33
+ iconUrl?: string;
34
+ minAmount?: string;
35
+ maxAmount?: string;
36
+ }
37
+ interface ChainInfo {
38
+ id: string;
39
+ name: string;
40
+ iconUrl?: string;
41
+ confirmations?: number;
42
+ estimatedTime?: string;
43
+ }
44
+ interface QuoteRequest$1 {
45
+ token: string;
46
+ chain: string;
47
+ amount: string;
48
+ direction: "deposit" | "withdraw";
49
+ }
50
+ interface QuoteResult {
51
+ quoteId: string;
52
+ estimatedAmount: string;
53
+ slippage: string;
54
+ fee: string;
55
+ feeToken: string;
56
+ exchangeRate: string;
57
+ expiresAt: number;
58
+ }
59
+ interface DepositAddressResult {
60
+ address: string;
61
+ minimumDeposit?: string;
62
+ }
63
+ interface MarketDataProvider {
64
+ getSupportedTokens(direction: "deposit" | "withdraw"): Promise<TokenInfo[]>;
65
+ getSupportedChains(token: string, direction: "deposit" | "withdraw"): Promise<ChainInfo[]>;
66
+ getQuote(request: QuoteRequest$1): Promise<QuoteResult>;
67
+ getDepositAddress(token: string, chain: string): Promise<DepositAddressResult>;
68
+ }
69
+
70
+ interface WalletItem {
71
+ id: string;
72
+ name: string;
73
+ icon?: ReactNode;
74
+ installed?: boolean;
75
+ installUrl?: string;
76
+ }
77
+ interface SocialProvider {
78
+ id: string;
79
+ label: string;
80
+ icon?: ReactNode;
81
+ }
82
+ interface SignInUiConfig {
83
+ socialProviders?: SocialProvider[];
84
+ wallets?: WalletItem[];
85
+ initialVisibleCount?: number;
86
+ /**
87
+ * @deprecated Ignored by `SignInModal` / `useSignInModalController`: social login creates the session without `window.confirm`.
88
+ */
89
+ sessionConfirmation?: {
90
+ enabled?: boolean;
91
+ title?: string;
92
+ message?: string;
93
+ };
94
+ sessionPolicy?: Partial<SessionCapabilityPolicy>;
95
+ }
96
+
97
+ interface SDKConfig {
98
+ googleClientId?: string;
99
+ twitterClientId?: string;
100
+ twitterRedirectUri?: string;
101
+ cubeSigner?: CubeSignerConfig;
102
+ signIn?: SignInUiConfig;
103
+ }
104
+ /**
105
+ * Fixed auth config: built-in bundled defaults (see bundledConfig.ts) with optional
106
+ * overrides from environment (server / `NEXT_PUBLIC_*` client). Used as defaults in initSDK.
107
+ */
108
+ declare function getFixedAuthConfig(): Partial<SDKConfig>;
109
+ /**
110
+ * Config for initializing the predicate SDK. Defaults come from bundled config
111
+ * (and env overrides); you may override any of them here. Optional top-level
112
+ * `registerUser` is merged into `cubeSigner.oidcLoginHooks` when cubeSigner is present.
113
+ */
114
+ interface PredicateSDKConfig extends Partial<SDKConfig> {
115
+ /**
116
+ * Optional hook to register the user on your backend when CubeSigner proof
117
+ * indicates the user is not initialized. Used when cubeSigner is available
118
+ * (from env or override).
119
+ */
120
+ registerUser?: (oidcToken: string) => Promise<void>;
121
+ }
122
+ declare function initSDK(config?: PredicateSDKConfig): void;
123
+ declare function getSDKConfig(): Readonly<SDKConfig>;
124
+
125
+ /**
126
+ * Attempt to silently reconnect a wallet whose session was restored
127
+ * from localStorage cache. Creates a temporary `WalletConnector` with
128
+ * the default adapter registry (injected wallets + Cubist if configured)
129
+ * and delegates to `WalletConnector.tryAutoReconnect()`.
130
+ *
131
+ * Safe to call multiple times — concurrent calls share the same promise.
132
+ * Returns the fresh session on success, or `null` if reconnection failed.
133
+ */
134
+ declare function tryAutoReconnect(): Promise<WalletSession | null>;
135
+
136
+ declare global {
137
+ interface Window {
138
+ google?: {
139
+ accounts: {
140
+ id: {
141
+ initialize(config: GISInitConfig): void;
142
+ prompt(momentListener?: (notification: GISPromptMoment) => void): void;
143
+ renderButton(parent: HTMLElement, options: GISButtonConfig): void;
144
+ revoke(hint: string, callback?: () => void): void;
145
+ };
146
+ };
147
+ };
148
+ }
149
+ }
150
+ interface GISInitConfig {
151
+ client_id: string;
152
+ callback: (response: GISCredentialResponse) => void;
153
+ auto_select?: boolean;
154
+ cancel_on_tap_outside?: boolean;
155
+ use_fedcm_for_prompt?: boolean;
156
+ }
157
+ interface GISCredentialResponse {
158
+ credential: string;
159
+ }
160
+ interface GISPromptMoment {
161
+ isSkippedMoment(): boolean;
162
+ isDismissedMoment(): boolean;
163
+ isNotDisplayed(): boolean;
164
+ getDismissedReason(): string;
165
+ }
166
+ interface GISButtonConfig {
167
+ type?: "standard" | "icon";
168
+ size?: "large" | "medium" | "small";
169
+ }
170
+ interface GoogleCredential {
171
+ idToken: string;
172
+ email?: string;
173
+ name?: string;
174
+ picture?: string;
175
+ }
176
+ declare function isFedCMSupported(): boolean;
177
+ declare function signInWithGoogle(clientId: string): Promise<GoogleCredential>;
178
+
179
+ interface TwitterAuthResult {
180
+ code: string;
181
+ codeVerifier: string;
182
+ state: string;
183
+ }
184
+ declare function notifyTwitterCallback(): void;
185
+ declare function signInWithTwitter(clientId: string, redirectUri: string): Promise<TwitterAuthResult>;
186
+
187
+ interface DepositModalConfig {
188
+ preferredToken?: string;
189
+ preferredChain?: string;
190
+ onStatusChange?: (status: DepositStatus) => void;
191
+ }
192
+ type DepositStatus = {
193
+ phase: "idle";
194
+ } | {
195
+ phase: "address-issued";
196
+ depositId: string;
197
+ address: string;
198
+ } | {
199
+ phase: "confirming";
200
+ depositId: string;
201
+ } | {
202
+ phase: "settled";
203
+ depositId: string;
204
+ txHash?: string;
205
+ } | {
206
+ phase: "failed";
207
+ reason: string;
208
+ };
209
+ interface DepositController extends ModalController<DepositModalConfig> {
210
+ readonly status: DepositStatus;
211
+ fetchTokens(): Promise<TokenInfo[]>;
212
+ fetchChains(token: string): Promise<ChainInfo[]>;
213
+ fetchQuote(token: string, chain: string, amount: string): Promise<QuoteResult>;
214
+ fetchDepositAddress(token: string, chain: string): Promise<DepositAddressResult>;
215
+ }
216
+ declare const createDepositController: (custody: CustodyAdapter, marketData: MarketDataProvider) => DepositController;
217
+
218
+ interface WithdrawModalConfig {
219
+ defaultAmount?: string;
220
+ defaultToken?: string;
221
+ defaultChain?: string;
222
+ targetAddress?: string;
223
+ onStatusChange?: (status: WithdrawStatus) => void;
224
+ }
225
+ type WithdrawStatus = {
226
+ phase: "idle";
227
+ } | {
228
+ phase: "requested";
229
+ requestId: string;
230
+ } | {
231
+ phase: "processing";
232
+ requestId: string;
233
+ } | {
234
+ phase: "settled";
235
+ requestId: string;
236
+ txHash?: string;
237
+ } | {
238
+ phase: "failed";
239
+ reason: string;
240
+ };
241
+ interface WithdrawController extends ModalController<WithdrawModalConfig> {
242
+ readonly status: WithdrawStatus;
243
+ fetchTokens(): Promise<TokenInfo[]>;
244
+ fetchChains(token: string): Promise<ChainInfo[]>;
245
+ fetchQuote(token: string, chain: string, amount: string): Promise<QuoteResult>;
246
+ }
247
+ declare const createWithdrawController: (custody: CustodyAdapter, marketData: MarketDataProvider) => WithdrawController;
248
+
249
+ /**
250
+ * Default `MarketDataProvider` backed by the merchant chains API.
251
+ * - getSupportedTokens / getSupportedChains: from GET `{merchantBase}/chains`
252
+ * - getQuote: local estimate until a dedicated quote API exists
253
+ * - getDepositAddress: 当前 session 钱包地址 + 与 `token`/`chain` 匹配的 `GET /chains` 中 `minimum_deposit`(按 decimals 格式化)
254
+ */
255
+ declare function createMarketDataProvider(): MarketDataProvider;
256
+
257
+ interface Erc20BalanceResult {
258
+ raw: bigint;
259
+ formatted: string;
260
+ symbol: string;
261
+ }
262
+ /**
263
+ * Query any ERC-20 token balance via a raw JSON-RPC `eth_call`.
264
+ * No external library dependency – uses the global `fetch`.
265
+ */
266
+ declare function fetchErc20Balance(rpcUrl: string, tokenAddress: string, walletAddress: string): Promise<bigint>;
267
+ interface FundingTokenBalanceOptions {
268
+ rpcUrl?: string;
269
+ tokenAddress?: string;
270
+ decimals?: number;
271
+ /**
272
+ * Funding chain id (e.g. `"3131"` Tenderly BSC, `"56"` mainnet).
273
+ * When omitted, defaults to `3131` via {@link getChainInfo}.
274
+ */
275
+ chainId?: string | number | null;
276
+ /** Label for {@link Erc20BalanceResult.symbol} (default `"Funding"`). */
277
+ displaySymbol?: string;
278
+ }
279
+ /**
280
+ * Fetches the configured funding ERC-20 balance on the selected funding chain.
281
+ * Defaults: chain `3131`, RPC from {@link getChainInfo}, token from {@link getFundingTokenAddress} / env.
282
+ */
283
+ declare function fetchFundingTokenBalance(walletAddress: string, options?: FundingTokenBalanceOptions): Promise<Erc20BalanceResult>;
284
+
285
+ interface WithdrawRequest {
286
+ /** 用户收款地址(目标链) */
287
+ toAddress: string;
288
+ /** Human-readable amount, e.g. "100.5" */
289
+ amount: string;
290
+ /** 目标链代币 symbol,如 "USDT" */
291
+ token: string;
292
+ /** 目标链 chain_id */
293
+ chain: string;
294
+ }
295
+ interface WithdrawResult {
296
+ /** Funding 链上转入一次性地址的 tx hash */
297
+ txHash: string;
298
+ /** 提现订单 ID,用于轮询 getWithdrawOrder(orderId) */
299
+ orderId: string;
300
+ /** 广播 funding tx 的链 id,用于构建 explorer 链接 */
301
+ fundingChainId?: string;
302
+ }
303
+ /**
304
+ * A function that executes a withdraw operation.
305
+ * Callers can supply their own implementation to override the default behaviour.
306
+ */
307
+ type WithdrawExecutor = (request: WithdrawRequest) => Promise<WithdrawResult>;
308
+ /**
309
+ * Convert a human-readable decimal string to the smallest unit (wei-equivalent).
310
+ *
311
+ * Examples with decimals=18:
312
+ * "1" → 1000000000000000000n
313
+ * "0.5" → 500000000000000000n
314
+ * "100.1" → 100100000000000000000n
315
+ */
316
+ declare function parseUnits(value: string, decimals: number): bigint;
317
+ interface FundingWithdrawExecutorOptions {
318
+ /** 源链 funding ERC-20 合约地址;默认 {@link getFundingTokenAddress} / env */
319
+ tokenAddress?: string;
320
+ decimals?: number;
321
+ /**
322
+ * Funding EVM chain id(如 `3131` Tenderly、`56` 主网)。未传时默认 `3131`。
323
+ */
324
+ chainId?: number | string;
325
+ /** 覆盖 {@link getChainInfo} 提供的 JSON-RPC URL */
326
+ rpcUrl?: string;
327
+ /** 系统配置的单笔限额(wei 字符串),若提供则校验 request.amount 不得超过此值 */
328
+ maxAmountWei?: string;
329
+ /**
330
+ * 与商户订单接口约定的 funding 侧 token symbol(默认 `USDT`,按后端协议)。
331
+ */
332
+ fundingLegTokenSymbol?: string;
333
+ }
334
+ /**
335
+ * Factory that returns a `WithdrawExecutor` implementing the flow in withdraw.md:
336
+ * 1) Create NATIVE_SWAP order → get one-time wallet address (OTW);
337
+ * 2) Sign ERC-20 transfer of the funding token on the funding chain to the OTW (not to user);
338
+ * 3) Broadcast tx and return { txHash, orderId } for the client to poll getWithdrawOrder(orderId).
339
+ */
340
+ declare function createFundingWithdrawExecutor(options?: FundingWithdrawExecutorOptions): WithdrawExecutor;
341
+
342
+ /**
343
+ * Merchant API client
344
+ * 基于 axios 封装,类型与文档一致。
345
+ */
346
+
347
+ /** 通用 API 响应:所有接口统一格式 */
348
+ interface ApiResponse<T> {
349
+ data: T | null;
350
+ code: number;
351
+ msg: string;
352
+ timestamp: number;
353
+ }
354
+ interface TokenData {
355
+ symbol: string;
356
+ address: string;
357
+ decimals: number;
358
+ /** 最小充值量(最小单位字符串,如 `"15000000"`) */
359
+ minimum_deposit?: string;
360
+ /** 是否为 USD 类稳定币 */
361
+ is_usd_stable?: boolean;
362
+ }
363
+ interface ChainData {
364
+ chain_id: string;
365
+ network: string;
366
+ tokens: TokenData[];
367
+ }
368
+ interface ChainsResponseData {
369
+ chains: ChainData[];
370
+ is_testnet: boolean;
371
+ }
372
+ interface PlatformRegisterRequest {
373
+ platform_contract_address: string;
374
+ chain_id: string;
375
+ }
376
+ interface PlatformRegisterResponseData {
377
+ deposit_address: string;
378
+ chain_id: string;
379
+ }
380
+ type QuoteDirection = "deposit" | "withdraw";
381
+ interface QuoteRequest {
382
+ direction: QuoteDirection;
383
+ chain_id: string;
384
+ token_address: string;
385
+ token_amount?: string;
386
+ dst_token_amount?: string;
387
+ }
388
+ interface QuoteResponseData {
389
+ token_address: string;
390
+ token_symbol: string;
391
+ token_decimals: number;
392
+ rate: string;
393
+ chain_id: number;
394
+ deposit_address?: string;
395
+ dst_token_amount?: string;
396
+ token_amount?: string;
397
+ expires_at?: string;
398
+ }
399
+ type DepositOrderStatus = "received" | "processing" | "completed" | "failed" | "funded";
400
+ interface DepositOrderResponseData {
401
+ order_id: string;
402
+ status: DepositOrderStatus;
403
+ source_chain_id: string;
404
+ token_address: string;
405
+ token_amount?: string;
406
+ dst_token_amount?: string;
407
+ deposit_address?: string;
408
+ source_tx_hash?: string;
409
+ created_at?: string;
410
+ updated_at?: string;
411
+ }
412
+ type WithdrawOrderStatus = "pending" | "funded" | "processing" | "completed" | "failed" | "expired";
413
+ interface WithdrawOrderResponseData {
414
+ order_id: string;
415
+ status: WithdrawOrderStatus;
416
+ one_time_address?: string;
417
+ chain_id: string;
418
+ dst_token_amount: string;
419
+ /** Fee (e.g. "0.01 USDT"); only present if backend includes it in GET /api/v1/orders/withdraw/:id. UI falls back to feeDisplay prop or "—". */
420
+ fee?: string;
421
+ target_chain_id: string;
422
+ target_address: string;
423
+ funding_tx_hash?: string;
424
+ dst_tx_hash?: string;
425
+ out_tx_hash?: string;
426
+ created_at?: string;
427
+ updated_at?: string;
428
+ }
429
+ interface NativeSwapPayload {
430
+ chain_id: string;
431
+ token_address: string;
432
+ token_amount: string;
433
+ dst_chain_id: string;
434
+ dst_token_address: string;
435
+ recipient: string;
436
+ }
437
+ interface PaymentPairData {
438
+ token_symbol: string;
439
+ token_amount: string;
440
+ token_address: string;
441
+ user_address: string;
442
+ chain_id: string;
443
+ }
444
+ interface CreateOrderRequest {
445
+ intent_id: string;
446
+ order_type: "NATIVE_SWAP";
447
+ order_payload: NativeSwapPayload;
448
+ payment_pairs: PaymentPairData[];
449
+ }
450
+ type PaymentSessionStatus = "CREATED" | "PENDING" | "FUNDED" | "CANCELED" | "CAPTURING" | "SUCCEED";
451
+ interface PaymentSessionResponseData {
452
+ payment_session_id: string;
453
+ created_at?: string;
454
+ status: PaymentSessionStatus;
455
+ one_time_wallet_address: string;
456
+ amount: string;
457
+ currency: string;
458
+ user_address?: string;
459
+ network?: string;
460
+ token_symbol?: string;
461
+ chain_id?: string;
462
+ funding_transaction_hash?: string | null;
463
+ capturable_amount?: string;
464
+ captured_amount?: string;
465
+ }
466
+ interface CreateOrderResponseData {
467
+ order_id: string;
468
+ payment_sessions: PaymentSessionResponseData[];
469
+ }
470
+ /**
471
+ * 配置 Merchant API 的 baseURL
472
+ */
473
+ declare function configureMerchantApi(): void;
474
+ /**
475
+ * 获取当前 axios 实例(用于自定义请求)
476
+ */
477
+ declare function getMerchantApiClient(): AxiosInstance;
478
+ /** GET /chains - 查询支持的链和代币列表 */
479
+ declare function getChains(): Promise<ChainsResponseData>;
480
+ /** POST /api/v1/platform - 注册平台合约并获取充值地址 */
481
+ declare function registerPlatform(body: PlatformRegisterRequest): Promise<PlatformRegisterResponseData>;
482
+ /** POST /api/v1/quote - 统一报价(充值/提现) */
483
+ declare function quote(body: QuoteRequest): Promise<QuoteResponseData>;
484
+ /** GET /api/v1/orders/deposit/{order_id} - 查询充值订单状态 */
485
+ declare function getDepositOrder(orderId: string): Promise<DepositOrderResponseData>;
486
+ /** GET /api/v1/orders/withdraw/{order_id} - 查询提现订单状态 */
487
+ declare function getWithdrawOrder(orderId: string): Promise<WithdrawOrderResponseData>;
488
+ /** POST /order - 创建 NATIVE_SWAP 提现订单 */
489
+ declare function createOrder(body: CreateOrderRequest): Promise<CreateOrderResponseData>;
490
+
491
+ /**
492
+ * funding 链(与 {@link DEFAULT_FUNDING_CHAIN_ID} 一致)上,且 `tokenAddress` 在 Merchant `GET /chains`
493
+ * 中对应条目的 `is_usd_stable === true` 时,由业务层自行完成提现并构造 `withdrawDirectResult`;
494
+ * 其余情况走默认 funding 提现执行器与订单轮询。
495
+ */
496
+ declare function isUsdtWithdrawDirect(chainId: string, tokenAddress: string, chains: ChainData[]): boolean;
497
+ /**
498
+ * 从 `getChains()` 返回的 `chains` 中,按当前选择的链 id + token symbol 或合约地址解析 `TokenData`。
499
+ */
500
+ declare function findTokenDataFromChains(chains: ChainData[], chainId: string, opts: {
501
+ symbol: string;
502
+ tokenAddress?: string;
503
+ }): TokenData | undefined;
504
+
505
+ interface PredicateMarketPolicyAdapterOptions {
506
+ appId?: string;
507
+ origin?: string;
508
+ expiresAt?: number;
509
+ }
510
+ declare const createPredicateMarketPolicyAdapter: (options?: PredicateMarketPolicyAdapterOptions) => {
511
+ deposit(token: SupportedToken, chain: SupportedChain, maxAmount?: string): SessionCapabilityPolicy;
512
+ withdraw(token: SupportedToken, chain: SupportedChain, maxAmount?: string): SessionCapabilityPolicy;
513
+ trade(chain: SupportedChain, capabilities?: WalletCapability[]): SessionCapabilityPolicy;
514
+ };
515
+
516
+ interface SignInModalProps {
517
+ title?: string;
518
+ socialProviders?: SocialProvider[];
519
+ wallets?: WalletItem[];
520
+ initialVisibleCount?: number;
521
+ privacyPolicyUrl?: string;
522
+ termsOfUseUrl?: string;
523
+ onGoogleLogin?: (credential: GoogleCredential) => void;
524
+ onTwitterLogin?: (result: TwitterAuthResult) => void;
525
+ onCubeSignerSession?: (session: CubeSignerSession) => void;
526
+ onWalletConnected?: (session: WalletSession, walletId: string) => void;
527
+ onSocialLogin?: (providerId: string) => void;
528
+ onWalletSelect?: (walletId: string) => void | Promise<void>;
529
+ onDismiss?: () => void;
530
+ onSuccess?: (session: WalletSession) => void;
531
+ }
532
+ declare function clearSocialAccountInstance(): void;
533
+ declare const SignInModal: ({ title, socialProviders, wallets, initialVisibleCount, privacyPolicyUrl, termsOfUseUrl, onGoogleLogin, onTwitterLogin, onCubeSignerSession, onWalletConnected, onSocialLogin, onWalletSelect, onDismiss, onSuccess, }: SignInModalProps) => react_jsx_runtime_js.JSX.Element;
534
+
535
+ interface WalletOption {
536
+ id: string;
537
+ label: string;
538
+ description: string;
539
+ category: "social" | "plugin";
540
+ icon?: ReactNode;
541
+ }
542
+ interface WalletSelectionModalProps {
543
+ title?: string;
544
+ options: WalletOption[];
545
+ onSelect?: (id: string) => void;
546
+ }
547
+ declare const WalletSelectionModal: ({ title, options, onSelect, }: WalletSelectionModalProps) => react_jsx_runtime_js.JSX.Element;
548
+
549
+ interface SelectOption {
550
+ id: string;
551
+ label: string;
552
+ subtitle?: string;
553
+ icon?: ReactNode;
554
+ }
555
+ interface DropdownFieldProps {
556
+ label: string;
557
+ placeholder?: string;
558
+ value?: string;
559
+ icon?: ReactNode;
560
+ focused?: boolean;
561
+ options?: SelectOption[];
562
+ onSelect?: (id: string) => void;
563
+ /** @deprecated Use `options` + `onSelect` instead. */
564
+ onClick?: () => void;
565
+ }
566
+ declare const DropdownField: ({ label, placeholder, value, icon, focused, options, onSelect, onClick, }: DropdownFieldProps) => react_jsx_runtime_js.JSX.Element;
567
+
568
+ interface DepositModalProps {
569
+ /** Pre-selected token id. */
570
+ token?: string;
571
+ /** Pre-selected chain id. */
572
+ chain?: string;
573
+ /** Available tokens (when not provided, fetched from getChains). */
574
+ tokenOptions?: SelectOption[];
575
+ /** Available chains (when not provided, derived from getChains by token). */
576
+ chainOptions?: SelectOption[];
577
+ /** Deposit address,必须由调用方传入;在已选 token+chain 时若未传入合法值将抛错。 */
578
+ depositAddress?: string;
579
+ /** e.g. "0.01 USDT" */
580
+ minimumDeposit?: string;
581
+ /** Icon rendered at the center of the QR code. */
582
+ qrCenterIcon?: ReactNode;
583
+ /** Extra icons shown on the Transfer Crypto row. */
584
+ cryptoIcons?: ReactNode;
585
+ /** Deposit amount for quote (optional; when set, quote is fetched and shown). */
586
+ depositAmount?: string;
587
+ /** Called for toast messages (copy, quote expired, wait for balance, transfer confirmed). */
588
+ onShowToast?: (message: string) => void;
589
+ /** When set, show "Transfer confirmed" toast and explorer link. */
590
+ txHash?: string;
591
+ /** Build explorer URL for tx; e.g. (chainId, txHash) => `https://bscscan.com/tx/${txHash}` */
592
+ explorerTxUrl?: (chainId: string, txHash: string) => string;
593
+ onTokenSelect?: (id: string) => void;
594
+ onChainSelect?: (id: string) => void;
595
+ onCopyAddress?: (address: string) => void;
596
+ onBuyCrypto?: () => void;
597
+ onSignIn?: () => void;
598
+ onBack?: () => void;
599
+ onClose?: () => void;
600
+ }
601
+ declare const DepositModal: ({ token, chain, tokenOptions: tokenOptionsProp, chainOptions: chainOptionsProp, depositAddress, minimumDeposit, qrCenterIcon, cryptoIcons, depositAmount, onShowToast, txHash, explorerTxUrl, onTokenSelect, onChainSelect, onCopyAddress, onBuyCrypto, onSignIn, onBack, onClose, }: DepositModalProps) => react_jsx_runtime_js.JSX.Element;
602
+
603
+ type WithdrawUiStatus = "idle" | "pending" | "success" | "manual_review";
604
+ interface WithdrawModalProps {
605
+ address?: string;
606
+ token?: string;
607
+ tokenSymbol?: string;
608
+ chain?: string;
609
+ amount?: string;
610
+ balance?: string;
611
+ status?: WithdrawUiStatus;
612
+ receiveAmount?: string;
613
+ txHash?: string;
614
+ eta?: string;
615
+ tokenOptions?: SelectOption[];
616
+ chainOptions?: SelectOption[];
617
+ /** 使用 Merchant API:getChains 拉取 token/chain,quote(withdraw) 询价 */
618
+ useMerchantApi?: boolean;
619
+ /** 创建订单后传入,用于轮询提现订单状态 */
620
+ orderId?: string;
621
+ /** 提现模式:direct 直接提现,cross_chain 跨链提现 */
622
+ withdrawMode?: "direct" | "cross_chain";
623
+ /**
624
+ * 直接提现模式(无 orderId)下的结果数据;
625
+ * 将用来构造一个与 getWithdrawOrder 返回值兼容的对象,从而复用“有 orderId”时的全部交互与展示。
626
+ * 最少建议提供:status、dst_token_amount、target_chain_id、target_address(必要时包含 dst_tx_hash / out_tx_hash、fee)。
627
+ */
628
+ withdrawDirectResult?: Partial<WithdrawOrderResponseData>;
629
+ /** 成功页 Fee 展示:优先用订单接口返回的 fee,若后端未返回则用此值(如询价时的 fee),均无则显示 "—" */
630
+ feeDisplay?: string;
631
+ /** 广播后的 funding tx 所在链 id,与 txHash 一起用于展示「查看交易」链接 */
632
+ fundingChainId?: string;
633
+ /** 构建链上交易浏览器链接(已弃用,使用 getExplorerUrl) */
634
+ explorerTxUrl?: (chainId: string, txHash: string) => string;
635
+ onShowToast?: (message: string) => void;
636
+ onAddressChange?: ChangeEventHandler<HTMLInputElement>;
637
+ onTokenSelect?: (id: string) => void;
638
+ onChainSelect?: (id: string) => void;
639
+ onAmountChange?: ChangeEventHandler<HTMLInputElement>;
640
+ onMaxClick?: () => void;
641
+ /** 提交时传入当前表单值(收款地址、金额、所选 token、链上合约地址、所选 chain),由调用方执行提现 */
642
+ onSubmit?: (payload: {
643
+ toAddress: string;
644
+ amount: string;
645
+ token: string;
646
+ tokenAddress: string;
647
+ chain: string;
648
+ }) => void;
649
+ /** 提现订单状态变为 completed 时调用,用于调用方刷新余额等 */
650
+ onWithdrawCompleted?: () => void;
651
+ /** 点击「Start another withdrawal」时调用;应由调用方清空 orderId、重置 amount,恢复到待提交状态(不关弹层)。未传则退化为 onClose。 */
652
+ onStartAnotherWithdrawal?: () => void;
653
+ onSignIn?: () => void;
654
+ onClose?: () => void;
655
+ }
656
+ declare const WithdrawModal: ({ address, token, tokenSymbol, chain, amount, balance, status, receiveAmount: receiveAmountProp, txHash, tokenOptions: tokenOptionsProp, chainOptions: chainOptionsProp, useMerchantApi, orderId, withdrawMode, withdrawDirectResult, feeDisplay, fundingChainId, onShowToast, onAddressChange, onTokenSelect, onChainSelect, onAmountChange, onMaxClick, onSubmit, onWithdrawCompleted, onStartAnotherWithdrawal, onSignIn, onClose, }: WithdrawModalProps) => react_jsx_runtime_js.JSX.Element;
657
+
658
+ interface DepositDetailsPanelProps {
659
+ address: string;
660
+ tokenIcon?: ReactNode;
661
+ minimumDeposit?: string;
662
+ onCopyAddress?: (address: string) => void;
663
+ }
664
+ declare const DepositDetailsPanel: ({ address, tokenIcon, minimumDeposit, onCopyAddress, }: DepositDetailsPanelProps) => react_jsx_runtime_js.JSX.Element;
665
+
666
+ declare function getEnv(key: string): string;
667
+
668
+ declare function getExplorerUrl(chainId: string, data: {
669
+ txId: string;
670
+ }): string;
671
+
672
+ export { type ApiResponse, type ChainData, type ChainInfo, type ChainsResponseData, type CreateOrderRequest, type CreateOrderResponseData, type CustodyAdapter, type DepositAddressResult, type DepositController, DepositDetailsPanel, type DepositDetailsPanelProps, DepositModal, type DepositModalConfig, type DepositModalProps, type DepositOrderResponseData, type DepositOrderStatus, type DepositStatus, DropdownField, type DropdownFieldProps, type Erc20BalanceResult, type FundingTokenBalanceOptions, type FundingWithdrawExecutorOptions, type GoogleCredential, type MarketDataProvider, type ModalController, type NativeSwapPayload, type PaymentPairData, type PaymentSessionResponseData, type PaymentSessionStatus, type PlatformRegisterRequest, type PlatformRegisterResponseData, type PredicateMarketPolicyAdapterOptions, type PredicateSDKConfig, type QuoteDirection, type QuoteRequest$1 as QuoteRequest, type QuoteResponseData, type QuoteResult, type SDKConfig, type SelectOption, SignInModal, type SignInModalProps, type SignInUiConfig, type SocialProvider, type TokenData, type TokenInfo, type TwitterAuthResult, type WalletItem, type WalletOption, WalletSelectionModal, type WalletSelectionModalProps, type WithdrawController, type WithdrawExecutor, WithdrawModal, type WithdrawModalConfig, type WithdrawModalProps, type WithdrawOrderResponseData, type WithdrawOrderStatus, type WithdrawRequest, type WithdrawResult, type WithdrawStatus, type WithdrawUiStatus, clearSocialAccountInstance, configureMerchantApi, createDepositController, createFundingWithdrawExecutor, createMarketDataProvider, createOrder, createPredicateMarketPolicyAdapter, createWithdrawController, fetchErc20Balance, fetchFundingTokenBalance, findTokenDataFromChains, getChains, getDepositOrder, getEnv, getExplorerUrl, getFixedAuthConfig, getMerchantApiClient, getSDKConfig, getWithdrawOrder, initSDK, isFedCMSupported, isUsdtWithdrawDirect, notifyTwitterCallback, parseUnits, quote, registerPlatform, signInWithGoogle, signInWithTwitter, tryAutoReconnect };