@coinlist-co/react 0.5.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/{chunk-5E3P7AMH.js → chunk-AAER5LOL.js} +3 -1
  2. package/dist/chunk-AAER5LOL.js.map +1 -0
  3. package/dist/chunk-I5YTJ5SL.js +644 -0
  4. package/dist/chunk-I5YTJ5SL.js.map +1 -0
  5. package/dist/{chunk-N3WBC2VS.js → chunk-MKCOK3DF.js} +68 -57
  6. package/dist/chunk-MKCOK3DF.js.map +1 -0
  7. package/dist/chunk-Z2HAA2TI.js +768 -0
  8. package/dist/chunk-Z2HAA2TI.js.map +1 -0
  9. package/dist/client/index.cjs +3360 -556
  10. package/dist/client/index.cjs.map +1 -1
  11. package/dist/client/index.d.cts +921 -18
  12. package/dist/client/index.d.ts +921 -18
  13. package/dist/client/index.js +2275 -392
  14. package/dist/client/index.js.map +1 -1
  15. package/dist/collections-B84Vw55t.d.cts +28 -0
  16. package/dist/collections-BQbFJS3g.d.ts +28 -0
  17. package/dist/requirement-C2w45Q11.d.cts +969 -0
  18. package/dist/requirement-C2w45Q11.d.ts +969 -0
  19. package/dist/server/index.cjs +521 -37
  20. package/dist/server/index.cjs.map +1 -1
  21. package/dist/server/index.d.cts +116 -9
  22. package/dist/server/index.d.ts +116 -9
  23. package/dist/server/index.js +95 -28
  24. package/dist/server/index.js.map +1 -1
  25. package/dist/shared/index.cjs +1264 -42
  26. package/dist/shared/index.cjs.map +1 -1
  27. package/dist/shared/index.d.cts +644 -3
  28. package/dist/shared/index.d.ts +644 -3
  29. package/dist/shared/index.js +220 -5
  30. package/dist/shared/index.js.map +1 -1
  31. package/package.json +33 -30
  32. package/dist/chunk-5E3P7AMH.js.map +0 -1
  33. package/dist/chunk-CRACFEJ4.js +0 -17
  34. package/dist/chunk-CRACFEJ4.js.map +0 -1
  35. package/dist/chunk-N3WBC2VS.js.map +0 -1
  36. package/dist/chunk-V6WO67RO.js +0 -311
  37. package/dist/chunk-V6WO67RO.js.map +0 -1
  38. package/dist/client/styles.css +0 -2
  39. package/dist/requirement-BEO42QOr.d.cts +0 -387
  40. package/dist/requirement-BEO42QOr.d.ts +0 -387
