@coinlist-co/react 0.12.0 → 0.12.1-rc.0fa5c3b

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 (31) hide show
  1. package/dist/{chunk-ZFBEI3BW.js → chunk-3EOK47CQ.js} +20 -330
  2. package/dist/chunk-3EOK47CQ.js.map +1 -0
  3. package/dist/{chunk-F6WGUKZC.js → chunk-I5EHOV7V.js} +129 -3
  4. package/dist/chunk-I5EHOV7V.js.map +1 -0
  5. package/dist/{chunk-6CQHDASY.js → chunk-VSYGGTI6.js} +1173 -156
  6. package/dist/chunk-VSYGGTI6.js.map +1 -0
  7. package/dist/client/index.cjs +8559 -7690
  8. package/dist/client/index.cjs.map +1 -1
  9. package/dist/client/index.d.cts +116 -48
  10. package/dist/client/index.d.ts +116 -48
  11. package/dist/client/index.js +4059 -4007
  12. package/dist/client/index.js.map +1 -1
  13. package/dist/{collections-DOm9VKVm.d.cts → collections-C6b-rJpx.d.ts} +1 -1
  14. package/dist/{collections-aCv-Wr2a.d.ts → collections-UYVlXbEh.d.cts} +1 -1
  15. package/dist/server/index.cjs +1291 -166
  16. package/dist/server/index.cjs.map +1 -1
  17. package/dist/server/index.d.cts +1 -1
  18. package/dist/server/index.d.ts +1 -1
  19. package/dist/server/index.js +5 -3
  20. package/dist/server/index.js.map +1 -1
  21. package/dist/{config-DIaFzrMW.d.cts → tokens-namespace-C-BxcYMj.d.cts} +362 -188
  22. package/dist/{config-DIaFzrMW.d.ts → tokens-namespace-C-BxcYMj.d.ts} +362 -188
  23. package/dist/universal/index.cjs +1103 -405
  24. package/dist/universal/index.cjs.map +1 -1
  25. package/dist/universal/index.d.cts +427 -45
  26. package/dist/universal/index.d.ts +427 -45
  27. package/dist/universal/index.js +16 -14
  28. package/package.json +1 -1
  29. package/dist/chunk-6CQHDASY.js.map +0 -1
  30. package/dist/chunk-F6WGUKZC.js.map +0 -1
  31. package/dist/chunk-ZFBEI3BW.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { Hash, Hex } from 'viem';
1
+ import { Hash, Transport, PublicClient, Hex } from 'viem';
2
2
 
3
3
  declare const __brand: unique symbol;
