@coinlist-co/react 0.12.1-rc.f51a0c2 → 0.12.1
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-QIAM2VUU.js → chunk-VH34YC3Q.js} +49 -1
- package/dist/chunk-VH34YC3Q.js.map +1 -0
- package/dist/client/index.cjs +805 -409
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +293 -121
- package/dist/client/index.d.ts +293 -121
- package/dist/client/index.js +741 -392
- package/dist/client/index.js.map +1 -1
- package/dist/{collections-Biy3pQQL.d.cts → token-registry-snapshot-BNBNuDu1.d.ts} +65 -2
- package/dist/{collections-JfNDG8Tc.d.ts → token-registry-snapshot-CqI6dXM_.d.cts} +65 -2
- package/dist/universal/index.cjs +50 -0
- package/dist/universal/index.cjs.map +1 -1
- package/dist/universal/index.d.cts +2 -2
- package/dist/universal/index.d.ts +2 -2
- package/dist/universal/index.js +5 -1
- package/package.json +1 -1
- package/dist/chunk-QIAM2VUU.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { aI as ClientId, bw as RedirectUri, aJ as CodeChallenge, bk as PKCEState, C as CodeVerifier, q as EvmWalletAddress, a as EthereumChain, bN as Tx, B as BlockchainAmount, bG as SwapPreview, a0 as AssetDecimals, aA as Newtype } from './tokens-namespace-CIWBtgt2.
|
|
1
|
+
import { aI as ClientId, bw as RedirectUri, aJ as CodeChallenge, bk as PKCEState, C as CodeVerifier, q as EvmWalletAddress, a as EthereumChain, bN as Tx, B as BlockchainAmount, bG as SwapPreview, a0 as AssetDecimals, aA as Newtype, D as TokenMetadata, aH as Chain, b as EvmContractAddress, bf as OfferToken } from './tokens-namespace-CIWBtgt2.js';
|
|
2
2
|
import { Hex, Abi, Hash, TransactionReceipt } from 'viem';
|
|
3
3
|
|
|
4
4
|
type PKCEParams = {
|
|
@@ -113,4 +113,67 @@ declare const AssetIconUrl: (value: string) => AssetIconUrl;
|
|
|
113
113
|
*/
|
|
114
114
|
type NonEmptyArray<T> = [T, ...T[]];
|
|
115
115
|
|
|
116
|
-
|
|
116
|
+
/**
|
|
117
|
+
* A token as a lookup names it. `Chain` rather than `EthereumChain` because
|
|
118
|
+
* `OfferToken.chain` is the wider type; a Solana entry simply never matches,
|
|
119
|
+
* since the snapshot models EVM chains only.
|
|
120
|
+
*/
|
|
121
|
+
type TokenKey = {
|
|
122
|
+
chain: Chain;
|
|
123
|
+
address: EvmContractAddress;
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* One `coinlist.tokens.list()` answer, indexed for the lookups a catalogue
|
|
127
|
+
* makes: by the `(chain, address)` pairs `Offer.tokens` carries.
|
|
128
|
+
*
|
|
129
|
+
* The registry is fetched whole - a few hundred tokens across every chain in
|
|
130
|
+
* one request - and then asked one question per offer. Building the index
|
|
131
|
+
* once is what keeps that a map lookup per card rather than a scan of the
|
|
132
|
+
* snapshot per card. The same rule frontline-web and every other host wrote
|
|
133
|
+
* for themselves, kept here so that none of them has to.
|
|
134
|
+
*/
|
|
135
|
+
type TokenRegistrySnapshot = {
|
|
136
|
+
/** Every token the snapshot lists, in registry order. */
|
|
137
|
+
readonly tokens: readonly TokenMetadata[];
|
|
138
|
+
/** `chain:address` (address lowercased) to its metadata. */
|
|
139
|
+
readonly byKey: ReadonlyMap<string, TokenMetadata>;
|
|
140
|
+
};
|
|
141
|
+
declare const TokenRegistrySnapshot: {
|
|
142
|
+
/** Indexes a `tokens.list()` result. `[]` is a valid, empty snapshot. */
|
|
143
|
+
fromTokens: (tokens: readonly TokenMetadata[]) => TokenRegistrySnapshot;
|
|
144
|
+
/**
|
|
145
|
+
* The registry's entry for one token, or `null` when it lists none. The
|
|
146
|
+
* registry is curated, so `null` is an ordinary answer rather than an
|
|
147
|
+
* error, and callers fall back to their own display defaults.
|
|
148
|
+
*/
|
|
149
|
+
get: (snapshot: TokenRegistrySnapshot, token: TokenKey) => TokenMetadata | null;
|
|
150
|
+
/**
|
|
151
|
+
* The registry's entry for the token an offer is *about*, or `null` when
|
|
152
|
+
* it lists none of them.
|
|
153
|
+
*
|
|
154
|
+
* Resolution follows {@link offerDisplayTokens}: the token a sale
|
|
155
|
+
* distributes or a swap hands over, never the funding token the user pays
|
|
156
|
+
* with. An offer deployed on several chains carries one such token per
|
|
157
|
+
* chain, and the first the registry knows wins - they are the same asset,
|
|
158
|
+
* so any listed one answers for the offer.
|
|
159
|
+
*/
|
|
160
|
+
forOffer: (snapshot: TokenRegistrySnapshot, offer: {
|
|
161
|
+
tokens: readonly OfferToken[];
|
|
162
|
+
}) => TokenMetadata | null;
|
|
163
|
+
};
|
|
164
|
+
/**
|
|
165
|
+
* The tokens an offer is *about*, most specific first: every `swap` entry,
|
|
166
|
+
* then every `distribution` entry. `funding` entries name what a swap is paid
|
|
167
|
+
* with (USDC, USDT) and never the asset on offer, so they are left out.
|
|
168
|
+
*
|
|
169
|
+
* `swap` outranks `distribution` because a swap product names the asset it
|
|
170
|
+
* hands over precisely, while a sale's distribution entry names the same
|
|
171
|
+
* token for a sale product and is accepted as the fallback. The checkout's
|
|
172
|
+
* per-chain lookup and the catalogue's any-chain lookup both read this
|
|
173
|
+
* ordering, which is why it is stated once, here.
|
|
174
|
+
*/
|
|
175
|
+
declare function offerDisplayTokens(offer: {
|
|
176
|
+
tokens: readonly OfferToken[];
|
|
177
|
+
}): OfferToken[];
|
|
178
|
+
|
|
179
|
+
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, type WriteContractParams as W, ShortenedWalletAddress as a, FormattedPercentUi as b, TokenRegistrySnapshot as c, type EvmSigner as d, FormattedAmountUi as e, type PKCEParams as f, generatePKCEParams as g, offerDisplayTokens as o };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { aI as ClientId, bw as RedirectUri, aJ as CodeChallenge, bk as PKCEState, C as CodeVerifier, q as EvmWalletAddress, a as EthereumChain, bN as Tx, B as BlockchainAmount, bG as SwapPreview, a0 as AssetDecimals, aA as Newtype } from './tokens-namespace-CIWBtgt2.
|
|
1
|
+
import { aI as ClientId, bw as RedirectUri, aJ as CodeChallenge, bk as PKCEState, C as CodeVerifier, q as EvmWalletAddress, a as EthereumChain, bN as Tx, B as BlockchainAmount, bG as SwapPreview, a0 as AssetDecimals, aA as Newtype, D as TokenMetadata, aH as Chain, b as EvmContractAddress, bf as OfferToken } from './tokens-namespace-CIWBtgt2.cjs';
|
|
2
2
|
import { Hex, Abi, Hash, TransactionReceipt } from 'viem';
|
|
3
3
|
|
|
4
4
|
type PKCEParams = {
|
|
@@ -113,4 +113,67 @@ declare const AssetIconUrl: (value: string) => AssetIconUrl;
|
|
|
113
113
|
*/
|
|
114
114
|
type NonEmptyArray<T> = [T, ...T[]];
|
|
115
115
|
|
|
116
|
-
|
|
116
|
+
/**
|
|
117
|
+
* A token as a lookup names it. `Chain` rather than `EthereumChain` because
|
|
118
|
+
* `OfferToken.chain` is the wider type; a Solana entry simply never matches,
|
|
119
|
+
* since the snapshot models EVM chains only.
|
|
120
|
+
*/
|
|
121
|
+
type TokenKey = {
|
|
122
|
+
chain: Chain;
|
|
123
|
+
address: EvmContractAddress;
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* One `coinlist.tokens.list()` answer, indexed for the lookups a catalogue
|
|
127
|
+
* makes: by the `(chain, address)` pairs `Offer.tokens` carries.
|
|
128
|
+
*
|
|
129
|
+
* The registry is fetched whole - a few hundred tokens across every chain in
|
|
130
|
+
* one request - and then asked one question per offer. Building the index
|
|
131
|
+
* once is what keeps that a map lookup per card rather than a scan of the
|
|
132
|
+
* snapshot per card. The same rule frontline-web and every other host wrote
|
|
133
|
+
* for themselves, kept here so that none of them has to.
|
|
134
|
+
*/
|
|
135
|
+
type TokenRegistrySnapshot = {
|
|
136
|
+
/** Every token the snapshot lists, in registry order. */
|
|
137
|
+
readonly tokens: readonly TokenMetadata[];
|
|
138
|
+
/** `chain:address` (address lowercased) to its metadata. */
|
|
139
|
+
readonly byKey: ReadonlyMap<string, TokenMetadata>;
|
|
140
|
+
};
|
|
141
|
+
declare const TokenRegistrySnapshot: {
|
|
142
|
+
/** Indexes a `tokens.list()` result. `[]` is a valid, empty snapshot. */
|
|
143
|
+
fromTokens: (tokens: readonly TokenMetadata[]) => TokenRegistrySnapshot;
|
|
144
|
+
/**
|
|
145
|
+
* The registry's entry for one token, or `null` when it lists none. The
|
|
146
|
+
* registry is curated, so `null` is an ordinary answer rather than an
|
|
147
|
+
* error, and callers fall back to their own display defaults.
|
|
148
|
+
*/
|
|
149
|
+
get: (snapshot: TokenRegistrySnapshot, token: TokenKey) => TokenMetadata | null;
|
|
150
|
+
/**
|
|
151
|
+
* The registry's entry for the token an offer is *about*, or `null` when
|
|
152
|
+
* it lists none of them.
|
|
153
|
+
*
|
|
154
|
+
* Resolution follows {@link offerDisplayTokens}: the token a sale
|
|
155
|
+
* distributes or a swap hands over, never the funding token the user pays
|
|
156
|
+
* with. An offer deployed on several chains carries one such token per
|
|
157
|
+
* chain, and the first the registry knows wins - they are the same asset,
|
|
158
|
+
* so any listed one answers for the offer.
|
|
159
|
+
*/
|
|
160
|
+
forOffer: (snapshot: TokenRegistrySnapshot, offer: {
|
|
161
|
+
tokens: readonly OfferToken[];
|
|
162
|
+
}) => TokenMetadata | null;
|
|
163
|
+
};
|
|
164
|
+
/**
|
|
165
|
+
* The tokens an offer is *about*, most specific first: every `swap` entry,
|
|
166
|
+
* then every `distribution` entry. `funding` entries name what a swap is paid
|
|
167
|
+
* with (USDC, USDT) and never the asset on offer, so they are left out.
|
|
168
|
+
*
|
|
169
|
+
* `swap` outranks `distribution` because a swap product names the asset it
|
|
170
|
+
* hands over precisely, while a sale's distribution entry names the same
|
|
171
|
+
* token for a sale product and is accepted as the fallback. The checkout's
|
|
172
|
+
* per-chain lookup and the catalogue's any-chain lookup both read this
|
|
173
|
+
* ordering, which is why it is stated once, here.
|
|
174
|
+
*/
|
|
175
|
+
declare function offerDisplayTokens(offer: {
|
|
176
|
+
tokens: readonly OfferToken[];
|
|
177
|
+
}): OfferToken[];
|
|
178
|
+
|
|
179
|
+
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, type WriteContractParams as W, ShortenedWalletAddress as a, FormattedPercentUi as b, TokenRegistrySnapshot as c, type EvmSigner as d, FormattedAmountUi as e, type PKCEParams as f, generatePKCEParams as g, offerDisplayTokens as o };
|
package/dist/universal/index.cjs
CHANGED
|
@@ -136,6 +136,7 @@ __export(universal_exports, {
|
|
|
136
136
|
TokenLogo: () => TokenLogo,
|
|
137
137
|
TokenLogoUrl: () => TokenLogoUrl,
|
|
138
138
|
TokenMetadata: () => TokenMetadata,
|
|
139
|
+
TokenRegistrySnapshot: () => TokenRegistrySnapshot,
|
|
139
140
|
TokensNamespaceImpl: () => TokensNamespaceImpl,
|
|
140
141
|
TxExplorerUrl: () => TxExplorerUrl,
|
|
141
142
|
USDC: () => USDC,
|
|
@@ -173,6 +174,7 @@ __export(universal_exports, {
|
|
|
173
174
|
isChain: () => isChain,
|
|
174
175
|
isOfferType: () => isOfferType,
|
|
175
176
|
isSwapAvailable: () => isSwapAvailable,
|
|
177
|
+
offerDisplayTokens: () => offerDisplayTokens,
|
|
176
178
|
ondoQuoteOfferDeadline: () => ondoQuoteOfferDeadline,
|
|
177
179
|
parseBlockchainAmount: () => parseBlockchainAmount,
|
|
178
180
|
parseUint256: () => parseUint256,
|
|
@@ -3276,6 +3278,52 @@ var Erc20NamespaceImpl = class {
|
|
|
3276
3278
|
}
|
|
3277
3279
|
};
|
|
3278
3280
|
|
|
3281
|
+
// src/universal/core/tokens/token-registry-snapshot.ts
|
|
3282
|
+
var TokenRegistrySnapshot = {
|
|
3283
|
+
/** Indexes a `tokens.list()` result. `[]` is a valid, empty snapshot. */
|
|
3284
|
+
fromTokens: (tokens) => ({
|
|
3285
|
+
tokens,
|
|
3286
|
+
byKey: new Map(
|
|
3287
|
+
tokens.map((token) => [registryKey(token.identifier), token])
|
|
3288
|
+
)
|
|
3289
|
+
}),
|
|
3290
|
+
/**
|
|
3291
|
+
* The registry's entry for one token, or `null` when it lists none. The
|
|
3292
|
+
* registry is curated, so `null` is an ordinary answer rather than an
|
|
3293
|
+
* error, and callers fall back to their own display defaults.
|
|
3294
|
+
*/
|
|
3295
|
+
get: (snapshot, token) => snapshot.byKey.get(registryKey(token)) ?? null,
|
|
3296
|
+
/**
|
|
3297
|
+
* The registry's entry for the token an offer is *about*, or `null` when
|
|
3298
|
+
* it lists none of them.
|
|
3299
|
+
*
|
|
3300
|
+
* Resolution follows {@link offerDisplayTokens}: the token a sale
|
|
3301
|
+
* distributes or a swap hands over, never the funding token the user pays
|
|
3302
|
+
* with. An offer deployed on several chains carries one such token per
|
|
3303
|
+
* chain, and the first the registry knows wins - they are the same asset,
|
|
3304
|
+
* so any listed one answers for the offer.
|
|
3305
|
+
*/
|
|
3306
|
+
forOffer: (snapshot, offer) => {
|
|
3307
|
+
for (const token of offerDisplayTokens(offer)) {
|
|
3308
|
+
const metadata = TokenRegistrySnapshot.get(snapshot, token);
|
|
3309
|
+
if (metadata !== null) {
|
|
3310
|
+
return metadata;
|
|
3311
|
+
}
|
|
3312
|
+
}
|
|
3313
|
+
return null;
|
|
3314
|
+
}
|
|
3315
|
+
};
|
|
3316
|
+
function offerDisplayTokens(offer) {
|
|
3317
|
+
const swaps = offer.tokens.filter((token) => token.role === "swap");
|
|
3318
|
+
const distributions = offer.tokens.filter(
|
|
3319
|
+
(token) => token.role === "distribution"
|
|
3320
|
+
);
|
|
3321
|
+
return [...swaps, ...distributions];
|
|
3322
|
+
}
|
|
3323
|
+
function registryKey(token) {
|
|
3324
|
+
return `${token.chain}:${token.address.toLowerCase()}`;
|
|
3325
|
+
}
|
|
3326
|
+
|
|
3279
3327
|
// src/universal/api/nabu/tokens.ts
|
|
3280
3328
|
var import_viem5 = require("viem");
|
|
3281
3329
|
|
|
@@ -3928,6 +3976,7 @@ var User = {
|
|
|
3928
3976
|
TokenLogo,
|
|
3929
3977
|
TokenLogoUrl,
|
|
3930
3978
|
TokenMetadata,
|
|
3979
|
+
TokenRegistrySnapshot,
|
|
3931
3980
|
TokensNamespaceImpl,
|
|
3932
3981
|
TxExplorerUrl,
|
|
3933
3982
|
USDC,
|
|
@@ -3965,6 +4014,7 @@ var User = {
|
|
|
3965
4014
|
isChain,
|
|
3966
4015
|
isOfferType,
|
|
3967
4016
|
isSwapAvailable,
|
|
4017
|
+
offerDisplayTokens,
|
|
3968
4018
|
ondoQuoteOfferDeadline,
|
|
3969
4019
|
parseBlockchainAmount,
|
|
3970
4020
|
parseUint256,
|