@@ -0,0 +1,969 @@
1
+ import { Hex } from 'viem';
2
+
3
+ declare const __brand: unique symbol;
4
+ type Newtype<Base, Branding> = Base & {
5
+ readonly [__brand]: Branding;
6
+ };
7
+
8
+ type EthereumChain = 'ethereum_mainnet' | 'ethereum_sepolia';
9
+ /**
10
+ * Protocol a wallet binding is scoped to. EVM-only for now: an EVM address
11
+ * binds once per option regardless of which EVM chain proved ownership.
12
+ * Frontline's enum also has `:solana`, but we don't handle Solana bindings yet,
13
+ * so this stays `'ethereum'` until Solana support lands.
14
+ */
15
+ type WalletProtocol = 'ethereum';
16
+ /**
17
+ * EVM addresses keep a `0x${string}` base so they stay assignable to the
18
+ * `0x${string}` shapes that on-chain libraries (viem/wagmi) expect. We only
19
+ * drop the runtime `0x` narrowing: values are trusted at the boundary and
20
+ * branded via the constructor.
21
+ */
22
+ type EvmWalletAddress = Newtype<`0x${string}`, 'EvmWalletAddress'>;
23
+ declare const EvmWalletAddress: (value: string) => EvmWalletAddress;
24
+ type EvmContractAddress = Newtype<`0x${string}`, 'EvmContractAddress'>;
25
+ declare const EvmContractAddress: (value: string) => EvmContractAddress;
26
+ type HexEncodedTransactionData = Newtype<`0x${string}`, 'HexEncodedTransactionData'>;
27
+ declare const HexEncodedTransactionData: (value: string) => HexEncodedTransactionData;
28
+ type AssetDecimals = Newtype<number, 'AssetDecimals'>;
29
+ declare const AssetDecimals: (value: number) => AssetDecimals;
30
+ declare const MAX_UINT_256: bigint;
31
+ /**
32
+ * A non-negative integer within uint256 bounds. Kept unbranded (a plain
33
+ * `bigint`) so raw on-chain amounts flow in without ceremony; bounds are
34
+ * enforced where it matters (see {@link combineAmounts}).
35
+ */
36
+ type Uint256 = bigint;
37
+ /**
38
+ * Asserts a raw bigint falls within uint256 bounds, throwing otherwise. Use at
39
+ * on-chain arithmetic boundaries (bps math, price computation) where a computed
40
+ * value could underflow below zero or overflow above 2^256-1.
41
+ */
42
+ declare const assertUint256: (value: bigint) => Uint256;
43
+ type BlockchainAmount = Newtype<{
44
+ raw: Uint256;
45
+ decimals: AssetDecimals;
46
+ }, 'BlockchainAmount'>;
47
+ /**
48
+ * Constructs a {@link BlockchainAmount} and exposes arithmetic helpers.
49
+ * TypeScript has no operator overloading, so use `BlockchainAmount.add(a, b)`
50
+ * instead of `+`/`-` on the objects directly.
51
+ */
52
+ declare const BlockchainAmount: ((value: {
53
+ raw: Uint256;
54
+ decimals: AssetDecimals;
55
+ }) => BlockchainAmount) & {
56
+ add: (a: BlockchainAmount, b: BlockchainAmount) => BlockchainAmount;
57
+ sub: (a: BlockchainAmount, b: BlockchainAmount) => BlockchainAmount;
58
+ };
59
+ type AssetSymbol = Newtype<string, 'AssetSymbol'>;
60
+ declare const AssetSymbol: (value: string) => AssetSymbol;
61
+ /**
62
+ * A stablecoin symbol is an {@link AssetSymbol} narrowed to the coins we
63
+ * support. It shares the `AssetSymbol` brand so it stays assignable to it.
64
+ */
65
+ type StablecoinSymbol = Newtype<'USDC' | 'USDT', 'AssetSymbol'>;
66
+ declare const StablecoinSymbol: (value: "USDC" | "USDT") => StablecoinSymbol;
67
+ type KnownAssetSymbol = StablecoinSymbol;
68
+ declare const KnownAssetSymbol: (value: "USDC" | "USDT") => StablecoinSymbol;
69
+ type Erc20Asset = {
70
+ name: string;
71
+ symbol: AssetSymbol;
72
+ decimals: AssetDecimals;
73
+ };
74
+ type Bps = Newtype<bigint, 'Bps'>;
75
+ declare const Bps: (value: bigint) => Bps;
76
+
77
+ /**
78
+ * Raw JSON models for the on-chain swap endpoints. uint256 values are encoded
79
+ * as decimal strings because they can exceed the safe integer range of JSON
80
+ * consumers.
81
+ */
82
+ type WalletAuthorizationDto = {
83
+ object: 'wallet_authorization';
84
+ authorized: boolean;
85
+ };
86
+ type SwapPreviewDto = {
87
+ object: 'swap_preview';
88
+ pay_input_amount: string;
89
+ fee: string;
90
+ receive_output_amount: string;
91
+ };
92
+ type SwapStatusDto = {
93
+ object: 'swap_status';
94
+ stopped: string;
95
+ swap_level: string;
96
+ };
97
+ type TokenAllowanceDto = {
98
+ object: 'token_allowance';
99
+ allowance: string;
100
+ };
101
+ type TokenBalanceDto = {
102
+ object: 'token_balance';
103
+ balance: string;
104
+ };
105
+ type AllowWalletResponseDto = {
106
+ action: 'broadcast_transaction';
107
+ to: string;
108
+ data: string;
109
+ } | {
110
+ action: 'none';
111
+ already_allowed: boolean;
112
+ };
113
+
114
+ /**
115
+ * Whether a wallet is authorized to interact with a given swap contract.
116
+ */
117
+ type SwapAuthorization = {
118
+ authorized: boolean;
119
+ };
120
+ declare const SwapAuthorization: {
121
+ fromDto: (dto: WalletAuthorizationDto) => SwapAuthorization;
122
+ };
123
+ /**
124
+ * A read-only quote for a swap: how much goes in, the protocol fee, and how
125
+ * much would come out. All amounts are raw on-chain integers (uint256).
126
+ */
127
+ type SwapPreview = {
128
+ inputAmount: Uint256;
129
+ fee: Uint256;
130
+ outputAmount: Uint256;
131
+ };
132
+ declare const SwapPreview: {
133
+ fromDto: (dto: SwapPreviewDto) => SwapPreview;
134
+ };
135
+ /**
136
+ * The on-chain state of a swap contract.
137
+ *
138
+ * - `stopped`: non-zero when the contract is paused/halted.
139
+ * - `swapLevel`: the current swap level/tier.
140
+ */
141
+ type SwapStatus = {
142
+ stopped: Uint256;
143
+ swapLevel: Uint256;
144
+ };
145
+ declare const SwapStatus: {
146
+ fromDto: (dto: SwapStatusDto) => SwapStatus;
147
+ };
148
+ /**
149
+ * The ERC-20 allowance an owner has granted a spender for a token.
150
+ */
151
+ type TokenAllowance = {
152
+ allowance: Uint256;
153
+ };
154
+ declare const TokenAllowance: {
155
+ fromDto: (dto: TokenAllowanceDto) => TokenAllowance;
156
+ };
157
+ /**
158
+ * The raw ERC-20 balance an owner holds of a token (uint256).
159
+ */
160
+ type TokenBalance = {
161
+ balance: Uint256;
162
+ };
163
+ declare const TokenBalance: {
164
+ fromDto: (dto: TokenBalanceDto) => TokenBalance;
165
+ };
166
+ /**
167
+ * The backend's response to an allow-wallet request. Either the caller must
168
+ * broadcast an on-chain transaction to complete allow-listing, or nothing is
169
+ * required because the wallet is already allowed.
170
+ */
171
+ type AllowWalletResponse = {
172
+ action: 'broadcast_transaction';
173
+ to: EvmContractAddress;
174
+ data: HexEncodedTransactionData;
175
+ } | {
176
+ action: 'none';
177
+ alreadyAllowed: boolean;
178
+ };
179
+ declare const AllowWalletResponse: {
180
+ fromDto: (dto: AllowWalletResponseDto) => AllowWalletResponse;
181
+ };
182
+
183
+ /**
184
+ * OAuth 2.0 token response (RFC 6749 §5.1).
185
+ * Maps to OpenAPI schema OauthToken.
186
+ */
187
+ type OAuthSessionDto = {
188
+ access_token: string;
189
+ expires_in: number;
190
+ refresh_token?: string;
191
+ };
192
+
193
+ type ClientCredentialsOAuth = Newtype<OAuthAccessToken, 'ClientCredentialsOAuth'>;
194
+ declare const ClientCredentialsOAuth: (value: OAuthAccessToken) => ClientCredentialsOAuth;
195
+ type OAuthAccessToken = {
196
+ value: string;
197
+ expiresAt: Date;
198
+ };
199
+ type OAuthRefreshToken = Newtype<string, 'OAuthRefreshToken'>;
200
+ declare const OAuthRefreshToken: (value: string) => OAuthRefreshToken;
201
+ type OAuthSession = {
202
+ accessToken: OAuthAccessToken;
203
+ refreshToken?: OAuthRefreshToken;
204
+ };
205
+ declare const OAuthSession: {
206
+ fromDto: (dto: OAuthSessionDto) => OAuthSession;
207
+ };
208
+
209
+ type HttpRequestAttributes = {
210
+ protected?: boolean;
211
+ userAgent?: boolean;
212
+ idempotencyKey?: boolean;
213
+ /** Zero-based attempt index: 0 = first request, 1 = first retry, etc. */
214
+ retryAttempt?: number;
215
+ renewAttempted?: boolean;
216
+ clientCredentials?: ClientCredentialsOAuth;
217
+ };
218
+
219
+ type QueryParamValue = string | number | boolean | null | undefined;
220
+ type QueryParamValues = QueryParamValue | QueryParamValue[];
221
+ type HttpRequest<TBody = unknown> = {
222
+ method: 'GET';
223
+ url: string;
224
+ queryParams?: Record<string, QueryParamValues>;
225
+ headers?: Record<string, string>;
226
+ attributes?: HttpRequestAttributes;
227
+ redirect?: RequestRedirect;
228
+ } | {
229
+ method: 'POST';
230
+ url: string;
231
+ queryParams?: Record<string, QueryParamValues>;
232
+ headers?: Record<string, string>;
233
+ body: TBody;
234
+ attributes?: HttpRequestAttributes;
235
+ redirect?: RequestRedirect;
236
+ } | {
237
+ method: 'DELETE';
238
+ url: string;
239
+ queryParams?: Record<string, QueryParamValues>;
240
+ headers?: Record<string, string>;
241
+ attributes?: HttpRequestAttributes;
242
+ redirect?: RequestRedirect;
243
+ };
244
+
245
+ /**
246
+ * Structural interface satisfied by both {@link AuthenticatedApiClient} and
247
+ * {@link ApiClient}. Used by the shared frontline API functions so they can
248
+ * be called from either the client or server without any browser dependencies.
249
+ */
250
+ interface Sender {
251
+ send<T>(request: HttpRequest): Promise<T>;
252
+ }
253
+
254
+ interface SharedNamespaceContext {
255
+ readonly api: Sender;
256
+ ensureUserAuthenticated(): Promise<void>;
257
+ }
258
+
259
+ type OfferDto = {
260
+ id: string;
261
+ slug: string;
262
+ tagline: string | null | undefined;
263
+ banner_url: string | null | undefined;
264
+ logo_url: string | null | undefined;
265
+ starts_at: string;
266
+ ends_at: string;
267
+ };
268
+
269
+ type OfferId = Newtype<string, 'OfferId'>;
270
+ declare const OfferId: (value: string) => OfferId;
271
+ type OfferSlug = Newtype<string, 'OfferSlug'>;
272
+ declare const OfferSlug: (value: string) => OfferSlug;
273
+ type Offer = {
274
+ id: OfferId;
275
+ slug: OfferSlug;
276
+ tagline: string | null;
277
+ bannerUrl: string | null;
278
+ logoUrl: string | null;
279
+ startsAt: Date;
280
+ endsAt: Date;
281
+ };
282
+ declare const Offer: {
283
+ fromDto: (dto: OfferDto) => Offer;
284
+ };
285
+
286
+ /** Challenge kinds accepted by `POST /v1/wallet-ownership`. */
287
+ type WalletOwnershipChallengeTypeDto = 'plain' | 'siwe';
288
+ /**
289
+ * Request body for `POST /v1/wallet-ownership`. `challenge_type` defaults to
290
+ * `plain` on the backend; the SIWE fields (`domain`, `uri`, `statement`) are
291
+ * required only when `challenge_type` is `siwe` and must be absent otherwise.
292
+ */
293
+ type CreateWalletOwnershipChallengeDto = {
294
+ wallet_address: string;
295
+ chain: string;
296
+ challenge_type?: WalletOwnershipChallengeTypeDto;
297
+ domain?: string;
298
+ uri?: string;
299
+ statement?: string;
300
+ };
301
+ /** Response body for `POST /v1/wallet-ownership`. */
302
+ type WalletOwnershipChallengeDto = {
303
+ message: string;
304
+ expires_at: string;
305
+ };
306
+
307
+ /** Fields common to every wallet-ownership challenge request. */
308
+ type WalletOwnershipChallengeParamsBase = {
309
+ /** Wallet address to prove ownership of. */
310
+ walletAddress: EvmWalletAddress;
311
+ /** Chain the wallet belongs to. */
312
+ chain: EthereumChain;
313
+ };
314
+ /**
315
+ * How the ownership challenge is framed: a plain message or a Sign-In With
316
+ * Ethereum challenge. Extracted as its own type so SDK consumers can pass it as
317
+ * a standalone param without reaching into the {@link CreateWalletOwnershipChallengeParams}
318
+ * union.
319
+ */
320
+ type WalletChallengeType = CreateWalletOwnershipChallengeParams['challengeType'];
321
+ /**
322
+ * A single-use ownership challenge returned by `POST /v1/wallet-ownership`.
323
+ * The consumer signs {@link message} with their wallet, then submits the
324
+ * signature to connect the wallet to an offer option.
325
+ */
326
+ type WalletOwnershipChallenge = {
327
+ /** The message the wallet must sign. */
328
+ message: string;
329
+ /** When the challenge expires and can no longer be consumed. */
330
+ expiresAt: Date;
331
+ };
332
+ declare const WalletOwnershipChallenge: {
333
+ /** Maps the API DTO into the SDK wallet-ownership-challenge domain model. */
334
+ fromDto: (dto: WalletOwnershipChallengeDto) => WalletOwnershipChallenge;
335
+ };
336
+ /**
337
+ * Parameters for requesting a wallet-ownership challenge. Modeled as a
338
+ * discriminated union on `challengeType` so a `siwe` challenge must carry
339
+ * `domain`/`uri`/`statement`, matching the backend contract at compile time.
340
+ */
341
+ type CreateWalletOwnershipChallengeParams = (WalletOwnershipChallengeParamsBase & {
342
+ /** A bare message the wallet signs. */
343
+ challengeType: 'plain';
344
+ }) | (WalletOwnershipChallengeParamsBase & {
345
+ /** Marks this as a Sign-In With Ethereum challenge. */
346
+ challengeType: 'siwe';
347
+ /** The requesting site's hostname (e.g. `example.com`). */
348
+ domain: string;
349
+ /** The requesting site's URI. */
350
+ uri: string;
351
+ /** Human-readable statement shown in the signing prompt. */
352
+ statement: string;
353
+ });
354
+ declare const CreateWalletOwnershipChallengeParams: {
355
+ /**
356
+ * Maps challenge-request params into the API DTO payload. The discriminated
357
+ * union guarantees SIWE fields are present exactly when `challengeType` is
358
+ * `siwe`, so the mapping narrows on the discriminant.
359
+ */
360
+ toDto: (params: CreateWalletOwnershipChallengeParams) => CreateWalletOwnershipChallengeDto;
361
+ };
362
+
363
+ /** Parameters shared by contract reads scoped to a chain. */
364
+ type SwapContractRef = {
365
+ contractAddress: EvmContractAddress;
366
+ chain: EthereumChain;
367
+ };
368
+ type GetSwapAuthorizationParams = SwapContractRef & {
369
+ walletAddress: EvmWalletAddress;
370
+ };
371
+ type GetSwapPreviewParams = SwapContractRef & {
372
+ inputToken: EvmContractAddress;
373
+ amount: bigint;
374
+ };
375
+ type GetTokenAllowanceParams = {
376
+ tokenAddress: EvmContractAddress;
377
+ owner: EvmWalletAddress;
378
+ spender: EvmContractAddress;
379
+ chain: EthereumChain;
380
+ };
381
+ type GetTokenBalanceParams = {
382
+ tokenAddress: EvmContractAddress;
383
+ owner: EvmWalletAddress;
384
+ chain: EthereumChain;
385
+ };
386
+ type AllowWalletParams = {
387
+ offerId: OfferId;
388
+ walletAddress: EvmWalletAddress;
389
+ chain: EthereumChain;
390
+ signature: string;
391
+ };
392
+ /**
393
+ * Read/write operations for the on-chain swap flow: quoting a swap, inspecting
394
+ * contract state, checking token allowances, and proving/allow-listing wallet
395
+ * ownership.
396
+ */
397
+ interface CoinListSwapNamespace {
398
+ /**
399
+ * Checks whether a wallet is authorized to swap against the given contract.
400
+ */
401
+ getAuthorization(params: GetSwapAuthorizationParams): Promise<SwapAuthorization>;
402
+ /**
403
+ * Fetches a read-only quote for swapping `amount` of `inputToken`.
404
+ */
405
+ getPreview(params: GetSwapPreviewParams): Promise<SwapPreview>;
406
+ /**
407
+ * Reads the current on-chain state of a swap contract.
408
+ */
409
+ getStatus(params: SwapContractRef): Promise<SwapStatus>;
410
+ /**
411
+ * Reads the ERC-20 allowance an `owner` has granted a `spender`.
412
+ */
413
+ getTokenAllowance(params: GetTokenAllowanceParams): Promise<TokenAllowance>;
414
+ /**
415
+ * Reads the raw ERC-20 balance an `owner` holds of a token.
416
+ */
417
+ getTokenBalance(params: GetTokenBalanceParams): Promise<TokenBalance>;
418
+ /**
419
+ * Reads the ERC-20 output token a swap contract pays out.
420
+ */
421
+ getOutputToken(params: SwapContractRef): Promise<Erc20Asset>;
422
+ /**
423
+ * Requests a single-use challenge the user must sign to prove wallet
424
+ * ownership, via `POST /v1/wallet-ownership`. Supports both `plain` and
425
+ * `siwe` challenges. This is the same operation as the top-level
426
+ * `createWalletOwnershipChallenge`, scoped under the swap namespace for the
427
+ * allow-wallet flow.
428
+ */
429
+ requestWalletOwnershipChallenge(params: CreateWalletOwnershipChallengeParams): Promise<WalletOwnershipChallenge>;
430
+ /**
431
+ * Submits a signed wallet-ownership challenge to allow-list the wallet for
432
+ * an offer, identified by its offer id.
433
+ */
434
+ allowWallet(params: AllowWalletParams): Promise<AllowWalletResponse>;
435
+ }
436
+ declare class SwapNamespaceImpl implements CoinListSwapNamespace {
437
+ private readonly ctx;
438
+ constructor(ctx: SharedNamespaceContext);
439
+ getAuthorization(params: GetSwapAuthorizationParams): Promise<SwapAuthorization>;
440
+ getPreview(params: GetSwapPreviewParams): Promise<SwapPreview>;
441
+ getStatus(params: SwapContractRef): Promise<SwapStatus>;
442
+ getTokenAllowance(params: GetTokenAllowanceParams): Promise<TokenAllowance>;
443
+ getTokenBalance(params: GetTokenBalanceParams): Promise<TokenBalance>;
444
+ getOutputToken(params: SwapContractRef): Promise<Erc20Asset>;
445
+ requestWalletOwnershipChallenge(params: CreateWalletOwnershipChallengeParams): Promise<WalletOwnershipChallenge>;
446
+ allowWallet(params: AllowWalletParams): Promise<AllowWalletResponse>;
447
+ }
448
+
449
+ type AuthorizationCode = Newtype<string, 'AuthorizationCode'>;
450
+ declare const AuthorizationCode: (value: string) => AuthorizationCode;
451
+ type CodeVerifier = Newtype<string, 'CodeVerifier'>;
452
+ declare const CodeVerifier: (value: string) => CodeVerifier;
453
+ type CodeChallenge = Newtype<string, 'CodeChallenge'>;
454
+ declare const CodeChallenge: (value: string) => CodeChallenge;
455
+ type PKCEState = Newtype<string, 'PKCEState'>;
456
+ declare const PKCEState: (value: string) => PKCEState;
457
+ type RedirectUri = Newtype<string, 'RedirectUri'>;
458
+ declare const RedirectUri: (value: string) => RedirectUri;
459
+ type ClientId = Newtype<string, 'ClientId'>;
460
+ declare const ClientId: (value: string) => ClientId;
461
+ type ClientSecret = Newtype<string, 'ClientSecret'>;
462
+ declare const ClientSecret: (value: string) => ClientSecret;
463
+
464
+ type Cursor = Newtype<string, 'Cursor'>;
465
+ declare const Cursor: (value: string) => Cursor;
466
+ interface PaginatedResponseDto<T> {
467
+ data: T[];
468
+ starting_after?: string;
469
+ starting_before?: string;
470
+ }
471
+ declare function fetchAllPages<A, P extends PaginationParams = PaginationParams>(fetchPage: (params: P) => Promise<PaginatedResponse<A>>, baseParams?: Omit<P, keyof PaginationParams>): Promise<A[]>;
472
+ interface PaginatedResponse<T> {
473
+ data: T[];
474
+ startingAfter: Cursor | null;
475
+ startingBefore: Cursor | null;
476
+ }
477
+ declare const PaginatedResponse: {
478
+ fromDto: <A, B>(dto: PaginatedResponseDto<A>, itemMapper: (item: A) => B) => PaginatedResponse<B>;
479
+ };
480
+ /**
481
+ * Cursor-based pagination input used when requesting paginated API resources.
482
+ * Set `after` or `before` to navigate relative to a known cursor, and `limit`
483
+ * to control the maximum number of returned items.
484
+ */
485
+ interface PaginationParams {
486
+ before?: Cursor;
487
+ after?: Cursor;
488
+ limit?: number;
489
+ }
490
+ declare const PaginationParams: {
491
+ toQueryParams: (params: PaginationParams) => Record<string, QueryParamValue>;
492
+ };
493
+
494
+ interface Config {
495
+ /** OAuth2 public identifier. */
496
+ readonly clientId: ClientId;
497
+ /**
498
+ * OAuth2 redirect URI. Recommended to point to a frontend page where
499
+ * {@link CoinListClient#completeOauth} can be called to complete the PKCE
500
+ * flow on the client side.
501
+ */
502
+ readonly redirectUri: RedirectUri;
503
+ /**
504
+ * Recommended to leave undefined. Used to change the CoinList environment;
505
+ * default is production.
506
+ */
507
+ readonly baseUrl?: string;
508
+ }
509
+
510
+ type DocumentSubmissionStatusDto = 'INITIALIZED' | 'SENT' | 'VIEWED' | 'COMPLETED' | 'DECLINED' | 'EXPIRED';
511
+ type DocumentFormTypeDto = 'w8_ben' | 'w8_ben_e';
512
+ type DocumentSubmissionDto = {
513
+ object: 'document_submission';
514
+ status: DocumentSubmissionStatusDto;
515
+ form_type: DocumentFormTypeDto;
516
+ };
517
+
518
+ /** Document types that can be signed via {@link CoinListClient.submitDocument}. */
519
+ type DocumentType = 'tax_certification';
520
+ /** Signing-state machine status for a document submission. */
521
+ type DocumentSubmissionStatus = DocumentSubmissionStatusDto;
522
+ /** The tax form derived from the entity's kind (individual vs company/trust). */
523
+ type DocumentFormType = DocumentFormTypeDto;
524
+ /** Result of starting (or resuming) a document signing submission. */
525
+ type DocumentSubmission = {
526
+ status: DocumentSubmissionStatus;
527
+ formType: DocumentFormType;
528
+ };
529
+ declare const DocumentSubmission: {
530
+ fromDto: (dto: DocumentSubmissionDto) => DocumentSubmission;
531
+ };
532
+
533
+ type KycTokenDto = {
534
+ object: 'kyc_token';
535
+ token: string;
536
+ };
537
+
538
+ /**
539
+ * Sumsub verification level name. Determines which screens the Sumsub WebSDK
540
+ * shows (levels are configured in the Sumsub dashboard). The backend
541
+ * prescribes the level (and whether the applicant must be reset first) in the
542
+ * requirement statuses response — clients never compute levels themselves.
543
+ */
544
+ type KycLevelName = string;
545
+ /** Short-lived Sumsub WebSDK access token scoped to the current user. */
546
+ type KycToken = {
547
+ token: string;
548
+ };
549
+ declare const KycToken: {
550
+ fromDto: (dto: KycTokenDto) => KycToken;
551
+ };
552
+
553
+ type AssetDto = {
554
+ code: string;
555
+ fractional_digits: number;
556
+ id: string;
557
+ name: string;
558
+ };
559
+
560
+ type AssetId = Newtype<string, 'AssetId'>;
561
+ declare const AssetId: (value: string) => AssetId;
562
+ type AssetCode = Newtype<string, 'AssetCode'>;
563
+ declare const AssetCode: (value: string) => AssetCode;
564
+ type Asset = {
565
+ id: AssetId;
566
+ code: AssetCode;
567
+ name: string;
568
+ fractionalDigits: number;
569
+ };
570
+ declare const Asset: {
571
+ fromDto: (dto: AssetDto) => Asset;
572
+ };
573
+
574
+ type OfferDetailDto = {
575
+ asset: AssetDto;
576
+ faqs: OfferDetailFaqDto[];
577
+ funding_assets: AssetDto[];
578
+ id: string;
579
+ links: OfferDetailLinkDto[];
580
+ milestones: OfferDetailMilestoneDto[];
581
+ name: string;
582
+ object: 'offer_details';
583
+ options: OfferDetailOptionDto[];
584
+ slug: string;
585
+ terms: OfferDetailTermDto[];
586
+ about: string | null | undefined;
587
+ banner_url: string | null | undefined;
588
+ category: string | null | undefined;
589
+ ends_at: string;
590
+ logo_url: string | null | undefined;
591
+ starts_at: string;
592
+ tagline: string | null | undefined;
593
+ };
594
+ type OfferDetailFaqDto = {
595
+ answer: string | null;
596
+ question: string | null;
597
+ };
598
+ type OfferDetailLinkDto = {
599
+ label: string | null;
600
+ url: string | null;
601
+ };
602
+ type OfferDetailMilestoneDto = {
603
+ name: string | null;
604
+ schedule: string | null;
605
+ status: 'completed' | 'active' | 'upcoming';
606
+ };
607
+ type OfferDetailOptionDto = {
608
+ bid_increment: number | null;
609
+ floor_price_usd: number | null;
610
+ id: string;
611
+ minimum_purchase_usd: number | null;
612
+ price_usd: string | null;
613
+ sale_agreement_url: string | null;
614
+ slug: string;
615
+ total_token_supply: number | null;
616
+ };
617
+ type OfferDetailTermDto = {
618
+ key: string | null;
619
+ value: string | null;
620
+ };
621
+
622
+ type OfferOptionId = Newtype<string, 'OfferOptionId'>;
623
+ declare const OfferOptionId: (value: string) => OfferOptionId;
624
+ type OfferOptionSlug = Newtype<string, 'OfferOptionSlug'>;
625
+ declare const OfferOptionSlug: (value: string) => OfferOptionSlug;
626
+ type OfferDetail = {
627
+ id: OfferId;
628
+ slug: OfferSlug;
629
+ name: string;
630
+ asset: Asset;
631
+ fundingAssets: Asset[];
632
+ about: string | null;
633
+ tagline: string | null;
634
+ bannerUrl: string | null;
635
+ logoUrl: string | null;
636
+ category: string | null;
637
+ startsAt: Date;
638
+ endsAt: Date;
639
+ faqs: FaqItem[];
640
+ links: Link[];
641
+ milestones: Milestone[];
642
+ options: OfferOption[];
643
+ terms: TermItem[];
644
+ };
645
+ declare const OfferDetail: {
646
+ fromDto: (dto: OfferDetailDto) => OfferDetail;
647
+ };
648
+ type OfferOption = {
649
+ id: OfferOptionId;
650
+ slug: OfferOptionSlug;
651
+ bidIncrement: number | null;
652
+ floorPriceUsd: number | null;
653
+ minimumPurchaseUsd: number | null;
654
+ priceUsd: string | null;
655
+ saleAgreementUrl: string | null;
656
+ totalTokenSupply: number | null;
657
+ };
658
+ declare const OfferOption: {
659
+ fromDto: (dto: OfferDetailOptionDto) => OfferOption;
660
+ };
661
+ type FaqItem = {
662
+ question: string | null;
663
+ answer: string | null;
664
+ };
665
+ declare const FaqItem: {
666
+ fromDto: (dto: OfferDetailFaqDto) => FaqItem;
667
+ };
668
+ type Link = {
669
+ label: string | null;
670
+ url: string | null;
671
+ };
672
+ declare const Link: {
673
+ fromDto: (dto: OfferDetailLinkDto) => Link;
674
+ };
675
+ type TermItem = {
676
+ key: string | null;
677
+ value: string | null;
678
+ };
679
+ declare const TermItem: {
680
+ fromDto: (dto: OfferDetailTermDto) => TermItem;
681
+ };
682
+ type Milestone = {
683
+ name: string | null;
684
+ schedule: string | null;
685
+ status: 'completed' | 'active' | 'upcoming';
686
+ };
687
+ declare const Milestone: {
688
+ fromDto: (dto: OfferDetailMilestoneDto) => Milestone;
689
+ };
690
+
691
+ /** Request body for `POST /v1/offers/:offer_id/addresses`. */
692
+ type CreateOfferOptionAddressDto = {
693
+ offer_option_id: string;
694
+ wallet_address: string;
695
+ chain: string;
696
+ signature: string;
697
+ };
698
+ /** Binding object returned by the `/v1/offers/:offer_id/addresses` resource. */
699
+ type OfferOptionAddressDto = {
700
+ id: string;
701
+ offer_option_id: string;
702
+ address: string;
703
+ protocol: WalletProtocol;
704
+ created_at: string;
705
+ };
706
+
707
+ /** Unique identifier for a proven wallet binding on an offer option. */
708
+ type OfferOptionAddressId = Newtype<string, 'OfferOptionAddressId'>;
709
+ /** Casts a string into a typed {@link OfferOptionAddressId}. */
710
+ declare const OfferOptionAddressId: (value: string) => OfferOptionAddressId;
711
+ /**
712
+ * A user's external wallet, proven via a wallet-ownership challenge and bound
713
+ * to an offer option. Returned by the `/v1/offers/:offer_id/addresses` resource.
714
+ */
715
+ type OfferOptionAddress = {
716
+ /** Unique binding id. */
717
+ id: OfferOptionAddressId;
718
+ /** Offer option the wallet is bound to. */
719
+ offerOptionId: OfferOptionId;
720
+ /** The connected external wallet address. */
721
+ address: EvmWalletAddress;
722
+ /**
723
+ * Protocol the binding is scoped to. An EVM address binds once per option
724
+ * regardless of which EVM chain proved ownership.
725
+ */
726
+ protocol: WalletProtocol;
727
+ /** When the binding was created. */
728
+ createdAt: Date;
729
+ };
730
+ declare const OfferOptionAddress: {
731
+ /** Maps the API DTO into the SDK offer-option-address domain model. */
732
+ fromDto: (dto: OfferOptionAddressDto) => OfferOptionAddress;
733
+ };
734
+ /** Parameters required to connect a proven external wallet to an offer option. */
735
+ type ConnectExternalWalletParams = {
736
+ /** Offer option to bind the wallet to. */
737
+ offerOptionId: OfferOptionId;
738
+ /** External wallet address that was proven. */
739
+ walletAddress: EvmWalletAddress;
740
+ /** Chain the ownership was proven on. */
741
+ chain: EthereumChain;
742
+ /** Signature of the wallet-ownership challenge message. */
743
+ signature: Hex;
744
+ };
745
+ declare const ConnectExternalWalletParams: {
746
+ /** Maps connect-wallet params into the API DTO payload. */
747
+ toDto: (params: ConnectExternalWalletParams) => CreateOfferOptionAddressDto;
748
+ };
749
+
750
+ type ParticipationStatusDto = 'prepared' | 'pending' | 'submitted' | 'completed' | 'failed' | 'remit_submitted' | 'remitted' | 'remit_failed';
751
+ type ParticipationDto = {
752
+ object: 'participation';
753
+ id: string;
754
+ offer_id: string;
755
+ offer_option_id: string;
756
+ status: ParticipationStatusDto;
757
+ amount: string;
758
+ amount_string: string;
759
+ asset: AssetDto;
760
+ chain: string;
761
+ inserted_at: string | null | undefined;
762
+ updated_at: string | null | undefined;
763
+ wallet_address: string | null | undefined;
764
+ };
765
+ type CreateParticipationDto = {
766
+ offer_id: string;
767
+ offer_option_id: string;
768
+ chain: string;
769
+ wallet_address: string;
770
+ amount: string;
771
+ asset_id: string;
772
+ approval_transaction_hash: string | null | undefined;
773
+ };
774
+
775
+ /** Unique identifier for a participation. */
776
+ type ParticipationId = Newtype<string, 'ParticipationId'>;
777
+ /** Casts a string into a typed {@link ParticipationId}. */
778
+ declare const ParticipationId: (value: string) => ParticipationId;
779
+ /** Blockchain identifier for where a participation is funded. */
780
+ type Blockchain = Newtype<string, 'Blockchain'>;
781
+ /** Casts a string into a typed {@link Blockchain}. */
782
+ declare const Blockchain: (value: string) => Blockchain;
783
+ /** Wallet address used for a participation. */
784
+ type WalletAddress = Newtype<`0x${string}`, 'WalletAddress'>;
785
+ /** Casts a `0x`-prefixed string into a typed {@link WalletAddress}. */
786
+ declare const WalletAddress: (value: `0x${string}`) => WalletAddress;
787
+ /** Possible participation lifecycle states returned by the API. */
788
+ type ParticipationStatus = ParticipationStatusDto;
789
+ /** Pagination params for listing participations, with an optional offer filter. */
790
+ interface ParticipationsPaginationParams extends PaginationParams {
791
+ offerId?: OfferId;
792
+ }
793
+ declare const ParticipationsPaginationParams: {
794
+ toQueryParams: (params: ParticipationsPaginationParams) => Record<string, QueryParamValue>;
795
+ };
796
+ /** Domain model for a participation returned by CoinList APIs. */
797
+ type Participation = {
798
+ /** Unique participation id. */
799
+ id: ParticipationId;
800
+ /** Parent offer id. */
801
+ offerId: OfferId;
802
+ /** Selected offer option id. */
803
+ offerOptionId: OfferOptionId;
804
+ /** Current processing status. */
805
+ status: ParticipationStatus;
806
+ /** Raw participation amount from API. */
807
+ amount: string;
808
+ /** Human-readable formatted amount from API. */
809
+ displayAmount: string;
810
+ /** Asset metadata for the participation amount. */
811
+ asset: Asset;
812
+ /** Funding chain identifier. */
813
+ chain: Blockchain;
814
+ /** Creation timestamp, if returned by API. */
815
+ insertedAt: Date | null;
816
+ /** Last update timestamp, if returned by API. */
817
+ updatedAt: Date | null;
818
+ /** Wallet used for participation, blank values normalized to null. */
819
+ walletAddress: WalletAddress | null;
820
+ };
821
+ declare const Participation: {
822
+ /** Maps API DTO shape into the SDK participation domain model. */
823
+ fromDto: (dto: ParticipationDto) => Participation;
824
+ };
825
+ /** Parameters required to create a new participation. */
826
+ type CreateParticipationParams = {
827
+ /** Offer to participate in. */
828
+ offerId: OfferId;
829
+ /** Offer option selected for participation. */
830
+ offerOptionId: OfferOptionId;
831
+ /** Blockchain for funding. */
832
+ chain: Blockchain;
833
+ /** Wallet address that funds the participation. */
834
+ walletAddress: WalletAddress;
835
+ /** Raw amount to participate with. */
836
+ amount: string;
837
+ /** Funding asset id. */
838
+ assetId: AssetId;
839
+ /** Approval transaction hash of allowance transaction. */
840
+ approvalTransactionHash: string;
841
+ };
842
+ declare const CreateParticipationParams: {
843
+ /** Maps participation creation params into API DTO payload. */
844
+ toDto: (params: CreateParticipationParams) => CreateParticipationDto;
845
+ };
846
+
847
+ type PiiKindDto = 'person' | 'company';
848
+ type PiiJurisdictionDto = {
849
+ iso_2: string;
850
+ name: string | null;
851
+ };
852
+ type PiiAddressDto = {
853
+ street: string | null;
854
+ city: string | null;
855
+ state: string | null;
856
+ postal_code: string | null;
857
+ country: string | null;
858
+ };
859
+ type PiiDto = {
860
+ object: 'user_pii';
861
+ kind: PiiKindDto;
862
+ full_legal_name: string | null;
863
+ date_of_birth: string | null;
864
+ jurisdiction: PiiJurisdictionDto | null;
865
+ tax_id: string | null;
866
+ permanent_address: PiiAddressDto;
867
+ };
868
+
869
+ /** Whether the PII belongs to an individual or a company/trust entity. */
870
+ type PiiKind = PiiKindDto;
871
+ /** ISO 3166-1 alpha-2 country code (e.g. `'US'`). */
872
+ type Iso2CountryCode = Newtype<string, 'Iso2CountryCode'>;
873
+ declare const Iso2CountryCode: (value: string) => Iso2CountryCode;
874
+ /** Jurisdiction derived from the entity's address country. */
875
+ type PiiJurisdiction = {
876
+ iso2: Iso2CountryCode;
877
+ name: string | null;
878
+ };
879
+ declare const PiiJurisdiction: {
880
+ fromDto: (dto: PiiJurisdictionDto) => PiiJurisdiction;
881
+ };
882
+ /** Permanent address on file for the entity. */
883
+ type PiiAddress = {
884
+ street: string | null;
885
+ city: string | null;
886
+ state: string | null;
887
+ postalCode: string | null;
888
+ country: string | null;
889
+ };
890
+ declare const PiiAddress: {
891
+ fromDto: (dto: PiiAddressDto) => PiiAddress;
892
+ };
893
+ /**
894
+ * The current user's PII, used to pre-fill tax forms such as the W-8BEN.
895
+ * Fields the entity hasn't provided are `null`.
896
+ */
897
+ type Pii = {
898
+ kind: PiiKind;
899
+ fullLegalName: string | null;
900
+ dateOfBirth: string | null;
901
+ jurisdiction: PiiJurisdiction | null;
902
+ taxId: string | null;
903
+ permanentAddress: PiiAddress;
904
+ };
905
+ declare const Pii: {
906
+ fromDto: (dto: PiiDto) => Pii;
907
+ };
908
+
909
+ type RequirementTypeDto = 'kyc_approved' | 'identity_verified' | 'proof_of_address' | 'source_of_funds' | 'external_wallet' | 'whitelisted_wallet' | 'jurisdiction' | 'accreditation' | 'document';
910
+ type RequirementDto = {
911
+ object: 'requirement';
912
+ id: string;
913
+ type: RequirementTypeDto;
914
+ details: Record<string, unknown> | null;
915
+ };
916
+ type RequirementStatusValueDto = 'not_started' | 'in_progress' | 'action_needed' | 'completed' | 'rejected';
917
+ type RequirementActionNeededReasonDto = 'kyc_not_verified' | 'update_pii_data';
918
+ /**
919
+ * Object form of a requirement status, used when the status carries extra
920
+ * data: the action-needed reason and/or the Sumsub flow that resolves the
921
+ * requirement (kyc_level + kyc_reset, forwarded to the kyc-token endpoint).
922
+ */
923
+ type RequirementStatusObjectDto = {
924
+ status: RequirementStatusValueDto;
925
+ action?: RequirementActionNeededReasonDto;
926
+ kyc_level?: string;
927
+ kyc_reset?: boolean;
928
+ };
929
+ type RequirementStatusesDto = {
930
+ object: 'requirement_statuses';
931
+ offer_id: string;
932
+ statuses: Record<string, RequirementStatusValueDto | RequirementStatusObjectDto>;
933
+ };
934
+
935
+ type RequirementId = Newtype<string, 'RequirementId'>;
936
+ declare const RequirementId: (value: string) => RequirementId;
937
+ type RequirementType = RequirementTypeDto;
938
+ type RequirementStatusValue = RequirementStatusValueDto;
939
+ type RequirementActionNeededReason = RequirementActionNeededReasonDto;
940
+ type Requirement = {
941
+ id: RequirementId;
942
+ type: RequirementType;
943
+ details: Record<string, unknown> | null;
944
+ };
945
+ declare const Requirement: {
946
+ fromDto: (dto: RequirementDto) => Requirement;
947
+ };
948
+ type RequirementStatusInfo = {
949
+ id: RequirementId;
950
+ status: RequirementStatusValue;
951
+ /** Why the requirement needs action (KYC-backed requirements only). */
952
+ action: RequirementActionNeededReason | null;
953
+ /**
954
+ * The Sumsub verification level that resolves this requirement, prescribed
955
+ * by the backend. Present exactly when an inline Sumsub flow can be started.
956
+ */
957
+ kycLevel?: KycLevelName;
958
+ /**
959
+ * Whether the Sumsub applicant must be reset before starting the flow
960
+ * (redoing an already-approved level, e.g. to update stale PII). Forward to
961
+ * the kyc-token request as-is.
962
+ */
963
+ kycReset?: boolean;
964
+ };
965
+ declare const RequirementStatusInfo: {
966
+ fromStatusesDto: (dto: RequirementStatusesDto) => RequirementStatusInfo[];
967
+ };
968
+
969
+ export { Asset as $, AuthorizationCode as A, Bps as B, type CoinListSwapNamespace as C, type DocumentType as D, EvmWalletAddress as E, AssetDecimals as F, StablecoinSymbol as G, OAuthSession as H, ClientCredentialsOAuth as I, ClientSecret as J, type KycLevelName as K, AssetSymbol as L, SwapStatus as M, type Newtype as N, OfferId as O, PaginationParams as P, KnownAssetSymbol as Q, Requirement as R, SwapNamespaceImpl as S, ClientId as T, type Uint256 as U, RedirectUri as V, WalletOwnershipChallenge as W, CodeChallenge as X, PKCEState as Y, type AllowWalletParams as Z, AllowWalletResponse as _, type EthereumChain as a, AssetCode as a0, AssetId as a1, Blockchain as a2, Cursor as a3, type DocumentFormType as a4, type DocumentSubmissionStatus as a5, FaqItem as a6, type GetSwapAuthorizationParams as a7, type GetSwapPreviewParams as a8, type GetTokenAllowanceParams as a9, fetchAllPages as aA, type GetTokenBalanceParams as aa, HexEncodedTransactionData as ab, Iso2CountryCode as ac, Link as ad, MAX_UINT_256 as ae, Milestone as af, OAuthRefreshToken as ag, OfferOption as ah, OfferOptionSlug as ai, OfferSlug as aj, type PaginatedResponseDto as ak, type ParticipationStatus as al, PiiAddress as am, PiiJurisdiction as an, type PiiKind as ao, type RequirementActionNeededReason as ap, RequirementId as aq, SwapAuthorization as ar, type SwapContractRef as as, SwapPreview as at, TermItem as au, TokenAllowance as av, TokenBalance as aw, WalletAddress as ax, type WalletProtocol as ay, assertUint256 as az, EvmContractAddress as b, BlockchainAmount as c, CodeVerifier as d, type Config as e, type OAuthAccessToken as f, Offer as g, PaginatedResponse as h, OfferDetail as i, Participation as j, ParticipationsPaginationParams as k, ParticipationId as l, CreateParticipationParams as m, CreateWalletOwnershipChallengeParams as n, ConnectExternalWalletParams as o, OfferOptionAddress as p, OfferOptionId as q, OfferOptionAddressId as r, RequirementStatusInfo as s, Pii as t, DocumentSubmission as u, KycToken as v, type WalletChallengeType as w, type RequirementType as x, type RequirementStatusValue as y, type Erc20Asset as z };