@coinlist-co/react 0.12.1-rc.c2b6ba5 → 0.12.1-rc.e183ffd
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/dist/{chunk-F6WGUKZC.js → chunk-DCW7NQXH.js} +129 -3
- package/dist/chunk-DCW7NQXH.js.map +1 -0
- package/dist/{chunk-6CQHDASY.js → chunk-MOE5S6CE.js} +1354 -257
- package/dist/chunk-MOE5S6CE.js.map +1 -0
- package/dist/{chunk-ZFBEI3BW.js → chunk-ONLH57LF.js} +20 -330
- package/dist/chunk-ONLH57LF.js.map +1 -0
- package/dist/client/index.cjs +8779 -7816
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +143 -69
- package/dist/client/index.d.ts +143 -69
- package/dist/client/index.js +4177 -4109
- package/dist/client/index.js.map +1 -1
- package/dist/{collections-aCv-Wr2a.d.ts → collections-Biy3pQQL.d.cts} +1 -1
- package/dist/{collections-DOm9VKVm.d.cts → collections-JfNDG8Tc.d.ts} +1 -1
- package/dist/server/index.cjs +1463 -260
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +5 -3
- package/dist/server/index.js.map +1 -1
- package/dist/{config-DIaFzrMW.d.cts → tokens-namespace-CIWBtgt2.d.cts} +529 -230
- package/dist/{config-DIaFzrMW.d.ts → tokens-namespace-CIWBtgt2.d.ts} +529 -230
- package/dist/universal/index.cjs +1258 -478
- package/dist/universal/index.cjs.map +1 -1
- package/dist/universal/index.d.cts +427 -45
- package/dist/universal/index.d.ts +427 -45
- package/dist/universal/index.js +20 -14
- package/package.json +1 -1
- package/dist/chunk-6CQHDASY.js.map +0 -1
- package/dist/chunk-F6WGUKZC.js.map +0 -1
- 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<
|
|
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<
|
|
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<
|
|
1069
|
-
getBalance(params: GetTokenBalanceParams): Promise<
|
|
1126
|
+
getAllowance(params: GetTokenAllowanceParams): Promise<Uint256>;
|
|
1127
|
+
getBalance(params: GetTokenBalanceParams): Promise<Uint256>;
|
|
1070
1128
|
}
|
|
1071
1129
|
|
|
1072
1130
|
/**
|
|
@@ -1158,16 +1216,51 @@ type InternalDebugEvent = {
|
|
|
1158
1216
|
* handling it becomes a compile error.
|
|
1159
1217
|
*/
|
|
1160
1218
|
type OfferTypeDto = 'coinlist::token_sale' | 'superstate::swap' | 'ondo::swap';
|
|
1161
|
-
|
|
1219
|
+
/**
|
|
1220
|
+
* One variant per {@link OfferTypeDto}, mirroring frontline#1365, which keys
|
|
1221
|
+
* `GET /v1/offers` on `type`. Read `type` first: it decides which of the
|
|
1222
|
+
* fields below mean anything.
|
|
1223
|
+
*/
|
|
1224
|
+
type OfferDto = CoinListTokenSaleOfferDto | SuperstateSwapOfferDto | OndoSwapOfferDto;
|
|
1225
|
+
type OfferBaseDto = {
|
|
1162
1226
|
id: string;
|
|
1163
1227
|
slug: string;
|
|
1164
|
-
|
|
1228
|
+
ends_at: string | null;
|
|
1229
|
+
tokens: OfferTokenDto[];
|
|
1230
|
+
};
|
|
1231
|
+
/**
|
|
1232
|
+
* A curated sale window and the hand-authored copy that goes with it. Required
|
|
1233
|
+
* on every variant that runs such a campaign, which is every one but Ondo.
|
|
1234
|
+
*/
|
|
1235
|
+
type OfferEditorialDto = {
|
|
1165
1236
|
tagline: string;
|
|
1166
1237
|
banner_url: string;
|
|
1167
|
-
logo_url: string;
|
|
1168
1238
|
starts_at: string;
|
|
1169
|
-
|
|
1170
|
-
|
|
1239
|
+
};
|
|
1240
|
+
/**
|
|
1241
|
+
* What an Ondo swap sends in place of {@link OfferEditorialDto}. It trades
|
|
1242
|
+
* continuously and runs no campaign, so the keys arrive as `null` and carry
|
|
1243
|
+
* nothing. Declared so a fixture can describe the real payload; no `fromDto`
|
|
1244
|
+
* reads them.
|
|
1245
|
+
*/
|
|
1246
|
+
type OfferNoEditorialDto = {
|
|
1247
|
+
tagline: null;
|
|
1248
|
+
banner_url: null;
|
|
1249
|
+
starts_at: null;
|
|
1250
|
+
};
|
|
1251
|
+
type CoinListTokenSaleOfferDto = OfferBaseDto & OfferEditorialDto & {
|
|
1252
|
+
type: 'coinlist::token_sale';
|
|
1253
|
+
logo_url: string;
|
|
1254
|
+
};
|
|
1255
|
+
type SuperstateSwapOfferDto = OfferBaseDto & OfferEditorialDto & {
|
|
1256
|
+
type: 'superstate::swap';
|
|
1257
|
+
/** Publishing a swap does not require anyone to upload artwork for it. */
|
|
1258
|
+
logo_url: string | null;
|
|
1259
|
+
};
|
|
1260
|
+
type OndoSwapOfferDto = OfferBaseDto & OfferNoEditorialDto & {
|
|
1261
|
+
type: 'ondo::swap';
|
|
1262
|
+
/** Publishing a swap does not require anyone to upload artwork for it. */
|
|
1263
|
+
logo_url: string | null;
|
|
1171
1264
|
};
|
|
1172
1265
|
type OfferTokenDto = {
|
|
1173
1266
|
role: 'funding' | 'distribution' | 'swap';
|
|
@@ -1180,19 +1273,62 @@ declare const OfferId: (value: string) => OfferId;
|
|
|
1180
1273
|
type OfferSlug = Newtype<string, 'OfferSlug'>;
|
|
1181
1274
|
declare const OfferSlug: (value: string) => OfferSlug;
|
|
1182
1275
|
type OfferType = OfferTypeDto;
|
|
1183
|
-
|
|
1276
|
+
declare const isOfferType: (value: string) => value is OfferType;
|
|
1277
|
+
type OfferBase = {
|
|
1184
1278
|
id: OfferId;
|
|
1185
1279
|
slug: OfferSlug;
|
|
1186
|
-
|
|
1280
|
+
endsAt: Date | null;
|
|
1281
|
+
tokens: OfferToken[];
|
|
1282
|
+
};
|
|
1283
|
+
type CoinListTokenSaleOffer = OfferBase & OfferEditorial & {
|
|
1284
|
+
type: 'coinlist::token_sale';
|
|
1285
|
+
logoUrl: string;
|
|
1286
|
+
};
|
|
1287
|
+
type SuperstateSwapOffer = OfferBase & OfferEditorial & {
|
|
1288
|
+
type: 'superstate::swap';
|
|
1289
|
+
/** Null when nobody has uploaded artwork: a swap publishes without it. */
|
|
1290
|
+
logoUrl: string | null;
|
|
1291
|
+
};
|
|
1292
|
+
type OndoSwapOffer = OfferBase & {
|
|
1293
|
+
type: 'ondo::swap';
|
|
1294
|
+
/** Null when nobody has uploaded artwork: a swap publishes without it. */
|
|
1295
|
+
logoUrl: string | null;
|
|
1296
|
+
};
|
|
1297
|
+
/**
|
|
1298
|
+
* A curated sale window and the hand-authored copy that goes with it. Every
|
|
1299
|
+
* variant that runs such a campaign carries all three, validated; an Ondo swap
|
|
1300
|
+
* trades continuously, runs none, and carries none.
|
|
1301
|
+
*/
|
|
1302
|
+
type OfferEditorial = {
|
|
1187
1303
|
tagline: string;
|
|
1188
1304
|
bannerUrl: string;
|
|
1189
|
-
logoUrl: string;
|
|
1190
1305
|
startsAt: Date;
|
|
1191
|
-
endsAt: Date | null;
|
|
1192
|
-
tokens: OfferToken[];
|
|
1193
1306
|
};
|
|
1307
|
+
declare const OfferEditorial: {
|
|
1308
|
+
/**
|
|
1309
|
+
* `model` prefixes the field in the error (`'Offer'`, `'OfferDetail'`), so
|
|
1310
|
+
* the same three checks name the payload that failed them.
|
|
1311
|
+
*/
|
|
1312
|
+
fromDto: (dto: OfferEditorialDto, model: string) => OfferEditorial;
|
|
1313
|
+
};
|
|
1314
|
+
/**
|
|
1315
|
+
* An offer as `GET /v1/offers` lists it: a union on {@link OfferType}, each
|
|
1316
|
+
* variant carrying only the fields that mean something for it. Narrow on
|
|
1317
|
+
* `type` before reading anything beyond {@link OfferBase} - an Ondo swap has
|
|
1318
|
+
* no `startsAt` to read, and the compiler says so.
|
|
1319
|
+
*/
|
|
1320
|
+
type Offer = CoinListTokenSaleOffer | SuperstateSwapOffer | OndoSwapOffer;
|
|
1194
1321
|
declare const Offer: {
|
|
1195
1322
|
fromDto: (dto: OfferDto) => Offer;
|
|
1323
|
+
/**
|
|
1324
|
+
* Maps a page of offers, dropping every offer whose `type` this SDK does not
|
|
1325
|
+
* name. The same reasoning as {@link OfferToken.listFromDto}: a plain `.map`
|
|
1326
|
+
* would throw out of `fromDto` and, through `PaginatedResponse.fromDto`,
|
|
1327
|
+
* reject the whole page, so one offer of an unknown type would blank the
|
|
1328
|
+
* grid for every offer beside it. A single offer fetched by id still
|
|
1329
|
+
* throws, because there is nothing beside it to keep.
|
|
1330
|
+
*/
|
|
1331
|
+
listFromDto: (dtos: OfferDto[]) => Offer[];
|
|
1196
1332
|
};
|
|
1197
1333
|
type TokenRole = 'funding' | 'distribution' | 'swap';
|
|
1198
1334
|
type OfferToken = {
|
|
@@ -1237,6 +1373,13 @@ interface PaginatedResponse<T> {
|
|
|
1237
1373
|
}
|
|
1238
1374
|
declare const PaginatedResponse: {
|
|
1239
1375
|
fromDto: <A, B>(dto: PaginatedResponseDto<A>, itemMapper: (item: A) => B) => PaginatedResponse<B>;
|
|
1376
|
+
/**
|
|
1377
|
+
* For a mapper that decides the page as a whole - one that drops items it
|
|
1378
|
+
* cannot map, such as `Offer.listFromDto` - rather than item by item. The
|
|
1379
|
+
* cursors are the wire's either way: dropping an item changes what the
|
|
1380
|
+
* page holds, not where the next page starts.
|
|
1381
|
+
*/
|
|
1382
|
+
fromDtoPage: <A, B>(dto: PaginatedResponseDto<A>, pageMapper: (items: A[]) => B[]) => PaginatedResponse<B>;
|
|
1240
1383
|
};
|
|
1241
1384
|
/**
|
|
1242
1385
|
* Cursor-based pagination input used when requesting paginated API resources.
|
|
@@ -1298,12 +1441,41 @@ type CreateParticipationDto = {
|
|
|
1298
1441
|
approval_transaction_hash: string | null | undefined;
|
|
1299
1442
|
};
|
|
1300
1443
|
|
|
1301
|
-
|
|
1444
|
+
/**
|
|
1445
|
+
* One variant per `OfferTypeDto`, the same split as `OfferDto` with what
|
|
1446
|
+
* `GET /v1/offers/:id` adds on top. Read `type` first.
|
|
1447
|
+
*/
|
|
1448
|
+
type OfferDetailDto = CoinListTokenSaleOfferDetailDto | SuperstateSwapOfferDetailDto | OndoSwapOfferDetailDto;
|
|
1449
|
+
type CoinListTokenSaleOfferDetailDto = OfferDetailBaseDto & OfferEditorialDto & OfferDetailNoSwapContractsDto & {
|
|
1450
|
+
type: 'coinlist::token_sale';
|
|
1451
|
+
logo_url: string;
|
|
1452
|
+
};
|
|
1453
|
+
type SuperstateSwapOfferDetailDto = OfferDetailBaseDto & OfferEditorialDto & OfferDetailNoSwapContractsDto & {
|
|
1454
|
+
type: 'superstate::swap';
|
|
1455
|
+
logo_url: string | null;
|
|
1456
|
+
};
|
|
1457
|
+
type OndoSwapOfferDetailDto = OfferDetailBaseDto & OfferNoEditorialDto & {
|
|
1458
|
+
type: 'ondo::swap';
|
|
1459
|
+
logo_url: string | null;
|
|
1460
|
+
/**
|
|
1461
|
+
* Every chain this offer swaps on, with the contract each settles
|
|
1462
|
+
* through. `[]` is an answer - "swaps nowhere" - and a missing key is not.
|
|
1463
|
+
*/
|
|
1464
|
+
swap_contracts: OfferDetailSwapContractDto[];
|
|
1465
|
+
};
|
|
1466
|
+
/**
|
|
1467
|
+
* An offer that does not settle through a CoinList swap contract sends `[]`
|
|
1468
|
+
* or no key at all, and either way there is nothing to read. Declared so a
|
|
1469
|
+
* fixture can describe the real payload.
|
|
1470
|
+
*/
|
|
1471
|
+
type OfferDetailNoSwapContractsDto = {
|
|
1472
|
+
swap_contracts?: OfferDetailSwapContractDto[];
|
|
1473
|
+
};
|
|
1474
|
+
type OfferDetailBaseDto = {
|
|
1302
1475
|
asset: AssetDto;
|
|
1303
1476
|
faqs: OfferDetailFaqDto[];
|
|
1304
1477
|
funding_assets: AssetDto[];
|
|
1305
1478
|
tokens: OfferTokenDto[];
|
|
1306
|
-
swap_contracts?: OfferDetailSwapContractDto[];
|
|
1307
1479
|
id: string;
|
|
1308
1480
|
links: OfferDetailLinkDto[];
|
|
1309
1481
|
milestones: OfferDetailMilestoneDto[];
|
|
@@ -1311,15 +1483,20 @@ type OfferDetailDto = {
|
|
|
1311
1483
|
object: 'offer_details';
|
|
1312
1484
|
options: OfferDetailOptionDto[];
|
|
1313
1485
|
slug: string;
|
|
1314
|
-
type: OfferTypeDto;
|
|
1315
1486
|
terms: OfferDetailTermDto[];
|
|
1316
1487
|
about: string | null | undefined;
|
|
1317
|
-
banner_url: string;
|
|
1318
1488
|
category: string;
|
|
1319
1489
|
ends_at: string | null;
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1490
|
+
/** Issuer of the *token*, not of the security it tracks. Ondo offers only. */
|
|
1491
|
+
issuer: string | null;
|
|
1492
|
+
/** ISO 6166 id of the underlying security. Null when the supplier has none. */
|
|
1493
|
+
isin: string | null;
|
|
1494
|
+
/** The underlying's symbol on its venue (`QQQ`), never the token's (`QQQon`). */
|
|
1495
|
+
ticker: string | null;
|
|
1496
|
+
/** Supplier vocabulary (`Stock`, `ETF`). Open set — display, do not branch. */
|
|
1497
|
+
instrument_type: string | null;
|
|
1498
|
+
/** Venue the underlying lists on. Not served by the supplier; entered by hand. */
|
|
1499
|
+
listing_venue: string | null;
|
|
1323
1500
|
};
|
|
1324
1501
|
type OfferDetailFaqDto = {
|
|
1325
1502
|
answer: string | null;
|
|
@@ -1353,44 +1530,93 @@ type OfferDetailSwapContractDto = {
|
|
|
1353
1530
|
address: string;
|
|
1354
1531
|
};
|
|
1355
1532
|
|
|
1356
|
-
type
|
|
1357
|
-
declare const
|
|
1358
|
-
type OfferOptionSlug = Newtype<string, 'OfferOptionSlug'>;
|
|
1359
|
-
declare const OfferOptionSlug: (value: string) => OfferOptionSlug;
|
|
1533
|
+
type Ticker = Newtype<string, 'Ticker'>;
|
|
1534
|
+
declare const Ticker: (value: string) => Ticker;
|
|
1360
1535
|
/**
|
|
1361
|
-
*
|
|
1362
|
-
*
|
|
1536
|
+
* An ISO 6166 International Securities Identification Number, e.g.
|
|
1537
|
+
* `US0378331005`. Identifies the security itself, which is what makes it the
|
|
1538
|
+
* stable key across venues where a {@link Ticker} is not: the same security
|
|
1539
|
+
* trades under different tickers in different places, and the same ticker
|
|
1540
|
+
* means different securities in different places.
|
|
1363
1541
|
*
|
|
1364
|
-
*
|
|
1365
|
-
*
|
|
1366
|
-
*
|
|
1542
|
+
* Not validated on construction — the value comes from a supplier that has
|
|
1543
|
+
* already checked it, and a client-side check-digit test could only reject
|
|
1544
|
+
* data the SDK still has to display.
|
|
1367
1545
|
*/
|
|
1368
|
-
type
|
|
1369
|
-
|
|
1370
|
-
|
|
1546
|
+
type Isin = Newtype<string, 'Isin'>;
|
|
1547
|
+
declare const Isin: (value: string) => Isin;
|
|
1548
|
+
type OrderBookSide = 'buy' | 'sell';
|
|
1549
|
+
|
|
1550
|
+
type CoinListTokenSaleOfferDetail = OfferDetailBase & OfferEditorial & {
|
|
1551
|
+
type: 'coinlist::token_sale';
|
|
1552
|
+
logoUrl: string;
|
|
1371
1553
|
};
|
|
1372
|
-
|
|
1373
|
-
|
|
1554
|
+
type SuperstateSwapOfferDetail = OfferDetailBase & OfferEditorial & {
|
|
1555
|
+
type: 'superstate::swap';
|
|
1556
|
+
/** Null when nobody has uploaded artwork: a swap publishes without it. */
|
|
1557
|
+
logoUrl: string | null;
|
|
1374
1558
|
};
|
|
1375
|
-
type
|
|
1559
|
+
type OndoSwapOfferDetail = OfferDetailBase & {
|
|
1560
|
+
type: 'ondo::swap';
|
|
1561
|
+
/** Null when nobody has uploaded artwork: a swap publishes without it. */
|
|
1562
|
+
logoUrl: string | null;
|
|
1563
|
+
/**
|
|
1564
|
+
* Every chain this offer can be swapped on, with the CoinList contract each
|
|
1565
|
+
* settles through. Empty means it cannot be swapped anywhere.
|
|
1566
|
+
*/
|
|
1567
|
+
swapContracts: OfferSwapContract[];
|
|
1568
|
+
};
|
|
1569
|
+
type OfferDetailBase = {
|
|
1376
1570
|
id: OfferId;
|
|
1377
1571
|
slug: OfferSlug;
|
|
1378
|
-
type: OfferType;
|
|
1379
1572
|
name: string;
|
|
1380
1573
|
asset: Asset;
|
|
1381
1574
|
fundingAssets: Asset[];
|
|
1382
1575
|
tokens: OfferToken[];
|
|
1383
|
-
/**
|
|
1384
|
-
* Every chain this offer can be swapped on, with the CoinList contract each
|
|
1385
|
-
* settles through. Empty means it cannot be swapped anywhere.
|
|
1386
|
-
*/
|
|
1387
|
-
swapContracts: OfferSwapContract[];
|
|
1388
1576
|
about: string | null;
|
|
1389
|
-
tagline: string;
|
|
1390
|
-
bannerUrl: string;
|
|
1391
|
-
logoUrl: string;
|
|
1392
1577
|
category: string;
|
|
1393
|
-
|
|
1578
|
+
/**
|
|
1579
|
+
* The legal issuer of the *token*, e.g. `'Ondo Global Markets'`. The issuer
|
|
1580
|
+
* of the security it tracks is {@link OfferDetail.name} (`'Apple Inc.'`).
|
|
1581
|
+
* Null on offers with no single named issuer.
|
|
1582
|
+
*/
|
|
1583
|
+
issuer: string | null;
|
|
1584
|
+
/**
|
|
1585
|
+
* ISO 6166 identifier of the underlying security, e.g. `'US0378331005'`.
|
|
1586
|
+
* Null both on offers that tokenize no security and on the few that do but
|
|
1587
|
+
* whose supplier publishes no ISIN, so absence does not imply "not a
|
|
1588
|
+
* security".
|
|
1589
|
+
*/
|
|
1590
|
+
isin: Isin | null;
|
|
1591
|
+
/**
|
|
1592
|
+
* The underlying security's symbol on its listing venue, e.g. `'QQQ'`. This
|
|
1593
|
+
* is *not* the token's symbol — that is `asset.code` (`'QQQon'`). Null on
|
|
1594
|
+
* offers that tokenize no listed security.
|
|
1595
|
+
*/
|
|
1596
|
+
ticker: Ticker | null;
|
|
1597
|
+
/**
|
|
1598
|
+
* What kind of instrument the underlying is, as the supplier classifies it:
|
|
1599
|
+
* `'Stock'`, `'ETF'`. Distinct from {@link OfferDetail.category}, which is
|
|
1600
|
+
* the broader class the offer is grouped under (`'Equities'`) — this field
|
|
1601
|
+
* describes the single instrument, `category` describes the shelf it sits
|
|
1602
|
+
* on.
|
|
1603
|
+
*
|
|
1604
|
+
* An open set: the vocabulary belongs to the supplier and may grow without
|
|
1605
|
+
* notice, so render an unrecognized value rather than branching on it. Note
|
|
1606
|
+
* the supplier's spelling is its own — a common stock arrives as `'Stock'`.
|
|
1607
|
+
*/
|
|
1608
|
+
instrumentType: string | null;
|
|
1609
|
+
/**
|
|
1610
|
+
* The exchange the underlying security lists on, e.g. `'NASDAQ'`. Not
|
|
1611
|
+
* derivable from {@link OfferDetail.isin}, whose country prefix is the
|
|
1612
|
+
* country of issuance rather than the venue.
|
|
1613
|
+
*
|
|
1614
|
+
* Unlike the fields above, this one is recorded by hand rather than served
|
|
1615
|
+
* by the supplier, so it is null until someone records it — on a newly
|
|
1616
|
+
* listed offer that is the normal state, and it says nothing about whether
|
|
1617
|
+
* the offer tokenizes a security.
|
|
1618
|
+
*/
|
|
1619
|
+
listingVenue: string | null;
|
|
1394
1620
|
endsAt: Date | null;
|
|
1395
1621
|
faqs: FaqItem[];
|
|
1396
1622
|
links: Link[];
|
|
@@ -1398,6 +1624,32 @@ type OfferDetail = {
|
|
|
1398
1624
|
options: OfferOption[];
|
|
1399
1625
|
terms: TermItem[];
|
|
1400
1626
|
};
|
|
1627
|
+
type OfferOptionId = Newtype<string, 'OfferOptionId'>;
|
|
1628
|
+
declare const OfferOptionId: (value: string) => OfferOptionId;
|
|
1629
|
+
type OfferOptionSlug = Newtype<string, 'OfferOptionSlug'>;
|
|
1630
|
+
declare const OfferOptionSlug: (value: string) => OfferOptionSlug;
|
|
1631
|
+
/**
|
|
1632
|
+
* A chain an offer can be swapped on, with the CoinList contract the swap
|
|
1633
|
+
* settles through - the spender to approve before any quote exists.
|
|
1634
|
+
*
|
|
1635
|
+
* Carries no role, unlike {@link OfferToken}: there is one swap contract per
|
|
1636
|
+
* chain and it serves every Ondo asset on it, so which token is being traded
|
|
1637
|
+
* does not change the answer.
|
|
1638
|
+
*/
|
|
1639
|
+
type OfferSwapContract = {
|
|
1640
|
+
chain: Chain;
|
|
1641
|
+
address: EvmContractAddress;
|
|
1642
|
+
};
|
|
1643
|
+
declare const OfferSwapContract: {
|
|
1644
|
+
fromDto: (dto: OfferDetailSwapContractDto) => OfferSwapContract;
|
|
1645
|
+
};
|
|
1646
|
+
/**
|
|
1647
|
+
* An offer as `GET /v1/offers/:id` serves it: the same union on `type` as
|
|
1648
|
+
* {@link Offer}, each variant carrying only the fields that mean something
|
|
1649
|
+
* for it. Narrow on `type` before reading anything beyond
|
|
1650
|
+
* {@link OfferDetailBase}.
|
|
1651
|
+
*/
|
|
1652
|
+
type OfferDetail = CoinListTokenSaleOfferDetail | SuperstateSwapOfferDetail | OndoSwapOfferDetail;
|
|
1401
1653
|
declare const OfferDetail: {
|
|
1402
1654
|
fromDto: (dto: OfferDetailDto) => OfferDetail;
|
|
1403
1655
|
};
|
|
@@ -1570,10 +1822,6 @@ declare class CoinListTokenSaleNamespaceImpl implements CoinListTokenSaleNamespa
|
|
|
1570
1822
|
createParticipation(params: CreateParticipationParams): Promise<Participation>;
|
|
1571
1823
|
}
|
|
1572
1824
|
|
|
1573
|
-
type Ticker = Newtype<string, 'Ticker'>;
|
|
1574
|
-
declare const Ticker: (value: string) => Ticker;
|
|
1575
|
-
type OrderBookSide = 'buy' | 'sell';
|
|
1576
|
-
|
|
1577
1825
|
/**
|
|
1578
1826
|
* No `chain` on the read params: Ondo runs no sandbox, so every environment
|
|
1579
1827
|
* prices against Ondo production on Ethereum mainnet. Accepting a chain would
|
|
@@ -2230,6 +2478,105 @@ declare class OndoNamespaceImpl implements OndoNamespace {
|
|
|
2230
2478
|
buildSellTransaction(params: BuildOndoSellParams): Promise<OndoSellTransaction>;
|
|
2231
2479
|
}
|
|
2232
2480
|
|
|
2481
|
+
/**
|
|
2482
|
+
* Raw JSON models for the Superstate swap endpoints that are still backend
|
|
2483
|
+
* calls.
|
|
2484
|
+
*
|
|
2485
|
+
* The contract *reads* no longer have DTOs: the SDK calls `status()`,
|
|
2486
|
+
* `preview()`, `authorized()` and `outputToken()` on-chain through
|
|
2487
|
+
* `@/universal/api/rpc`, so their wire shape is the ABI rather than JSON.
|
|
2488
|
+
* Allow-listing a wallet stays here because it is a backend write, not a read.
|
|
2489
|
+
*/
|
|
2490
|
+
type AllowWalletResponseDto = {
|
|
2491
|
+
action: 'broadcast_transaction';
|
|
2492
|
+
to: string;
|
|
2493
|
+
data: string;
|
|
2494
|
+
} | {
|
|
2495
|
+
action: 'none';
|
|
2496
|
+
already_allowed: boolean;
|
|
2497
|
+
};
|
|
2498
|
+
|
|
2499
|
+
/**
|
|
2500
|
+
* A read-only quote for a swap: how much goes in, the protocol fee, and how
|
|
2501
|
+
* much would come out. All amounts are raw on-chain integers (uint256).
|
|
2502
|
+
*/
|
|
2503
|
+
type SwapPreview = {
|
|
2504
|
+
inputAmount: Uint256;
|
|
2505
|
+
fee: Uint256;
|
|
2506
|
+
outputAmount: Uint256;
|
|
2507
|
+
};
|
|
2508
|
+
declare const SwapPreview: {
|
|
2509
|
+
/** Maps the contract's `Preview { input, fee, output }` struct. */
|
|
2510
|
+
fromContract: (preview: {
|
|
2511
|
+
input: bigint;
|
|
2512
|
+
fee: bigint;
|
|
2513
|
+
output: bigint;
|
|
2514
|
+
}) => SwapPreview;
|
|
2515
|
+
};
|
|
2516
|
+
/**
|
|
2517
|
+
* The bitmask of operations a swap contract has paused, as `Operable.paused`
|
|
2518
|
+
* reports it. Each bit is one operation level; swapping is
|
|
2519
|
+
* {@link SWAP_LEVEL}.
|
|
2520
|
+
*
|
|
2521
|
+
* Meaningful only while the contract is paused, which is why it lives on that
|
|
2522
|
+
* arm of {@link SwapStatus} alone: an active contract has nothing paused, and
|
|
2523
|
+
* a stopped one is past caring which level was.
|
|
2524
|
+
*/
|
|
2525
|
+
type PauseFlags = Newtype<number, 'PauseFlags'>;
|
|
2526
|
+
declare const PauseFlags: (value: number) => PauseFlags;
|
|
2527
|
+
/**
|
|
2528
|
+
* The on-chain state of a swap contract, as `status()` reports it.
|
|
2529
|
+
*
|
|
2530
|
+
* - `active` - operating normally.
|
|
2531
|
+
* - `paused` - one or more operations are suspended, and may be resumed.
|
|
2532
|
+
* `pausedLevels` says which. **This does not by itself mean swapping is
|
|
2533
|
+
* down**: a contract can pause an unrelated operation and keep swapping.
|
|
2534
|
+
* Ask `isSwapAvailable` rather than reading the state.
|
|
2535
|
+
* - `stopped` - permanently halted, and cannot be reactivated.
|
|
2536
|
+
*/
|
|
2537
|
+
type SwapStatus = {
|
|
2538
|
+
state: 'active';
|
|
2539
|
+
} | {
|
|
2540
|
+
state: 'paused';
|
|
2541
|
+
pausedLevels: PauseFlags;
|
|
2542
|
+
} | {
|
|
2543
|
+
state: 'stopped';
|
|
2544
|
+
};
|
|
2545
|
+
declare const SwapStatus: {
|
|
2546
|
+
/**
|
|
2547
|
+
* Maps the contract's `Status { uint32 flags; State state }` struct, where
|
|
2548
|
+
* `State` is `0 = Active | 1 = Paused | 2 = Stopped`.
|
|
2549
|
+
*
|
|
2550
|
+
* `flags` is carried onto the `paused` arm only. On the other two the
|
|
2551
|
+
* contract sets it to a self-identifying marker rather than to information -
|
|
2552
|
+
* so repeating it would invite a caller to read meaning into a constant.
|
|
2553
|
+
*
|
|
2554
|
+
* @throws ValidationError on a `state` outside the enum. A contract that has
|
|
2555
|
+
* grown a fourth state is one the SDK does not model, and guessing `active`
|
|
2556
|
+
* would let a halted swap read as a live one.
|
|
2557
|
+
*/
|
|
2558
|
+
fromContract: (status: {
|
|
2559
|
+
flags: number;
|
|
2560
|
+
state: number;
|
|
2561
|
+
}) => SwapStatus;
|
|
2562
|
+
};
|
|
2563
|
+
/**
|
|
2564
|
+
* The backend's response to an allow-wallet request. Either the caller must
|
|
2565
|
+
* broadcast an on-chain transaction to complete allow-listing, or nothing is
|
|
2566
|
+
* required because the wallet is already allowed.
|
|
2567
|
+
*/
|
|
2568
|
+
type AllowWalletResponse = {
|
|
2569
|
+
action: 'broadcast_transaction';
|
|
2570
|
+
to: EvmContractAddress;
|
|
2571
|
+
data: HexEncodedTransactionData;
|
|
2572
|
+
} | {
|
|
2573
|
+
action: 'none';
|
|
2574
|
+
alreadyAllowed: boolean;
|
|
2575
|
+
};
|
|
2576
|
+
declare const AllowWalletResponse: {
|
|
2577
|
+
fromDto: (dto: AllowWalletResponseDto) => AllowWalletResponse;
|
|
2578
|
+
};
|
|
2579
|
+
|
|
2233
2580
|
/** Parameters shared by contract reads scoped to a chain. */
|
|
2234
2581
|
type SwapContractRef = {
|
|
2235
2582
|
contractAddress: EvmContractAddress;
|
|
@@ -2251,30 +2598,46 @@ type AllowWalletParams = {
|
|
|
2251
2598
|
|
|
2252
2599
|
/**
|
|
2253
2600
|
* Read/write operations for the on-chain swap flow: quoting a swap, inspecting
|
|
2254
|
-
* contract state,
|
|
2255
|
-
*
|
|
2601
|
+
* contract state, and proving/allow-listing wallet ownership.
|
|
2602
|
+
*
|
|
2603
|
+
* Every read here is a contract call the SDK makes itself. By default those go
|
|
2604
|
+
* through CoinList's authenticated JSON-RPC proxy, so a logged-out caller gets
|
|
2605
|
+
* the proxy's `401` - surfaced as a viem error wrapping the SDK's `HttpError`,
|
|
2606
|
+
* not as `NotAuthenticatedError`, since viem re-wraps whatever a `Transport`
|
|
2607
|
+
* throws. Point `Config.rpc` at your own node for this chain and no CoinList
|
|
2608
|
+
* session is involved at all. `allowWallet` is the exception: it is a backend
|
|
2609
|
+
* write and always needs one, and throws `NotAuthenticatedError` without.
|
|
2256
2610
|
*/
|
|
2257
2611
|
interface SuperstateSwapNamespace {
|
|
2258
2612
|
/**
|
|
2259
2613
|
* Checks whether a wallet is authorized to swap against the given contract.
|
|
2260
2614
|
*/
|
|
2261
|
-
getAuthorization(params: GetSwapAuthorizationParams): Promise<
|
|
2615
|
+
getAuthorization(params: GetSwapAuthorizationParams): Promise<boolean>;
|
|
2262
2616
|
/**
|
|
2263
2617
|
* Fetches a read-only quote for swapping `amount` of `inputToken`.
|
|
2618
|
+
*
|
|
2619
|
+
* The contract reverts rather than quoting when it is stopped, or when
|
|
2620
|
+
* `inputToken` is not one it accepts, so this surfaces a viem
|
|
2621
|
+
* `ContractFunctionRevertedError` naming the contract's own error. Check
|
|
2622
|
+
* {@link getStatus} first if you would rather not provoke one.
|
|
2264
2623
|
*/
|
|
2265
2624
|
getPreview(params: GetSwapPreviewParams): Promise<SwapPreview>;
|
|
2266
2625
|
/**
|
|
2267
|
-
* Reads the current on-chain state of a swap contract.
|
|
2626
|
+
* Reads the current on-chain state of a swap contract. See
|
|
2627
|
+
* {@link isSwapAvailable} before concluding that a `paused` contract cannot
|
|
2628
|
+
* swap - the two are not the same question.
|
|
2268
2629
|
*/
|
|
2269
2630
|
getStatus(params: SwapContractRef): Promise<SwapStatus>;
|
|
2270
2631
|
/**
|
|
2271
|
-
* Reads the ERC-20 output token a swap contract pays out.
|
|
2632
|
+
* Reads the ERC-20 output token a swap contract pays out, with its metadata.
|
|
2272
2633
|
*/
|
|
2273
2634
|
getOutputToken(params: SwapContractRef): Promise<Erc20Asset>;
|
|
2274
2635
|
/**
|
|
2275
2636
|
* Submits a signed wallet-ownership challenge to allow-list the wallet for
|
|
2276
2637
|
* an offer, identified by its offer id. Obtain the challenge from
|
|
2277
2638
|
* `WalletsNamespace.createOwnershipChallenge`.
|
|
2639
|
+
*
|
|
2640
|
+
* @throws NotAuthenticatedError without a logged-in user.
|
|
2278
2641
|
*/
|
|
2279
2642
|
allowWallet(params: AllowWalletParams): Promise<AllowWalletResponse>;
|
|
2280
2643
|
}
|
|
@@ -2282,7 +2645,7 @@ declare class SuperstateSwapNamespaceImpl implements SuperstateSwapNamespace {
|
|
|
2282
2645
|
private readonly ctx;
|
|
2283
2646
|
protected readonly log: InternalLogger;
|
|
2284
2647
|
constructor(ctx: UniversalNamespaceContext);
|
|
2285
|
-
getAuthorization(params: GetSwapAuthorizationParams): Promise<
|
|
2648
|
+
getAuthorization(params: GetSwapAuthorizationParams): Promise<boolean>;
|
|
2286
2649
|
getPreview(params: GetSwapPreviewParams): Promise<SwapPreview>;
|
|
2287
2650
|
getStatus(params: SwapContractRef): Promise<SwapStatus>;
|
|
2288
2651
|
getOutputToken(params: SwapContractRef): Promise<Erc20Asset>;
|
|
@@ -2935,68 +3298,4 @@ declare class TokensNamespaceImpl implements TokensNamespace {
|
|
|
2935
3298
|
list(chain?: EthereumChain): Promise<TokenMetadata[]>;
|
|
2936
3299
|
}
|
|
2937
3300
|
|
|
2938
|
-
|
|
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 };
|
|
3301
|
+
export { OndoTradingStatus as $, AuthorizationCode as A, BlockchainAmount as B, CodeVerifier as C, TokenMetadata as D, type Erc20Namespace as E, type OfferType as F, type OndoSwapOfferDetail as G, type CoinListTokenSaleOfferDetail as H, type SuperstateSwapOfferDetail as I, Offer as J, RequirementStatusInfo as K, type Logger as L, type RequirementType as M, type RequirementStatusValue as N, OfferId as O, Participation as P, OfferOptionAddress as Q, type RequirementsNamespace as R, type SuperstateSwapNamespace as S, type TokensNamespace as T, type UniversalNamespaceContext as U, RequirementId as V, type WalletError as W, type KycLevelName as X, DocumentSubmission as Y, type WalletChallengeType as Z, type PinoLoggerOptions as _, EthereumChain as a, type GetTokenBalanceParams as a$, AssetDecimals as a0, type BuildOndoBuyParams as a1, type BuildOndoSellParams as a2, OndoQuote as a3, type OndoQuoteSize as a4, type TokenIdentifier as a5, OfferOptionAddressId as a6, TokenLogo as a7, type DebugEvent as a8, type FrontlineEventId as a9, type Newtype as aA, type AllowWalletParams as aB, AllowWalletResponse as aC, Asset as aD, AssetCode as aE, Blockchain as aF, type BuildOndoSwapParamsCore as aG, Chain as aH, ClientId as aI, CodeChallenge as aJ, type CoinListTokenSaleOffer as aK, ConnectExternalWalletParams as aL, type CreateKycTokenParams as aM, CreateParticipationParams as aN, CreateWalletOwnershipChallengeParams as aO, Cursor as aP, type DocumentFormType as aQ, type DocumentSubmissionStatus as aR, type DocumentType as aS, ETHEREUM_CHAINS as aT, Erc20NamespaceImpl as aU, FaqItem as aV, type GetOndoQuoteParams as aW, type GetOndoTradingStatusParams as aX, type GetSwapAuthorizationParams as aY, type GetSwapPreviewParams as aZ, type GetTokenAllowanceParams as a_, HttpError as aa, type HttpResponse as ab, KycToken as ac, type LogBinding as ad, type LogBindings as ae, type LogCause as af, type LogLevel as ag, type LogScope as ah, type LogValue as ai, type ProductionLogLevel as aj, RedactedWalletError as ak, type RequestId as al, type RpcFailureReason as am, type SafeEvent as an, type SafeFields as ao, type UnredactedFields as ap, OAuthSession as aq, ClientCredentialsOAuth as ar, ClientSecret as as, type Sender as at, PaginationParams as au, PaginatedResponse as av, DecimalString as aw, SwapStatus as ax, type Uint256 as ay, KnownAssetSymbol as az, EvmContractAddress as b, HexEncodedTransactionData as b0, Isin as b1, Iso2CountryCode as b2, Link as b3, type ListOptionAddressesParams as b4, MAX_ASSET_DECIMALS as b5, MAX_UINT_256 as b6, Milestone as b7, OAuthRefreshToken as b8, type OfferBase as b9, SOLANA_CHAINS as bA, STABLE_DECIMALS as bB, SolanaChain as bC, type SubmitDocumentParams as bD, type SuperstateSwapOffer as bE, type SwapContractRef as bF, SwapPreview as bG, TermItem as bH, Ticker as bI, type TokenLogoImage as bJ, TokenLogoUrl as bK, type TokenRole as bL, TokensNamespaceImpl as bM, type Tx as bN, WalletAddress as bO, WalletOwnershipChallenge as bP, type WalletProtocol as bQ, WalletsNamespaceImpl as bR, apiErrorCode as bS, assertUint256 as bT, isChain as bU, isOfferType as bV, parseUint256 as bW, type OfferDetailBase as ba, OfferEditorial as bb, OfferOption as bc, OfferOptionSlug as bd, OfferSlug as be, OfferToken as bf, OffersNamespaceImpl as bg, type OndoQuoteDuration as bh, type OndoSellOutcome as bi, type OndoSwapOffer as bj, PKCEState as bk, type PaginatedResponseDto as bl, ParticipationId as bm, type ParticipationStatus as bn, ParticipationsPaginationParams as bo, PauseFlags as bp, Pii as bq, PiiAddress as br, PiiJurisdiction as bs, type PiiKind as bt, type QueryParamValue as bu, type QueryParamValues as bv, RedirectUri as bw, type RemoveOptionAddressParams as bx, type RequirementActionNeededReason as by, type RpcConfig 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 };
|