@coinlist-co/react 0.12.2-rc.bc20f5b → 0.12.2-rc.e1f6c82
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-3WW5FLT7.js → chunk-EKLUJZ7T.js} +10 -10
- package/dist/chunk-EKLUJZ7T.js.map +1 -0
- package/dist/{chunk-C6GF7MDF.js → chunk-GIE4UWB3.js} +680 -619
- package/dist/chunk-GIE4UWB3.js.map +1 -0
- package/dist/chunk-MJ6YXZWH.js +22 -0
- package/dist/chunk-MJ6YXZWH.js.map +1 -0
- package/dist/{chunk-IZJ4JSSC.js → chunk-PIOQA6HW.js} +173 -234
- package/dist/chunk-PIOQA6HW.js.map +1 -0
- package/dist/client/index.d.ts +2414 -5239
- package/dist/client/index.js +683 -788
- package/dist/client/index.js.map +1 -1
- package/dist/server/index.d.ts +2 -32
- package/dist/server/index.js +6 -4
- package/dist/server/index.js.map +1 -1
- package/dist/{time-CVZpAkGY.d.cts → time-Bbqlt2x7.d.ts} +1907 -3183
- package/dist/{token-registry-snapshot-BkwA8KmD.d.ts → token-registry-snapshot-DttZXGvY.d.ts} +7 -41
- package/dist/universal/index.d.ts +57 -1044
- package/dist/universal/index.js +16 -42
- package/package.json +18 -14
- package/dist/chunk-3WW5FLT7.js.map +0 -1
- package/dist/chunk-C6GF7MDF.js.map +0 -1
- package/dist/chunk-IZJ4JSSC.js.map +0 -1
- package/dist/client/index.cjs +0 -20460
- package/dist/client/index.cjs.map +0 -1
- package/dist/client/index.d.cts +0 -8195
- package/dist/server/index.cjs +0 -4525
- package/dist/server/index.cjs.map +0 -1
- package/dist/server/index.d.cts +0 -382
- package/dist/time-CVZpAkGY.d.ts +0 -3987
- package/dist/token-registry-snapshot-bR14QehS.d.cts +0 -245
- package/dist/universal/index.cjs +0 -4562
- package/dist/universal/index.cjs.map +0 -1
- package/dist/universal/index.d.cts +0 -1362
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
import { b5 as ClientId, bX as RedirectUri, b6 as CodeChallenge, bL as PKCEState, C as CodeVerifier, v as EvmWalletAddress, a as EthereumChain, cc as Tx, B as BlockchainAmount, c5 as SwapPreview, a9 as AssetDecimals, aQ as Newtype, J as TokenMetadata, b4 as Chain, b as EvmContractAddress, aL as OfferToken } from './time-CVZpAkGY.cjs';
|
|
2
|
-
import { Hex, Abi, Hash, TransactionReceipt } from 'viem';
|
|
3
|
-
|
|
4
|
-
type PKCEParams = {
|
|
5
|
-
clientId: ClientId;
|
|
6
|
-
responseType: 'code';
|
|
7
|
-
redirectUri: RedirectUri;
|
|
8
|
-
codeChallenge: CodeChallenge;
|
|
9
|
-
codeChallengeMethod: 'S256';
|
|
10
|
-
state: PKCEState;
|
|
11
|
-
codeVerifier: CodeVerifier;
|
|
12
|
-
};
|
|
13
|
-
type PKCEConfig = {
|
|
14
|
-
clientId: ClientId;
|
|
15
|
-
redirectUri: RedirectUri;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Generates PKCE parameters for an OAuth2 authorization code flow.
|
|
19
|
-
* Pure crypto — no React, no DOM beyond Web Crypto API. Safe to use
|
|
20
|
-
* in server-side code and Next.js middleware.
|
|
21
|
-
*/
|
|
22
|
-
declare function generatePKCEParams(config: PKCEConfig): Promise<PKCEParams>;
|
|
23
|
-
|
|
24
|
-
type WriteContractParams = {
|
|
25
|
-
abi: Abi;
|
|
26
|
-
address: `0x${string}`;
|
|
27
|
-
functionName: string;
|
|
28
|
-
args?: readonly unknown[];
|
|
29
|
-
value?: bigint;
|
|
30
|
-
chain: EthereumChain;
|
|
31
|
-
};
|
|
32
|
-
type BroadcastTxParams = Tx & {
|
|
33
|
-
chain: EthereumChain;
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* The signing-only wallet capability: address + `signMessage`. This is all the
|
|
37
|
-
* external-wallet ownership proof needs (see `useConnectWallet`), so hosts can
|
|
38
|
-
* satisfy that flow without implementing on-chain capabilities. The richer
|
|
39
|
-
* {@link EvmWallet} extends this for swap flows.
|
|
40
|
-
*
|
|
41
|
-
* SDK users implement this against their own wallet stack (e.g. viem, wagmi,
|
|
42
|
-
* Privy). `signMessage` throws on failure and the SDK classifies it.
|
|
43
|
-
*/
|
|
44
|
-
interface EvmSigner {
|
|
45
|
-
readonly address: EvmWalletAddress;
|
|
46
|
-
signMessage(message: string): Promise<Hex>;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* The full on-chain wallet the SDK needs to run the swap flows: an
|
|
50
|
-
* {@link EvmSigner} plus contract writes, raw-tx broadcast, and confirmation.
|
|
51
|
-
* SDK users implement this against their own wallet stack (e.g. viem, wagmi,
|
|
52
|
-
* Privy).
|
|
53
|
-
*
|
|
54
|
-
* Methods throw on failure. The SDK catches and classifies the thrown error
|
|
55
|
-
* (viem's `UserRejectedRequestError`, `InsufficientFundsError`, timeouts, …)
|
|
56
|
-
* into a typed {@link WalletError}, so implementers can simply let their wallet
|
|
57
|
-
* library's errors propagate.
|
|
58
|
-
*/
|
|
59
|
-
interface EvmWallet extends EvmSigner {
|
|
60
|
-
writeContract(params: WriteContractParams): Promise<Hash>;
|
|
61
|
-
broadcastRawTx(params: BroadcastTxParams): Promise<Hash>;
|
|
62
|
-
awaitTx(hash: Hash, chain: EthereumChain): Promise<TransactionReceipt>;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* The host-provided wallet the ownership flow signs with: the signing-only
|
|
66
|
-
* {@link EvmSigner} plus the {@link EthereumChain} the signature is proven on.
|
|
67
|
-
* `chain` rides on the wallet (not the offer) because the binding is
|
|
68
|
-
* chain-agnostic: it only records which EVM chain signed.
|
|
69
|
-
*/
|
|
70
|
-
type ConnectWallet = EvmSigner & {
|
|
71
|
-
readonly chain: EthereumChain;
|
|
72
|
-
};
|
|
73
|
-
/**
|
|
74
|
-
* The host's connector for an external wallet, as two lambdas: one opens it,
|
|
75
|
-
* one tears the connection down. The SDK ships no wallet stack, so this is how
|
|
76
|
-
* a screen offers "Connect wallet" without knowing whether AppKit, Privy or the
|
|
77
|
-
* host's own modal is behind it.
|
|
78
|
-
*
|
|
79
|
-
* One product type rather than two optional lambdas, because they come as a
|
|
80
|
-
* pair: a screen that can connect a wallet must be able to let it go again,
|
|
81
|
-
* and a host that supports neither passes `null` for the whole adapter, which
|
|
82
|
-
* hides the connect affordance entirely.
|
|
83
|
-
*/
|
|
84
|
-
type ExternalWalletAdapter = {
|
|
85
|
-
/**
|
|
86
|
-
* Opens the host's wallet connector. Resolves once the attempt finishes; the
|
|
87
|
-
* SDK reads the outcome from the external wallet it is handed on the next
|
|
88
|
-
* render rather than from a return value, so a host that connects through a
|
|
89
|
-
* redirect still works.
|
|
90
|
-
*
|
|
91
|
-
* Rejecting is how a declined or failed connection is reported.
|
|
92
|
-
*/
|
|
93
|
-
connect: () => Promise<void>;
|
|
94
|
-
/** Disconnects the external wallet. Resolves when it is gone. */
|
|
95
|
-
disconnect: () => Promise<void>;
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* A read-only quote for a swap as domain amounts: how much goes in, the
|
|
100
|
-
* protocol fee, and how much would come out. Derived from the raw
|
|
101
|
-
* {@link SwapPreview} the swap contract returns.
|
|
102
|
-
*/
|
|
103
|
-
type SwapQuote = {
|
|
104
|
-
inputTokenAmount: BlockchainAmount;
|
|
105
|
-
fee: BlockchainAmount;
|
|
106
|
-
outputTokenAmount: BlockchainAmount;
|
|
107
|
-
};
|
|
108
|
-
declare const SwapQuote: {
|
|
109
|
-
/**
|
|
110
|
-
* Assembles a {@link SwapQuote} from a raw contract {@link SwapPreview}. The
|
|
111
|
-
* input and fee are denominated in the input token; the output in the output
|
|
112
|
-
* token.
|
|
113
|
-
*/
|
|
114
|
-
fromPreview: (preview: SwapPreview, inputDecimals: AssetDecimals, outputDecimals: AssetDecimals) => SwapQuote;
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
type FormattedAmountUi = Newtype<string, 'FormattedAmountUi'>;
|
|
118
|
-
declare const FormattedAmountUi: (value: string) => FormattedAmountUi;
|
|
119
|
-
type FormattedPercentUi = Newtype<string, 'FormattedPercentUi'>;
|
|
120
|
-
declare const FormattedPercentUi: (value: string) => FormattedPercentUi;
|
|
121
|
-
type TxExplorerUrl = Newtype<string, 'TxExplorerUrl'>;
|
|
122
|
-
declare const TxExplorerUrl: (value: string) => TxExplorerUrl;
|
|
123
|
-
/**
|
|
124
|
-
* A wallet address shortened for display (e.g. `0x1234…5678`). Keeps a
|
|
125
|
-
* `0x${string}` base but drops the runtime `0x` narrowing.
|
|
126
|
-
*/
|
|
127
|
-
type ShortenedWalletAddress = Newtype<`0x${string}`, 'ShortenedWalletAddress'>;
|
|
128
|
-
declare const ShortenedWalletAddress: (value: string) => ShortenedWalletAddress;
|
|
129
|
-
type FormattedAmountAssetUi = Newtype<string, 'FormattedAmountAssetUi'>;
|
|
130
|
-
declare const FormattedAmountAssetUi: (value: string) => FormattedAmountAssetUi;
|
|
131
|
-
type AssetIconUrl = Newtype<string, 'AssetIconUrl'>;
|
|
132
|
-
declare const AssetIconUrl: (value: string) => AssetIconUrl;
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* The wallets a screen reads for and acts from, supplied by the host.
|
|
136
|
-
*
|
|
137
|
-
* The SDK ships no wallet stack, so wallet discovery and connection are
|
|
138
|
-
* inverted onto the host: it hands over ready {@link EvmWallet}s, and an
|
|
139
|
-
* adapter for connecting an external one when it supports that. Every wallet
|
|
140
|
-
* here is one that can sign for itself, so a screen can broadcast from the
|
|
141
|
-
* wallet that holds a position.
|
|
142
|
-
*/
|
|
143
|
-
type WalletSelection = {
|
|
144
|
-
/**
|
|
145
|
-
* The user's embedded (custodial) wallets, in display order. Empty when
|
|
146
|
-
* they have none, which is a normal state, not an error.
|
|
147
|
-
*/
|
|
148
|
-
embedded: EvmWallet[];
|
|
149
|
-
/** The connected external wallet, or `null` while none is connected. */
|
|
150
|
-
external: EvmWallet | null;
|
|
151
|
-
/**
|
|
152
|
-
* The host's external-wallet connector, or `null` when it offers none - in
|
|
153
|
-
* which case the screen shows no connect affordance at all. A host may
|
|
154
|
-
* still pass a connected `external` without one, to show a wallet the user
|
|
155
|
-
* cannot change from here.
|
|
156
|
-
*/
|
|
157
|
-
externalAdapter: ExternalWalletAdapter | null;
|
|
158
|
-
};
|
|
159
|
-
declare const WalletSelection: {
|
|
160
|
-
/**
|
|
161
|
-
* Every wallet in display order - embedded first, then the external one -
|
|
162
|
-
* each address once. Addresses compare case-insensitively, so a host that
|
|
163
|
-
* hands the same wallet over as both embedded and external sees it once.
|
|
164
|
-
*/
|
|
165
|
-
all: (selection: WalletSelection) => EvmWallet[];
|
|
166
|
-
};
|
|
167
|
-
/**
|
|
168
|
-
* Names a wallet for display, e.g. `'CoinList Wallet'` for the user's
|
|
169
|
-
* embedded one. `null` means it has no name, and the screen shows its
|
|
170
|
-
* shortened address instead.
|
|
171
|
-
*/
|
|
172
|
-
type WalletLabelResolver = (address: EvmWalletAddress) => string | null;
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* An array guaranteed to hold at least one element. Use it where an empty list
|
|
176
|
-
* would be a bug (e.g. the set of assets a swap always offers).
|
|
177
|
-
*/
|
|
178
|
-
type NonEmptyArray<T> = [T, ...T[]];
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* A token as a lookup names it. `Chain` rather than `EthereumChain` because
|
|
182
|
-
* `OfferToken.chain` is the wider type; a Solana entry simply never matches,
|
|
183
|
-
* since the snapshot models EVM chains only.
|
|
184
|
-
*/
|
|
185
|
-
type TokenKey = {
|
|
186
|
-
chain: Chain;
|
|
187
|
-
address: EvmContractAddress;
|
|
188
|
-
};
|
|
189
|
-
/**
|
|
190
|
-
* One `coinlist.tokens.list()` answer, indexed for the lookups a catalogue
|
|
191
|
-
* makes: by the `(chain, address)` pairs `Offer.tokens` carries.
|
|
192
|
-
*
|
|
193
|
-
* The registry is fetched whole - a few hundred tokens across every chain in
|
|
194
|
-
* one request - and then asked one question per offer. Building the index
|
|
195
|
-
* once is what keeps that a map lookup per card rather than a scan of the
|
|
196
|
-
* snapshot per card. The same rule frontline-web and every other host wrote
|
|
197
|
-
* for themselves, kept here so that none of them has to.
|
|
198
|
-
*/
|
|
199
|
-
type TokenRegistrySnapshot = {
|
|
200
|
-
/** Every token the snapshot lists, in registry order. */
|
|
201
|
-
readonly tokens: readonly TokenMetadata[];
|
|
202
|
-
/** `chain:address` (address lowercased) to its metadata. */
|
|
203
|
-
readonly byKey: ReadonlyMap<string, TokenMetadata>;
|
|
204
|
-
};
|
|
205
|
-
declare const TokenRegistrySnapshot: {
|
|
206
|
-
/** Indexes a `tokens.list()` result. `[]` is a valid, empty snapshot. */
|
|
207
|
-
fromTokens: (tokens: readonly TokenMetadata[]) => TokenRegistrySnapshot;
|
|
208
|
-
/**
|
|
209
|
-
* The registry's entry for one token, or `null` when it lists none. The
|
|
210
|
-
* registry is curated, so `null` is an ordinary answer rather than an
|
|
211
|
-
* error, and callers fall back to their own display defaults.
|
|
212
|
-
*/
|
|
213
|
-
get: (snapshot: TokenRegistrySnapshot, token: TokenKey) => TokenMetadata | null;
|
|
214
|
-
/**
|
|
215
|
-
* The registry's entry for the token an offer is *about*, or `null` when
|
|
216
|
-
* it lists none of them.
|
|
217
|
-
*
|
|
218
|
-
* Resolution follows {@link offerDisplayTokens}: the token a sale
|
|
219
|
-
* distributes or a swap hands over, never the funding token the user pays
|
|
220
|
-
* with. An offer deployed on several chains carries one such token per
|
|
221
|
-
* chain, and the first the registry knows wins - they are the same asset,
|
|
222
|
-
* so any listed one answers for the offer.
|
|
223
|
-
*/
|
|
224
|
-
forOffer: (snapshot: TokenRegistrySnapshot, offer: {
|
|
225
|
-
tokens: readonly OfferToken[];
|
|
226
|
-
}) => TokenMetadata | null;
|
|
227
|
-
};
|
|
228
|
-
/**
|
|
229
|
-
* The tokens an offer is *about*, most specific first: every `swap` or
|
|
230
|
-
* `vault` entry, then every `distribution` entry. `funding` entries name what
|
|
231
|
-
* an offer is paid with (USDC, USDT) and never the asset on offer, so they are
|
|
232
|
-
* left out.
|
|
233
|
-
*
|
|
234
|
-
* `swap` and `vault` rank together - no offer type carries both - and outrank
|
|
235
|
-
* `distribution` because a swap or vault product names the token it hands over
|
|
236
|
-
* precisely, while a sale's distribution entry names the same token for a sale
|
|
237
|
-
* product and is accepted as the fallback. The checkout's
|
|
238
|
-
* per-chain lookup and the catalogue's any-chain lookup both read this
|
|
239
|
-
* ordering, which is why it is stated once, here.
|
|
240
|
-
*/
|
|
241
|
-
declare function offerDisplayTokens(offer: {
|
|
242
|
-
tokens: readonly OfferToken[];
|
|
243
|
-
}): OfferToken[];
|
|
244
|
-
|
|
245
|
-
export { AssetIconUrl as A, type BroadcastTxParams as B, type ConnectWallet as C, type EvmWallet as E, FormattedAmountAssetUi as F, type NonEmptyArray as N, type PKCEConfig as P, SwapQuote as S, TxExplorerUrl as T, WalletSelection as W, ShortenedWalletAddress as a, FormattedPercentUi as b, type WalletLabelResolver as c, TokenRegistrySnapshot as d, type EvmSigner as e, type ExternalWalletAdapter as f, type WriteContractParams as g, FormattedAmountUi as h, type PKCEParams as i, generatePKCEParams as j, offerDisplayTokens as o };
|