4
4
  type Newtype<Base, Branding> = Base & {
@@ -412,7 +412,7 @@ type PinoLoggerOptions = {
412
412
  * - an operation, a flow, a hook - is a {@link LogBinding} and appears as its
413
413
  * own field.
414
414
  */
415
- type LogScope = 'HTTP' | 'AUTH' | 'OFFERS' | 'REQUIREMENTS' | 'WALLETS' | 'ERC20' | 'TOKEN_SALE' | 'SUPERSTATE' | 'ONDO' | 'TOKENS' | 'SUPPORT' | 'HOOKS';
415
+ type LogScope = 'HTTP' | 'RPC' | 'AUTH' | 'OFFERS' | 'REQUIREMENTS' | 'WALLETS' | 'ERC20' | 'TOKEN_SALE' | 'SUPERSTATE' | 'ONDO' | 'TOKENS' | 'SUPPORT' | 'HOOKS';
416
416
  /**
417
417
  * Correlates every line one logical request produces. The first attempt, each
418
418
  * retry, and the re-send after a session renewal all carry the same id, so a
@@ -462,6 +462,12 @@ type FrontlineEventId = Newtype<string, 'FrontlineEventId'>;
462
462
  * `validation` failure from `OFFERS` surfaced by `useOffers` would have been
463
463
  * tagged `HOOKS` on the hook's line. Forward the event, not the cause alone.
464
464
  */
465
+ /**
466
+ * Why an on-chain read failed, named after what a caller would do about it
467
+ * rather than after the viem error class that reported it. See the `rpc` arm
468
+ * of {@link LogCause}.
469
+ */
470
+ type RpcFailureReason = 'reverted' | 'node-rejected' | 'transport' | 'malformed-response' | 'unknown';
465
471
  type LogCause =
466
472
  /**
467
473
  * A request reached the backend and came back non-2xx.
@@ -538,6 +544,33 @@ type LogCause =
538
544
  type: 'wallet';
539
545
  error: RedactedWalletError;
540
546
  }
547
+ /**
548
+ * An on-chain read did not answer. `reason` names the remedy, not the viem
549
+ * class that carried it:
550
+ *
551
+ * - `reverted` - the contract refused the call. Check the arguments, or the
552
+ * contract's own state (a stopped swap reverts its `preview`).
553
+ * - `node-rejected` - the node reached the contract and declined. Usually a
554
+ * malformed request, a rate limit, or a method the node does not serve.
555
+ * Also where a host-supplied `Transport` throwing something viem cannot
556
+ * read a code off lands: `buildRequest` wraps it in `UnknownRpcError`.
557
+ * - `transport` - the node was not reached at all. Retry, or fail over.
558
+ * A dropped `webSocket()` socket included.
559
+ * - `malformed-response` - the call returned something the ABI cannot
560
+ * decode, which in practice means the wrong address or a stale ABI.
561
+ * - `unknown` - anything else. Rare, since viem wraps most of what a read
562
+ * can throw into one of the classes the arms above name.
563
+ *
564
+ * Decided by `instanceof` alone. Nothing is read off the thrown error - not
565
+ * its `name`, not its `message`, not a revert reason - because a viem
566
+ * message embeds the calldata, the contract address and the caller, and
567
+ * `name` is a writable property a host-supplied transport could set to
568
+ * anything. All of that is on the paired `'debug'` line.
569
+ */
570
+ | {
571
+ type: 'rpc';
572
+ reason: RpcFailureReason;
573
+ }
541
574
  /**
542
575
  * Something the SDK does not recognise - usually a host-supplied lambda
543
576
  * (`getAccessToken`, an {@link EvmWallet} method) throwing, or a
@@ -926,8 +959,131 @@ interface Sender {
926
959
  send<T>(request: HttpRequest): Promise<T>;
927
960
  }
928
961
 
962
+ /**
963
+ * Where the SDK sends its on-chain reads, per chain.
964
+ *
965
+ * Leave it undefined and reads go through CoinList's authenticated JSON-RPC
966
+ * proxy (`POST /v1/chains/{chain}/rpc`), which needs no setup but does need a
967
+ * logged-in user - the proxy is OAuth-gated, so a read on a chain the SDK is
968
+ * proxying fails with its `401`, surfaced as the viem error wrapping it. A
969
+ * chain you name here is read straight from your own node instead, and needs
970
+ * no CoinList session at all.
971
+ *
972
+ * Each entry is either:
973
+ *
974
+ * - an RPC URL, which the SDK wraps in viem's `http()` transport, or
975
+ * - a viem {@link Transport} used as it stands - `fallback([...])`,
976
+ * `webSocket()`, or your app's own.
977
+ *
978
+ * Chains you leave out fall back to the proxy individually, so overriding
979
+ * mainnet does not opt Sepolia out. The SDK always constructs the viem
980
+ * `PublicClient` itself, so the chain definition, batching and retry policy
981
+ * stay the SDK's regardless of the transport you supply.
982
+ *
983
+ * @example
984
+ * ```ts
985
+ * createCoinListClient({
986
+ * clientId,
987
+ * redirectUri,
988
+ * rpc: {
989
+ * ethereum_mainnet: 'https://eth-mainnet.g.alchemy.com/v2/KEY',
990
+ * ethereum_sepolia: fallback([http(primary), http(backup)]),
991
+ * // base_* unset -> proxied through CoinList
992
+ * },
993
+ * });
994
+ * ```
995
+ */
996
+ type RpcConfig = Partial<Record<EthereumChain, string | Transport>>;
997
+ interface Config {
998
+ /** OAuth2 public identifier. */
999
+ readonly clientId: ClientId;
1000
+ /**
1001
+ * OAuth2 redirect URI. Recommended to point to a frontend page where
1002
+ * {@link CoinListClient#completeOauth} can be called to complete the PKCE
1003
+ * flow on the client side.
1004
+ */
1005
+ readonly redirectUri: RedirectUri;
1006
+ /**
1007
+ * Recommended to leave undefined. Used to change the CoinList environment;
1008
+ * default is production.
1009
+ */
1010
+ readonly baseUrl?: string;
1011
+ /**
1012
+ * Recommended to leave undefined. Overrides the base URL of the public
1013
+ * token registry backing `coinlist.tokens`; default is the production
1014
+ * registry.
1015
+ */
1016
+ readonly tokensBaseUrl?: string;
1017
+ /**
1018
+ * Where the SDK reports what it is doing. **Omit it and the SDK logs nothing
1019
+ * at all** - no `console` fallback, at any level, on any codepath. Supply
1020
+ * one and every request, every classified failure and every hook state
1021
+ * transition is reported at the level your logger asks for.
1022
+ *
1023
+ * Absent, the SDK says nothing at all - there is no fallback to `console`,
1024
+ * at any level, on any codepath.
1025
+ *
1026
+ * **Running the SDK's logging in production is not advised.** The safest
1027
+ * posture is to leave this undefined outside development, staging and
1028
+ * incident reproduction: a seam that emits nothing cannot disclose anything,
1029
+ * and that property does not depend on the SDK continuing to get redaction
1030
+ * right.
1031
+ *
1032
+ * If you do run one there, run it at `'info'` or above and know what that
1033
+ * does and does not buy you. Those levels are **redacted by construction**:
1034
+ * they carry only SDK-authored classification and server-authored
1035
+ * identifiers, and the type system holds that line rather than a convention -
1036
+ * an event at those levels accepts scalar fields only, so a body, a DTO or
1037
+ * an operation's parameters cannot be put on one. What the SDK does **not**
1038
+ * give you is a warranty that the result is safe for your environment. The
1039
+ * mechanism is checkable and stated; the conclusion depends on your sink,
1040
+ * your retention and your threat model, and it is yours to draw.
1041
+ *
1042
+ * **`'debug'` is not.** It reports request and response bodies, full URLs,
1043
+ * headers and operation parameters verbatim - bearer tokens, KYC answers,
1044
+ * tax-document fields, wallet signatures - and **the SDK does not redact**.
1045
+ * Run it on a developer's machine, in tests, and in beta or staging
1046
+ * environments where the data flowing through is not real customer data.
1047
+ * The shipped implementations make that structural: built with
1048
+ * `isDev: false`, `'debug'` does not typecheck. Either way, filtering,
1049
+ * redaction and retention at your sink are yours, not the SDK's.
1050
+ *
1051
+ * Every method you implement here **must be total**: the SDK calls them on
1052
+ * the codepath of the work they report and does not catch them, so a logger
1053
+ * that throws fails the operation it was describing.
1054
+ *
1055
+ * See {@link Logger} for the full contract, and {@link pinoClientLogger} or
1056
+ * {@link pinoServerLogger} for a ready-made implementation over pino.
1057
+ */
1058
+ readonly logger?: Logger;
1059
+ /**
1060
+ * Where on-chain reads go. Omit it and they are proxied through CoinList.
1061
+ * See {@link RpcConfig}.
1062
+ */
1063
+ readonly rpc?: RpcConfig;
1064
+ }
1065
+
1066
+ /**
1067
+ * Resolves a chain to the viem `PublicClient` the SDK reads it through.
1068
+ *
1069
+ * One function rather than a client per read, because the client is where the
1070
+ * batching lives: viem's multicall scheduler is keyed on the client's `uid`,
1071
+ * so two reads only ever share an `eth_call` if they share a client. Hence the
1072
+ * memoisation - it is correctness for batching, not a performance tweak.
1073
+ */
1074
+ type PublicClients = (chain: EthereumChain) => PublicClient;
1075
+
929
1076
  interface UniversalNamespaceContext {
930
1077
  readonly api: Sender;
1078
+ /**
1079
+ * The viem `PublicClient` for a chain, over whichever transport that chain
1080
+ * resolved to - the host's own node, or CoinList's proxy.
1081
+ *
1082
+ * A factory rather than a client, because a namespace serves every chain and
1083
+ * only the call knows which. Built once per client instance so that
1084
+ * concurrent reads share a batch; see `publicClients`.
1085
+ */
1086
+ readonly rpc: PublicClients;
931
1087
  /**
932
1088
  * The host's logger, or `null` when they supplied none.
933
1089
  *
@@ -940,133 +1096,35 @@ interface UniversalNamespaceContext {
940
1096
  ensureUserAuthenticated(): Promise<void>;
941
1097
  }
942
1098
 
943
- /**
944
- * Raw JSON models for the on-chain swap endpoints. uint256 values are encoded
945
- * as decimal strings because they can exceed the safe integer range of JSON
946
- * consumers.
947
- */
948
- type WalletAuthorizationDto = {
949
- object: 'wallet_authorization';
950
- authorized: boolean;
951
- };
952
- type SwapPreviewDto = {
953
- object: 'swap_preview';
954
- pay_input_amount: string;
955
- fee: string;
956
- receive_output_amount: string;
957
- };
958
- type SwapStatusDto = {
959
- object: 'swap_status';
960
- stopped: string;
961
- swap_level: string;
962
- };
963
- type TokenAllowanceDto = {
964
- object: 'token_allowance';
965
- allowance: string;
966
- };
967
- type TokenBalanceDto = {
968
- object: 'token_balance';
969
- balance: string;
970
- };
971
- type AllowWalletResponseDto = {
972
- action: 'broadcast_transaction';
973
- to: string;
974
- data: string;
975
- } | {
976
- action: 'none';
977
- already_allowed: boolean;
978
- };
979
-
980
- /**
981
- * Whether a wallet is authorized to interact with a given swap contract.
982
- */
983
- type SwapAuthorization = {
984
- authorized: boolean;
985
- };
986
- declare const SwapAuthorization: {
987
- fromDto: (dto: WalletAuthorizationDto) => SwapAuthorization;
988
- };
989
- /**
990
- * A read-only quote for a swap: how much goes in, the protocol fee, and how
991
- * much would come out. All amounts are raw on-chain integers (uint256).
992
- */
993
- type SwapPreview = {
994
- inputAmount: Uint256;
995
- fee: Uint256;
996
- outputAmount: Uint256;
997
- };
998
- declare const SwapPreview: {
999
- fromDto: (dto: SwapPreviewDto) => SwapPreview;
1000
- };
1001
- /**
1002
- * The on-chain state of a swap contract.
1003
- *
1004
- * - `stopped`: non-zero when the contract is paused/halted.
1005
- * - `swapLevel`: the current swap level/tier.
1006
- */
1007
- type SwapStatus = {
1008
- stopped: Uint256;
1009
- swapLevel: Uint256;
1010
- };
1011
- declare const SwapStatus: {
1012
- fromDto: (dto: SwapStatusDto) => SwapStatus;
1013
- };
1014
- /**
1015
- * The ERC-20 allowance an owner has granted a spender for a token.
1016
- */
1017
- type TokenAllowance = {
1018
- allowance: Uint256;
1019
- };
1020
- declare const TokenAllowance: {
1021
- fromDto: (dto: TokenAllowanceDto) => TokenAllowance;
1022
- };
1023
- /**
1024
- * The raw ERC-20 balance an owner holds of a token (uint256).
1025
- */
1026
- type TokenBalance = {
1027
- balance: Uint256;
1028
- };
1029
- declare const TokenBalance: {
1030
- fromDto: (dto: TokenBalanceDto) => TokenBalance;
1031
- };
1032
- /**
1033
- * The backend's response to an allow-wallet request. Either the caller must
1034
- * broadcast an on-chain transaction to complete allow-listing, or nothing is
1035
- * required because the wallet is already allowed.
1036
- */
1037
- type AllowWalletResponse = {
1038
- action: 'broadcast_transaction';
1039
- to: EvmContractAddress;
1040
- data: HexEncodedTransactionData;
1041
- } | {
1042
- action: 'none';
1043
- alreadyAllowed: boolean;
1044
- };
1045
- declare const AllowWalletResponse: {
1046
- fromDto: (dto: AllowWalletResponseDto) => AllowWalletResponse;
1047
- };
1048
-
1049
1099
  /**
1050
1100
  * Generic ERC-20 reads shared across on-chain flows (swap, token sale): the
1051
1101
  * allowance an owner has granted a spender, and the raw token balance an owner
1052
1102
  * holds. These are plain token reads, not tied to any single product flow.
1103
+ *
1104
+ * Read from the chain rather than from a CoinList endpoint. By default that
1105
+ * goes through CoinList's authenticated JSON-RPC proxy, so a logged-out caller
1106
+ * gets the proxy's `401` - surfaced as a viem error wrapping the SDK's
1107
+ * `HttpError`, not as `NotAuthenticatedError`, since viem re-wraps whatever a
1108
+ * `Transport` throws. Point `Config.rpc` at your own node for this chain and no
1109
+ * CoinList session is involved at all. See {@link RpcConfig}.
1053
1110
  */
1054
1111
  interface Erc20Namespace {
1055
1112
  /**
1056
- * Reads the ERC-20 allowance an `owner` has granted a `spender`.
1113
+ * Reads the ERC-20 allowance an `owner` has granted a `spender`, as a raw
1114
+ * on-chain integer.
1057
1115
  */
1058
- getAllowance(params: GetTokenAllowanceParams): Promise<TokenAllowance>;
1116
+ getAllowance(params: GetTokenAllowanceParams): Promise<Uint256>;
1059
1117
  /**
1060
1118
  * Reads the raw ERC-20 balance an `owner` holds of a token.
1061
1119
  */
1062
- getBalance(params: GetTokenBalanceParams): Promise<TokenBalance>;
1120
+ getBalance(params: GetTokenBalanceParams): Promise<Uint256>;
1063
1121
  }
1064
1122
  declare class Erc20NamespaceImpl implements Erc20Namespace {
1065
1123
  private readonly ctx;
1066
1124
  private readonly log;
1067
1125
  constructor(ctx: UniversalNamespaceContext);
1068
- getAllowance(params: GetTokenAllowanceParams): Promise<TokenAllowance>;
1069
- getBalance(params: GetTokenBalanceParams): Promise<TokenBalance>;
1126
+ getAllowance(params: GetTokenAllowanceParams): Promise<Uint256>;
1127
+ getBalance(params: GetTokenBalanceParams): Promise<Uint256>;
1070
1128
  }
1071
1129
 
1072
1130
  /**
@@ -1320,6 +1378,16 @@ type OfferDetailDto = {
1320
1378
  logo_url: string;
1321
1379
  starts_at: string;
1322
1380
  tagline: string;
1381
+ /** Issuer of the *token*, not of the security it tracks. Ondo offers only. */
1382
+ issuer: string | null;
1383
+ /** ISO 6166 id of the underlying security. Null when the supplier has none. */
1384
+ isin: string | null;
1385
+ /** The underlying's symbol on its venue (`QQQ`), never the token's (`QQQon`). */
1386
+ ticker: string | null;
1387
+ /** Supplier vocabulary (`Stock`, `ETF`). Open set — display, do not branch. */
1388
+ instrument_type: string | null;
1389
+ /** Venue the underlying lists on. Not served by the supplier; entered by hand. */
1390
+ listing_venue: string | null;
1323
1391
  };
1324
1392
  type OfferDetailFaqDto = {
1325
1393
  answer: string | null;
@@ -1353,6 +1421,23 @@ type OfferDetailSwapContractDto = {
1353
1421
  address: string;
1354
1422
  };
1355
1423
 
1424
+ type Ticker = Newtype<string, 'Ticker'>;
1425
+ declare const Ticker: (value: string) => Ticker;
1426
+ /**
1427
+ * An ISO 6166 International Securities Identification Number, e.g.
1428
+ * `US0378331005`. Identifies the security itself, which is what makes it the
1429
+ * stable key across venues where a {@link Ticker} is not: the same security
1430
+ * trades under different tickers in different places, and the same ticker
1431
+ * means different securities in different places.
1432
+ *
1433
+ * Not validated on construction — the value comes from a supplier that has
1434
+ * already checked it, and a client-side check-digit test could only reject
1435
+ * data the SDK still has to display.
1436
+ */
1437
+ type Isin = Newtype<string, 'Isin'>;
1438
+ declare const Isin: (value: string) => Isin;
1439
+ type OrderBookSide = 'buy' | 'sell';
1440
+
1356
1441
  type OfferOptionId = Newtype<string, 'OfferOptionId'>;
1357
1442
  declare const OfferOptionId: (value: string) => OfferOptionId;
1358
1443
  type OfferOptionSlug = Newtype<string, 'OfferOptionSlug'>;
@@ -1390,6 +1475,48 @@ type OfferDetail = {
1390
1475
  bannerUrl: string;
1391
1476
  logoUrl: string;
1392
1477
  category: string;
1478
+ /**
1479
+ * The legal issuer of the *token*, e.g. `'Ondo Global Markets'`. The issuer
1480
+ * of the security it tracks is {@link OfferDetail.name} (`'Apple Inc.'`).
1481
+ * Null on offers with no single named issuer.
1482
+ */
1483
+ issuer: string | null;
1484
+ /**
1485
+ * ISO 6166 identifier of the underlying security, e.g. `'US0378331005'`.
1486
+ * Null both on offers that tokenize no security and on the few that do but
1487
+ * whose supplier publishes no ISIN, so absence does not imply "not a
1488
+ * security".
1489
+ */
1490
+ isin: Isin | null;
1491
+ /**
1492
+ * The underlying security's symbol on its listing venue, e.g. `'QQQ'`. This
1493
+ * is *not* the token's symbol — that is `asset.code` (`'QQQon'`). Null on
1494
+ * offers that tokenize no listed security.
1495
+ */
1496
+ ticker: Ticker | null;
1497
+ /**
1498
+ * What kind of instrument the underlying is, as the supplier classifies it:
1499
+ * `'Stock'`, `'ETF'`. Distinct from {@link OfferDetail.category}, which is
1500
+ * the broader class the offer is grouped under (`'Equities'`) — this field
1501
+ * describes the single instrument, `category` describes the shelf it sits
1502
+ * on.
1503
+ *
1504
+ * An open set: the vocabulary belongs to the supplier and may grow without
1505
+ * notice, so render an unrecognized value rather than branching on it. Note
1506
+ * the supplier's spelling is its own — a common stock arrives as `'Stock'`.
1507
+ */
1508
+ instrumentType: string | null;
1509
+ /**
1510
+ * The exchange the underlying security lists on, e.g. `'NASDAQ'`. Not
1511
+ * derivable from {@link OfferDetail.isin}, whose country prefix is the
1512
+ * country of issuance rather than the venue.
1513
+ *
1514
+ * Unlike the fields above, this one is recorded by hand rather than served
1515
+ * by the supplier, so it is null until someone records it — on a newly
1516
+ * listed offer that is the normal state, and it says nothing about whether
1517
+ * the offer tokenizes a security.
1518
+ */
1519
+ listingVenue: string | null;
1393
1520
  startsAt: Date;
1394
1521
  endsAt: Date | null;
1395
1522
  faqs: FaqItem[];
@@ -1570,10 +1697,6 @@ declare class CoinListTokenSaleNamespaceImpl implements CoinListTokenSaleNamespa
1570
1697
  createParticipation(params: CreateParticipationParams): Promise<Participation>;
1571
1698
  }
1572
1699
 
1573
- type Ticker = Newtype<string, 'Ticker'>;
1574
- declare const Ticker: (value: string) => Ticker;
1575
- type OrderBookSide = 'buy' | 'sell';
1576
-
1577
1700
  /**
1578
1701
  * No `chain` on the read params: Ondo runs no sandbox, so every environment
1579
1702
  * prices against Ondo production on Ethereum mainnet. Accepting a chain would
@@ -2230,6 +2353,105 @@ declare class OndoNamespaceImpl implements OndoNamespace {
2230
2353
  buildSellTransaction(params: BuildOndoSellParams): Promise<OndoSellTransaction>;
2231
2354
  }
2232
2355
 
2356
+ /**
2357
+ * Raw JSON models for the Superstate swap endpoints that are still backend
2358
+ * calls.
2359
+ *
2360
+ * The contract *reads* no longer have DTOs: the SDK calls `status()`,
2361
+ * `preview()`, `authorized()` and `outputToken()` on-chain through
2362
+ * `@/universal/api/rpc`, so their wire shape is the ABI rather than JSON.
2363
+ * Allow-listing a wallet stays here because it is a backend write, not a read.
2364
+ */
2365
+ type AllowWalletResponseDto = {
2366
+ action: 'broadcast_transaction';
2367
+ to: string;
2368
+ data: string;
2369
+ } | {
2370
+ action: 'none';
2371
+ already_allowed: boolean;
2372
+ };
2373
+
2374
+ /**
2375
+ * A read-only quote for a swap: how much goes in, the protocol fee, and how
2376
+ * much would come out. All amounts are raw on-chain integers (uint256).
2377
+ */
2378
+ type SwapPreview = {
2379
+ inputAmount: Uint256;
2380
+ fee: Uint256;
2381
+ outputAmount: Uint256;
2382
+ };
2383
+ declare const SwapPreview: {
2384
+ /** Maps the contract's `Preview { input, fee, output }` struct. */
2385
+ fromContract: (preview: {
2386
+ input: bigint;
2387
+ fee: bigint;
2388
+ output: bigint;
2389
+ }) => SwapPreview;
2390
+ };
2391
+ /**
2392
+ * The bitmask of operations a swap contract has paused, as `Operable.paused`
2393
+ * reports it. Each bit is one operation level; swapping is
2394
+ * {@link SWAP_LEVEL}.
2395
+ *
2396
+ * Meaningful only while the contract is paused, which is why it lives on that
2397
+ * arm of {@link SwapStatus} alone: an active contract has nothing paused, and
2398
+ * a stopped one is past caring which level was.
2399
+ */
2400
+ type PauseFlags = Newtype<number, 'PauseFlags'>;
2401
+ declare const PauseFlags: (value: number) => PauseFlags;
2402
+ /**
2403
+ * The on-chain state of a swap contract, as `status()` reports it.
2404
+ *
2405
+ * - `active` - operating normally.
2406
+ * - `paused` - one or more operations are suspended, and may be resumed.
2407
+ * `pausedLevels` says which. **This does not by itself mean swapping is
2408
+ * down**: a contract can pause an unrelated operation and keep swapping.
2409
+ * Ask `isSwapAvailable` rather than reading the state.
2410
+ * - `stopped` - permanently halted, and cannot be reactivated.
2411
+ */
2412
+ type SwapStatus = {
2413
+ state: 'active';
2414
+ } | {
2415
+ state: 'paused';
2416
+ pausedLevels: PauseFlags;
2417
+ } | {
2418
+ state: 'stopped';
2419
+ };
2420
+ declare const SwapStatus: {
2421
+ /**
2422
+ * Maps the contract's `Status { uint32 flags; State state }` struct, where
2423
+ * `State` is `0 = Active | 1 = Paused | 2 = Stopped`.
2424
+ *
2425
+ * `flags` is carried onto the `paused` arm only. On the other two the
2426
+ * contract sets it to a self-identifying marker rather than to information -
2427
+ * so repeating it would invite a caller to read meaning into a constant.
2428
+ *
2429
+ * @throws ValidationError on a `state` outside the enum. A contract that has
2430
+ * grown a fourth state is one the SDK does not model, and guessing `active`
2431
+ * would let a halted swap read as a live one.
2432
+ */
2433
+ fromContract: (status: {
2434
+ flags: number;
2435
+ state: number;
2436
+ }) => SwapStatus;
2437
+ };
2438
+ /**
2439
+ * The backend's response to an allow-wallet request. Either the caller must
2440
+ * broadcast an on-chain transaction to complete allow-listing, or nothing is
2441
+ * required because the wallet is already allowed.
2442
+ */
2443
+ type AllowWalletResponse = {
2444
+ action: 'broadcast_transaction';
2445
+ to: EvmContractAddress;
2446
+ data: HexEncodedTransactionData;
2447
+ } | {
2448
+ action: 'none';
2449
+ alreadyAllowed: boolean;
2450
+ };
2451
+ declare const AllowWalletResponse: {
2452
+ fromDto: (dto: AllowWalletResponseDto) => AllowWalletResponse;
2453
+ };
2454
+
2233
2455
  /** Parameters shared by contract reads scoped to a chain. */
2234
2456
  type SwapContractRef = {
2235
2457
  contractAddress: EvmContractAddress;
@@ -2251,30 +2473,46 @@ type AllowWalletParams = {
2251
2473
 
2252
2474
  /**
2253
2475
  * Read/write operations for the on-chain swap flow: quoting a swap, inspecting
2254
- * contract state, checking token allowances, and proving/allow-listing wallet
2255
- * ownership.
2476
+ * contract state, and proving/allow-listing wallet ownership.
2477
+ *
2478
+ * Every read here is a contract call the SDK makes itself. By default those go
2479
+ * through CoinList's authenticated JSON-RPC proxy, so a logged-out caller gets
2480
+ * the proxy's `401` - surfaced as a viem error wrapping the SDK's `HttpError`,
2481
+ * not as `NotAuthenticatedError`, since viem re-wraps whatever a `Transport`
2482
+ * throws. Point `Config.rpc` at your own node for this chain and no CoinList
2483
+ * session is involved at all. `allowWallet` is the exception: it is a backend
2484
+ * write and always needs one, and throws `NotAuthenticatedError` without.
2256
2485
  */
2257
2486
  interface SuperstateSwapNamespace {
2258
2487
  /**
2259
2488
  * Checks whether a wallet is authorized to swap against the given contract.
2260
2489
  */
2261
- getAuthorization(params: GetSwapAuthorizationParams): Promise<SwapAuthorization>;
2490
+ getAuthorization(params: GetSwapAuthorizationParams): Promise<boolean>;
2262
2491
  /**
2263
2492
  * Fetches a read-only quote for swapping `amount` of `inputToken`.
2493
+ *
2494
+ * The contract reverts rather than quoting when it is stopped, or when
2495
+ * `inputToken` is not one it accepts, so this surfaces a viem
2496
+ * `ContractFunctionRevertedError` naming the contract's own error. Check
2497
+ * {@link getStatus} first if you would rather not provoke one.
2264
2498
  */
2265
2499
  getPreview(params: GetSwapPreviewParams): Promise<SwapPreview>;
2266
2500
  /**
2267
- * Reads the current on-chain state of a swap contract.
2501
+ * Reads the current on-chain state of a swap contract. See
2502
+ * {@link isSwapAvailable} before concluding that a `paused` contract cannot
2503
+ * swap - the two are not the same question.
2268
2504
  */
2269
2505
  getStatus(params: SwapContractRef): Promise<SwapStatus>;
2270
2506
  /**
2271
- * Reads the ERC-20 output token a swap contract pays out.
2507
+ * Reads the ERC-20 output token a swap contract pays out, with its metadata.
2272
2508
  */
2273
2509
  getOutputToken(params: SwapContractRef): Promise<Erc20Asset>;
2274
2510
  /**
2275
2511
  * Submits a signed wallet-ownership challenge to allow-list the wallet for
2276
2512
  * an offer, identified by its offer id. Obtain the challenge from
2277
2513
  * `WalletsNamespace.createOwnershipChallenge`.
2514
+ *
2515
+ * @throws NotAuthenticatedError without a logged-in user.
2278
2516
  */
2279
2517
  allowWallet(params: AllowWalletParams): Promise<AllowWalletResponse>;
2280
2518
  }
@@ -2282,7 +2520,7 @@ declare class SuperstateSwapNamespaceImpl implements SuperstateSwapNamespace {
2282
2520
  private readonly ctx;
2283
2521
  protected readonly log: InternalLogger;
2284
2522
  constructor(ctx: UniversalNamespaceContext);
2285
- getAuthorization(params: GetSwapAuthorizationParams): Promise<SwapAuthorization>;
2523
+ getAuthorization(params: GetSwapAuthorizationParams): Promise<boolean>;
2286
2524
  getPreview(params: GetSwapPreviewParams): Promise<SwapPreview>;
2287
2525
  getStatus(params: SwapContractRef): Promise<SwapStatus>;
2288
2526
  getOutputToken(params: SwapContractRef): Promise<Erc20Asset>;
@@ -2935,68 +3173,4 @@ declare class TokensNamespaceImpl implements TokensNamespace {
2935
3173
  list(chain?: EthereumChain): Promise<TokenMetadata[]>;
2936
3174
  }
2937
3175
 
2938
- interface Config {
2939
- /** OAuth2 public identifier. */
2940
- readonly clientId: ClientId;
2941
- /**
2942
- * OAuth2 redirect URI. Recommended to point to a frontend page where
2943
- * {@link CoinListClient#completeOauth} can be called to complete the PKCE
2944
- * flow on the client side.
2945
- */
2946
- readonly redirectUri: RedirectUri;
2947
- /**
2948
- * Recommended to leave undefined. Used to change the CoinList environment;
2949
- * default is production.
2950
- */
2951
- readonly baseUrl?: string;
2952
- /**
2953
- * Recommended to leave undefined. Overrides the base URL of the public
2954
- * token registry backing `coinlist.tokens`; default is the production
2955
- * registry.
2956
- */
2957
- readonly tokensBaseUrl?: string;
2958
- /**
2959
- * Where the SDK reports what it is doing. **Omit it and the SDK logs nothing
2960
- * at all** - no `console` fallback, at any level, on any codepath. Supply
2961
- * one and every request, every classified failure and every hook state
2962
- * transition is reported at the level your logger asks for.
2963
- *
2964
- * Absent, the SDK says nothing at all - there is no fallback to `console`,
2965
- * at any level, on any codepath.
2966
- *
2967
- * **Running the SDK's logging in production is not advised.** The safest
2968
- * posture is to leave this undefined outside development, staging and
2969
- * incident reproduction: a seam that emits nothing cannot disclose anything,
2970
- * and that property does not depend on the SDK continuing to get redaction
2971
- * right.
2972
- *
2973
- * If you do run one there, run it at `'info'` or above and know what that
2974
- * does and does not buy you. Those levels are **redacted by construction**:
2975
- * they carry only SDK-authored classification and server-authored
2976
- * identifiers, and the type system holds that line rather than a convention -
2977
- * an event at those levels accepts scalar fields only, so a body, a DTO or
2978
- * an operation's parameters cannot be put on one. What the SDK does **not**
2979
- * give you is a warranty that the result is safe for your environment. The
2980
- * mechanism is checkable and stated; the conclusion depends on your sink,
2981
- * your retention and your threat model, and it is yours to draw.
2982
- *
2983
- * **`'debug'` is not.** It reports request and response bodies, full URLs,
2984
- * headers and operation parameters verbatim - bearer tokens, KYC answers,
2985
- * tax-document fields, wallet signatures - and **the SDK does not redact**.
2986
- * Run it on a developer's machine, in tests, and in beta or staging
2987
- * environments where the data flowing through is not real customer data.
2988
- * The shipped implementations make that structural: built with
2989
- * `isDev: false`, `'debug'` does not typecheck. Either way, filtering,
2990
- * redaction and retention at your sink are yours, not the SDK's.
2991
- *
2992
- * Every method you implement here **must be total**: the SDK calls them on
2993
- * the codepath of the work they report and does not catch them, so a logger
2994
- * that throws fails the operation it was describing.
2995
- *
2996
- * See {@link Logger} for the full contract, and {@link pinoClientLogger} or
2997
- * {@link pinoServerLogger} for a ready-made implementation over pino.
2998
- */
2999
- readonly logger?: Logger;
3000
- }
3001
-
3002
- export { type BuildOndoSellParams as $, AuthorizationCode as A, BlockchainAmount as B, CodeVerifier as C, TokenMetadata as D, type Erc20Namespace as E, type OfferType as F, Offer as G, RequirementStatusInfo as H, type RequirementType as I, type RequirementStatusValue as J, OfferOptionAddress as K, type Logger as L, RequirementId as M, type KycLevelName as N, OfferId as O, Participation as P, DocumentSubmission as Q, type RequirementsNamespace as R, type SuperstateSwapNamespace as S, type TokensNamespace as T, type UniversalNamespaceContext as U, type WalletChallengeType as V, type WalletError as W, type PinoLoggerOptions as X, OndoTradingStatus as Y, AssetDecimals as Z, type BuildOndoBuyParams as _, EthereumChain as a, MAX_ASSET_DECIMALS as a$, OndoQuote as a0, type OndoQuoteSize as a1, type TokenIdentifier as a2, OfferOptionAddressId as a3, TokenLogo as a4, type DebugEvent as a5, type FrontlineEventId as a6, HttpError as a7, type HttpResponse as a8, KycToken as a9, AssetCode as aA, Blockchain as aB, type BuildOndoSwapParamsCore as aC, Chain as aD, ClientId as aE, CodeChallenge as aF, ConnectExternalWalletParams as aG, type CreateKycTokenParams as aH, CreateParticipationParams as aI, CreateWalletOwnershipChallengeParams as aJ, Cursor as aK, type DocumentFormType as aL, type DocumentSubmissionStatus as aM, type DocumentType as aN, ETHEREUM_CHAINS as aO, Erc20NamespaceImpl as aP, FaqItem as aQ, type GetOndoQuoteParams as aR, type GetOndoTradingStatusParams as aS, type GetSwapAuthorizationParams as aT, type GetSwapPreviewParams as aU, type GetTokenAllowanceParams as aV, type GetTokenBalanceParams as aW, HexEncodedTransactionData as aX, Iso2CountryCode as aY, Link as aZ, type ListOptionAddressesParams as a_, type LogBinding as aa, type LogBindings as ab, type LogCause as ac, type LogLevel as ad, type LogScope as ae, type LogValue as af, type ProductionLogLevel as ag, RedactedWalletError as ah, type RequestId as ai, type SafeEvent as aj, type SafeFields as ak, type UnredactedFields as al, OAuthSession as am, ClientCredentialsOAuth as an, ClientSecret as ao, type Sender as ap, PaginationParams as aq, PaginatedResponse as ar, DecimalString as as, SwapStatus as at, type Uint256 as au, KnownAssetSymbol as av, type Newtype as aw, type AllowWalletParams as ax, AllowWalletResponse as ay, Asset as az, EvmContractAddress as b, MAX_UINT_256 as b0, Milestone as b1, OAuthRefreshToken as b2, OfferOption as b3, OfferOptionSlug as b4, OfferSlug as b5, OfferToken as b6, OffersNamespaceImpl as b7, type OndoQuoteDuration as b8, type OndoSellOutcome as b9, TokenLogoUrl as bA, type TokenRole as bB, TokensNamespaceImpl as bC, type Tx as bD, WalletAddress as bE, WalletOwnershipChallenge as bF, type WalletProtocol as bG, WalletsNamespaceImpl as bH, apiErrorCode as bI, assertUint256 as bJ, isChain as bK, parseUint256 as bL, PKCEState as ba, type PaginatedResponseDto as bb, ParticipationId as bc, type ParticipationStatus as bd, ParticipationsPaginationParams as be, Pii as bf, PiiAddress as bg, PiiJurisdiction as bh, type PiiKind as bi, type QueryParamValue as bj, type QueryParamValues as bk, RedirectUri as bl, type RemoveOptionAddressParams as bm, type RequirementActionNeededReason as bn, SOLANA_CHAINS as bo, STABLE_DECIMALS as bp, SolanaChain as bq, type SubmitDocumentParams as br, SwapAuthorization as bs, type SwapContractRef as bt, SwapPreview as bu, TermItem as bv, Ticker as bw, TokenAllowance as bx, TokenBalance as by, type TokenLogoImage as bz, type CoinListTokenSaleNamespace as c, OfferOptionId as d, AssetId as e, CoinListTokenSaleNamespaceImpl as f, type OndoNamespace as g, AssetSymbol as h, OfferSwapContract as i, OndoBuyTransaction as j, OndoSellTransaction as k, type OndoSwapTransactionCore as l, type OrderBookSide as m, OndoNamespaceImpl as n, type WalletsNamespace as o, Bps as p, EvmWalletAddress as q, SuperstateSwapNamespaceImpl as r, Requirement as s, RequirementsNamespaceImpl as t, type Config as u, type OAuthAccessToken as v, type OffersNamespace as w, StablecoinSymbol as x, type Erc20Asset as y, OfferDetail as z };
3176
+ export { type BuildOndoSellParams as $, AuthorizationCode as A, BlockchainAmount as B, CodeVerifier as C, TokenMetadata as D, type Erc20Namespace as E, type OfferType as F, Offer as G, RequirementStatusInfo as H, type RequirementType as I, type RequirementStatusValue as J, OfferOptionAddress as K, type Logger as L, RequirementId as M, type KycLevelName as N, OfferId as O, Participation as P, DocumentSubmission as Q, type RequirementsNamespace as R, type SuperstateSwapNamespace as S, type TokensNamespace as T, type UniversalNamespaceContext as U, type WalletChallengeType as V, type WalletError as W, type PinoLoggerOptions as X, OndoTradingStatus as Y, AssetDecimals as Z, type BuildOndoBuyParams as _, EthereumChain as a, Link as a$, OndoQuote as a0, type OndoQuoteSize as a1, type TokenIdentifier as a2, OfferOptionAddressId as a3, TokenLogo as a4, type DebugEvent as a5, type FrontlineEventId as a6, HttpError as a7, type HttpResponse as a8, KycToken as a9, Asset as aA, AssetCode as aB, Blockchain as aC, type BuildOndoSwapParamsCore as aD, Chain as aE, ClientId as aF, CodeChallenge as aG, ConnectExternalWalletParams as aH, type CreateKycTokenParams as aI, CreateParticipationParams as aJ, CreateWalletOwnershipChallengeParams as aK, Cursor as aL, type DocumentFormType as aM, type DocumentSubmissionStatus as aN, type DocumentType as aO, ETHEREUM_CHAINS as aP, Erc20NamespaceImpl as aQ, FaqItem as aR, type GetOndoQuoteParams as aS, type GetOndoTradingStatusParams as aT, type GetSwapAuthorizationParams as aU, type GetSwapPreviewParams as aV, type GetTokenAllowanceParams as aW, type GetTokenBalanceParams as aX, HexEncodedTransactionData as aY, Isin as aZ, Iso2CountryCode as a_, type LogBinding as aa, type LogBindings as ab, type LogCause as ac, type LogLevel as ad, type LogScope as ae, type LogValue as af, type ProductionLogLevel as ag, RedactedWalletError as ah, type RequestId as ai, type RpcFailureReason as aj, type SafeEvent as ak, type SafeFields as al, type UnredactedFields as am, OAuthSession as an, ClientCredentialsOAuth as ao, ClientSecret as ap, type Sender as aq, PaginationParams as ar, PaginatedResponse as as, DecimalString as at, SwapStatus as au, type Uint256 as av, KnownAssetSymbol as aw, type Newtype as ax, type AllowWalletParams as ay, AllowWalletResponse as az, EvmContractAddress as b, type ListOptionAddressesParams as b0, MAX_ASSET_DECIMALS as b1, MAX_UINT_256 as b2, Milestone as b3, OAuthRefreshToken as b4, OfferOption as b5, OfferOptionSlug as b6, OfferSlug as b7, OfferToken as b8, OffersNamespaceImpl as b9, type TokenLogoImage as bA, TokenLogoUrl as bB, type TokenRole as bC, TokensNamespaceImpl as bD, type Tx as bE, WalletAddress as bF, WalletOwnershipChallenge as bG, type WalletProtocol as bH, WalletsNamespaceImpl as bI, apiErrorCode as bJ, assertUint256 as bK, isChain as bL, parseUint256 as bM, type OndoQuoteDuration as ba, type OndoSellOutcome as bb, PKCEState as bc, type PaginatedResponseDto as bd, ParticipationId as be, type ParticipationStatus as bf, ParticipationsPaginationParams as bg, PauseFlags as bh, Pii as bi, PiiAddress as bj, PiiJurisdiction as bk, type PiiKind as bl, type QueryParamValue as bm, type QueryParamValues as bn, RedirectUri as bo, type RemoveOptionAddressParams as bp, type RequirementActionNeededReason as bq, type RpcConfig as br, SOLANA_CHAINS as bs, STABLE_DECIMALS as bt, SolanaChain as bu, type SubmitDocumentParams as bv, type SwapContractRef as bw, SwapPreview as bx, TermItem as by, Ticker as bz, type CoinListTokenSaleNamespace as c, OfferOptionId as d, AssetId as e, CoinListTokenSaleNamespaceImpl as f, type OndoNamespace as g, AssetSymbol as h, OfferSwapContract as i, OndoBuyTransaction as j, OndoSellTransaction as k, type OndoSwapTransactionCore as l, type OrderBookSide as m, OndoNamespaceImpl as n, type WalletsNamespace as o, Bps as p, EvmWalletAddress as q, SuperstateSwapNamespaceImpl as r, Requirement as s, RequirementsNamespaceImpl as t, type Config as u, type OAuthAccessToken as v, type OffersNamespace as w, StablecoinSymbol as x, type Erc20Asset as y, OfferDetail as z };