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