@coinlist-co/react 0.12.2-rc.7b430dd → 0.12.2-rc.9fb6364

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/{chunk-MOE5S6CE.js → chunk-BNMF2HMW.js} +114 -4
  2. package/dist/chunk-BNMF2HMW.js.map +1 -0
  3. package/dist/{chunk-VH34YC3Q.js → chunk-KRA6EM2L.js} +2 -2
  4. package/dist/{chunk-DCW7NQXH.js → chunk-STAHYDLY.js} +52 -19
  5. package/dist/chunk-STAHYDLY.js.map +1 -0
  6. package/dist/client/index.cjs +322 -96
  7. package/dist/client/index.cjs.map +1 -1
  8. package/dist/client/index.d.cts +26 -10
  9. package/dist/client/index.d.ts +26 -10
  10. package/dist/client/index.js +225 -102
  11. package/dist/client/index.js.map +1 -1
  12. package/dist/server/index.cjs +437 -76
  13. package/dist/server/index.cjs.map +1 -1
  14. package/dist/server/index.d.cts +47 -38
  15. package/dist/server/index.d.ts +47 -38
  16. package/dist/server/index.js +316 -61
  17. package/dist/server/index.js.map +1 -1
  18. package/dist/time-B5YOQxuh.d.ts +50 -0
  19. package/dist/time-BY3apBpc.d.cts +50 -0
  20. package/dist/{token-registry-snapshot-BNBNuDu1.d.ts → token-registry-snapshot-C1NxdBmF.d.ts} +1 -1
  21. package/dist/{token-registry-snapshot-CqI6dXM_.d.cts → token-registry-snapshot-DyjrA32p.d.cts} +1 -1
  22. package/dist/{tokens-namespace-CIWBtgt2.d.cts → tokens-namespace-BJfFeowE.d.cts} +53 -1
  23. package/dist/{tokens-namespace-CIWBtgt2.d.ts → tokens-namespace-BJfFeowE.d.ts} +53 -1
  24. package/dist/universal/index.cjs +100 -3
  25. package/dist/universal/index.cjs.map +1 -1
  26. package/dist/universal/index.d.cts +23 -5
  27. package/dist/universal/index.d.ts +23 -5
  28. package/dist/universal/index.js +12 -2
  29. package/package.json +1 -1
  30. package/dist/chunk-DCW7NQXH.js.map +0 -1
  31. package/dist/chunk-MOE5S6CE.js.map +0 -1
  32. /package/dist/{chunk-VH34YC3Q.js.map → chunk-KRA6EM2L.js.map} +0 -0
@@ -1,3 +1,27 @@
1
+ // src/universal/api/internal-access-token-source.ts
2
+ var SentWith = {
3
+ userToken: (token) => ({
4
+ type: "user-token",
5
+ token
6
+ }),
7
+ noUserToken: { type: "no-user-token" }
8
+ };
9
+ var TokenTrigger = {
10
+ beforeRequest: { type: "before-request" },
11
+ after401: (rejected) => ({
12
+ type: "after-401",
13
+ rejected
14
+ })
15
+ };
16
+ function isRejectedToken(token, rejected) {
17
+ switch (rejected.type) {
18
+ case "user-token":
19
+ return rejected.token.value === token.value;
20
+ case "no-user-token":
21
+ return false;
22
+ }
23
+ }
24
+
1
25
  // src/universal/api/http-attributes.ts
2
26
  var empty = {};
