@coinlist-co/react 0.12.1-rc.e183ffd → 0.12.1-rc.f2804ef
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-ONLH57LF.js → chunk-VH34YC3Q.js} +55 -3
- package/dist/chunk-VH34YC3Q.js.map +1 -0
- package/dist/client/index.cjs +578 -329
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +266 -108
- package/dist/client/index.d.ts +266 -108
- package/dist/client/index.js +520 -321
- 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 +58 -3
- package/dist/universal/index.cjs.map +1 -1
- package/dist/universal/index.d.cts +7 -12
- package/dist/universal/index.d.ts +7 -12
- package/dist/universal/index.js +9 -3
- package/package.json +1 -1
- package/dist/chunk-ONLH57LF.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
|
@@ -77,7 +77,7 @@ __export(universal_exports, {
|
|
|
77
77
|
OAuthRefreshToken: () => OAuthRefreshToken,
|
|
78
78
|
OAuthSession: () => OAuthSession,
|
|
79
79
|
ONDO_POLL_INTERVAL_MS: () => ONDO_POLL_INTERVAL_MS,
|
|
80
|
-
|
|
80
|
+
ONDO_QUOTE_MAX_TTL_MS: () => ONDO_QUOTE_MAX_TTL_MS,
|
|
81
81
|
ONDO_SETTLEMENT_ASSET: () => ONDO_SETTLEMENT_ASSET,
|
|
82
82
|
ONDO_SUPPORTED_INPUT_ASSETS: () => ONDO_SUPPORTED_INPUT_ASSETS,
|
|
83
83
|
Offer: () => Offer,
|
|
@@ -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,8 @@ __export(universal_exports, {
|
|
|
173
174
|
isChain: () => isChain,
|
|
174
175
|
isOfferType: () => isOfferType,
|
|
175
176
|
isSwapAvailable: () => isSwapAvailable,
|
|
177
|
+
offerDisplayTokens: () => offerDisplayTokens,
|
|
178
|
+
ondoQuoteOfferDeadline: () => ondoQuoteOfferDeadline,
|
|
176
179
|
parseBlockchainAmount: () => parseBlockchainAmount,
|
|
177
180
|
parseUint256: () => parseUint256,
|
|
178
181
|
shortenAddress: () => shortenAddress,
|
|
@@ -1191,7 +1194,7 @@ var TOKEN_REGISTRY = {
|
|
|
1191
1194
|
|
|
1192
1195
|
// src/universal/core/checkout/ondo/constants.ts
|
|
1193
1196
|
var ONDO_POLL_INTERVAL_MS = 15e3;
|
|
1194
|
-
var
|
|
1197
|
+
var ONDO_QUOTE_MAX_TTL_MS = 15e3;
|
|
1195
1198
|
var DEFAULT_ONDO_AMOUNT_TO_COMPUTE_PRICE = DecimalString("1000");
|
|
1196
1199
|
var ONDO_SETTLEMENT_ASSET = USDC_SYMBOL;
|
|
1197
1200
|
var DEFAULT_ONDO_SELL_TOKENS_TO_COMPUTE_PRICE = 1;
|
|
@@ -1214,6 +1217,9 @@ function computeOndoSellPrice(transaction) {
|
|
|
1214
1217
|
shares: spendInputAmount
|
|
1215
1218
|
});
|
|
1216
1219
|
}
|
|
1220
|
+
function ondoQuoteOfferDeadline(expiresAt, nowMs = Date.now()) {
|
|
1221
|
+
return new Date(Math.min(expiresAt.getTime(), nowMs + ONDO_QUOTE_MAX_TTL_MS));
|
|
1222
|
+
}
|
|
1217
1223
|
function grossProceeds(expected) {
|
|
1218
1224
|
const raw = expected.quantity.raw + expected.fee.raw;
|
|
1219
1225
|
if (raw > MAX_UINT_256) {
|
|
@@ -3272,6 +3278,52 @@ var Erc20NamespaceImpl = class {
|
|
|
3272
3278
|
}
|
|
3273
3279
|
};
|
|
3274
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
|
+
|
|
3275
3327
|
// src/universal/api/nabu/tokens.ts
|
|
3276
3328
|
var import_viem5 = require("viem");
|
|
3277
3329
|
|
|
@@ -3865,7 +3917,7 @@ var User = {
|
|
|
3865
3917
|
OAuthRefreshToken,
|
|
3866
3918
|
OAuthSession,
|
|
3867
3919
|
ONDO_POLL_INTERVAL_MS,
|
|
3868
|
-
|
|
3920
|
+
ONDO_QUOTE_MAX_TTL_MS,
|
|
3869
3921
|
ONDO_SETTLEMENT_ASSET,
|
|
3870
3922
|
ONDO_SUPPORTED_INPUT_ASSETS,
|
|
3871
3923
|
Offer,
|
|
@@ -3924,6 +3976,7 @@ var User = {
|
|
|
3924
3976
|
TokenLogo,
|
|
3925
3977
|
TokenLogoUrl,
|
|
3926
3978
|
TokenMetadata,
|
|
3979
|
+
TokenRegistrySnapshot,
|
|
3927
3980
|
TokensNamespaceImpl,
|
|
3928
3981
|
TxExplorerUrl,
|
|
3929
3982
|
USDC,
|
|
@@ -3961,6 +4014,8 @@ var User = {
|
|
|
3961
4014
|
isChain,
|
|
3962
4015
|
isOfferType,
|
|
3963
4016
|
isSwapAvailable,
|
|
4017
|
+
offerDisplayTokens,
|
|
4018
|
+
ondoQuoteOfferDeadline,
|
|
3964
4019
|
parseBlockchainAmount,
|
|
3965
4020
|
parseUint256,
|
|
3966
4021
|
shortenAddress,
|