3
27
  var concat = (left, right) => ({
@@ -25,6 +49,10 @@ var retryAttempt = (attempt) => ({
25
49
  var renewAttempted = (value) => ({
26
50
  renewAttempted: value
27
51
  });
52
+ var notRetryable = () => ({ retryable: false });
53
+ var sentWith = (token) => ({
54
+ sentWith: token
55
+ });
28
56
  var requestId = (id) => ({ requestId: id });
29
57
  var getRequestId = (attrs) => attrs?.requestId ?? null;
30
58
  var isProtected = (attrs) => attrs?.protected === true;
@@ -32,6 +60,8 @@ var needUserAgent = (attrs) => attrs?.userAgent === true;
32
60
  var isIdempotent = (attrs) => attrs?.idempotencyKey === true;
33
61
  var getRetryAttempt = (attrs) => attrs?.retryAttempt ?? 0;
34
62
  var wasRenewAttempted = (attrs) => attrs?.renewAttempted === true;
63
+ var isRetryable = (attrs) => attrs?.retryable !== false;
64
+ var getSentWith = (attrs) => attrs?.sentWith === void 0 ? SentWith.noUserToken : SentWith.userToken(attrs.sentWith);
35
65
  var getClientCredentials = (attrs) => attrs?.clientCredentials;
36
66
  var Attributes = {
37
67
  empty,
@@ -47,6 +77,10 @@ var Attributes = {
47
77
  getRetryAttempt,
48
78
  renewAttempted,
49
79
  wasRenewAttempted,
80
+ notRetryable,
81
+ isRetryable,
82
+ sentWith,
83
+ getSentWith,
50
84
  clientCredentials,
51
85
  getClientCredentials,
52
86
  requestId,
@@ -209,6 +243,54 @@ var MathError = class extends Error {
209
243
  }
210
244
  };
211
245
 
246
+ // src/universal/types/time.ts
247
+ var MAX_EPOCH_MILLIS = 864e13;
248
+ var EpochMillis = {
249
+ /**
250
+ * @throws {@link ValidationError} unless `value` is an integer a `Date` can
251
+ * represent: at most {@link MAX_EPOCH_MILLIS} either side of the epoch.
252
+ */
253
+ of: (value) => {
254
+ if (!Number.isInteger(value) || Math.abs(value) > MAX_EPOCH_MILLIS) {
255
+ throw new ValidationError(
256
+ `EpochMillis must be an integer within \xB1${MAX_EPOCH_MILLIS}, got ${value}`
257
+ );
258
+ }
259
+ return value;
260
+ },
261
+ /** The wall clock. Code that needs the time takes a `TimeEff` instead. */
262
+ now: () => EpochMillis.of(Date.now()),
263
+ /** @throws {@link ValidationError} for an invalid `Date`. */
264
+ fromDate: (date) => EpochMillis.of(date.getTime()),
265
+ /** How long after `from` the instant `to` is; negative if it is before. */
266
+ elapsed: (from, to) => Millis.of(to - from),
267
+ plus: (at, duration) => EpochMillis.of(at + duration)
268
+ };
269
+ var Millis = {
270
+ of: (value) => value
271
+ };
272
+ var Seconds = {
273
+ /**
274
+ * @throws {@link ValidationError} unless `value` is a non-negative integer.
275
+ */
276
+ of: (value) => {
277
+ if (!Number.isInteger(value) || value < 0) {
278
+ throw new ValidationError(
279
+ `Seconds must be a non-negative integer, got ${value}`
280
+ );
281
+ }
282
+ return value;
283
+ },
284
+ toMillis: (value) => Millis.of(value * 1e3)
285
+ };
286
+ function isExpired({
287
+ expiresAt,
288
+ now,
289
+ buffer = Millis.of(0)
290
+ }) {
291
+ return now >= expiresAt - buffer;
292
+ }
293
+
212
294
  // src/universal/core/shared/blockchain/erc20/abi.ts
213
295
  var ERC20_ABI = [
214
296
  {
@@ -1069,7 +1151,11 @@ function formatAmount(amount, locale, options) {
1069
1151
  const decimal = formatRawAmount(amount);
1070
1152
  let [integerPart, fractionPart = ""] = decimal.split(".");
1071
1153
  const maxFractionDigits = options?.maxFractionDigits;
1072
- const minFractionDigits = maxFractionDigits !== void 0 ? Math.min(maxFractionDigits, amount.decimals) : Math.min(2, amount.decimals);
1154
+ const minFractionDigits = Math.min(
1155
+ options?.minFractionDigits ?? (maxFractionDigits !== void 0 ? maxFractionDigits : 2),
1156
+ maxFractionDigits ?? amount.decimals,
1157
+ amount.decimals
1158
+ );
1073
1159
  if (maxFractionDigits !== void 0 && fractionPart.length > maxFractionDigits) {
1074
1160
  ({ integerPart, fractionPart } = roundFractionHalfUp(
1075
1161
  integerPart,
@@ -1077,7 +1163,8 @@ function formatAmount(amount, locale, options) {
1077
1163
  maxFractionDigits
1078
1164
  ));
1079
1165
  }
1080
- const fraction = minFractionDigits === 0 ? "" : fractionPart.padEnd(minFractionDigits, "0");
1166
+ const trimmed = fractionPart.replace(/0+$/, "");
1167
+ const fraction = trimmed.padEnd(minFractionDigits, "0");
1081
1168
  const integerFormatted = BigInt(integerPart).toLocaleString(locale);
1082
1169
  if (minFractionDigits === 0 && fraction === "") {
1083
1170
  return FormattedAmountUi(integerFormatted);
@@ -1146,6 +1233,14 @@ function assetAmount(amount, symbol) {
1146
1233
  return FormattedAmountAssetUi(`${amount} ${symbol}`);
1147
1234
  }
1148
1235
  var NA_AMOUNT_ASSET_UI = FormattedAmountAssetUi("-");
1236
+ var SHARE_MAX_FRACTION_DIGITS = AssetDecimals(6);
1237
+ var SHARE_MIN_FRACTION_DIGITS = AssetDecimals(2);
1238
+ function formatShareAmount(amount, locale) {
1239
+ return formatAmount(amount, locale, {
1240
+ maxFractionDigits: SHARE_MAX_FRACTION_DIGITS,
1241
+ minFractionDigits: SHARE_MIN_FRACTION_DIGITS
1242
+ });
1243
+ }
1149
1244
  var USD_FRACTION_DIGITS = AssetDecimals(2);
1150
1245
  function formattedUsdPrice(amount, locale) {
1151
1246
  if (!amount) return NA_AMOUNT_ASSET_UI;
@@ -2944,11 +3039,18 @@ var HttpClient = class {
2944
3039
  );
2945
3040
  let response = await this.executeRequest(preparedRequest);
2946
3041
  for (const middleware of this.middleware.afterRequest ?? []) {
3042
+ let retried = false;
2947
3043
  response = await middleware({
2948
3044
  request: preparedRequest,
2949
3045
  response,
2950
- retry: (nextRequest = preparedRequest) => this.runRequestWithAfterMiddleware(nextRequest)
3046
+ retry: (nextRequest = preparedRequest) => {
3047
+ retried = true;
3048
+ return this.runRequestWithAfterMiddleware(nextRequest);
3049
+ }
2951
3050
  });
3051
+ if (retried) {
3052
+ return response;
3053
+ }
2952
3054
  }
2953
3055
  return response;
2954
3056
  }
@@ -3394,6 +3496,9 @@ export {
3394
3496
  VERIFY_IDENTITY_PATH,
3395
3497
  VERIFY_IDENTITY_ACCREDITATION_PATH,
3396
3498
  WALLET_PATH,
3499
+ SentWith,
3500
+ TokenTrigger,
3501
+ isRejectedToken,
3397
3502
  Attributes,
3398
3503
  HttpError,
3399
3504
  apiErrorCode,
@@ -3406,6 +3511,10 @@ export {
3406
3511
  describeErrorUnredacted,
3407
3512
  internalLogger,
3408
3513
  HttpClient,
3514
+ EpochMillis,
3515
+ Millis,
3516
+ Seconds,
3517
+ isExpired,
3409
3518
  ERC20_ABI,
3410
3519
  fetchAllPages,
3411
3520
  Cursor,
@@ -3473,6 +3582,7 @@ export {
3473
3582
  usdAmount,
3474
3583
  assetAmount,
3475
3584
  NA_AMOUNT_ASSET_UI,
3585
+ formatShareAmount,
3476
3586
  formattedUsdPrice,
3477
3587
  viemChain,
3478
3588
  getChainId,
@@ -3521,4 +3631,4 @@ export {
3521
3631
  OAuthRefreshToken,
3522
3632
  OAuthSession
3523
3633
  };
3524
- //# sourceMappingURL=chunk-MOE5S6CE.js.map
3634
+ //# sourceMappingURL=chunk-BNMF2HMW.js.map