@goodwidget/ai-credits-widget 0.1.11 → 0.1.12

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.
@@ -7,7 +7,7 @@ import {
7
7
  buildQuoteAmounts,
8
8
  buildSetOperatorPayload,
9
9
  totalCreditUsdFromProfile
10
- } from "../chunk-3QY3YZDH.js";
10
+ } from "../chunk-HFKD7MN7.js";
11
11
 
12
12
  // src/mocked/AiCreditsMockWidget.tsx
13
13
  import { useMemo } from "react";
package/dist/register.cjs CHANGED
@@ -141,20 +141,21 @@ function formatGValue(amount) {
141
141
  if (value < 0.01) return "<0.01";
142
142
  return gGrouped.format(value);
143
143
  }
144
- function formatGAmount(amount) {
145
- return `${formatGValue(amount)} G$`;
146
- }
147
144
  function isGValueCompacted(amount) {
148
145
  const value = toNumber(amount);
149
146
  return Number.isFinite(value) && value >= G_COMPACT_FROM;
150
147
  }
151
- function formatExactGAmount(amount) {
148
+ function formatExactGValue(amount) {
152
149
  const value = toNumber(amount);
153
- if (!Number.isFinite(value) || value <= 0) return "0 G$";
154
- return `${gGrouped.format(value)} G$`;
150
+ if (!Number.isFinite(value) || value <= 0) return "0";
151
+ if (value < 0.01) return "<0.01";
152
+ return gGrouped.format(value);
153
+ }
154
+ function formatExactGAmount(amount) {
155
+ return `${formatExactGValue(amount)} G$`;
155
156
  }
156
- function formatGWeiAmount(amountWei) {
157
- return formatGAmount(weiToNumber(amountWei));
157
+ function formatExactGWeiAmount(amountWei) {
158
+ return formatExactGAmount(weiToNumber(amountWei));
158
159
  }
159
160
  function formatUsdValue(amount) {
160
161
  const value = toNumber(amount);
@@ -182,7 +183,7 @@ var G_COMPACT_FROM, USD_MIN_VISIBLE, gGrouped, gCompact, usdGrouped;
182
183
  var init_format = __esm({
183
184
  "src/format.ts"() {
184
185
  "use strict";
185
- G_COMPACT_FROM = 1e6;
186
+ G_COMPACT_FROM = 1e3;
186
187
  USD_MIN_VISIBLE = 5e-3;
187
188
  gGrouped = new Intl.NumberFormat("en-US", {
188
189
  minimumFractionDigits: 0,
@@ -190,7 +191,7 @@ var init_format = __esm({
190
191
  });
191
192
  gCompact = new Intl.NumberFormat("en-US", {
192
193
  notation: "compact",
193
- maximumFractionDigits: 2
194
+ maximumFractionDigits: 1
194
195
  });
195
196
  usdGrouped = new Intl.NumberFormat("en-US", {
196
197
  minimumFractionDigits: 2,
@@ -1609,9 +1610,9 @@ var init_paymentErrors = __esm({
1609
1610
  function formatMinGDisplay(amountWei) {
1610
1611
  const raw = Number(amountWei) / 1e18;
1611
1612
  if (!Number.isFinite(raw) || raw <= 0) return "0";
1612
- if (raw >= 1e3) return formatGValue(Math.ceil(raw));
1613
- if (raw >= 10) return formatGValue(Math.ceil(raw * 10) / 10);
1614
- return formatGValue(Math.ceil(raw * 100) / 100);
1613
+ if (raw >= 1e3) return formatExactGValue(Math.ceil(raw));
1614
+ if (raw >= 10) return formatExactGValue(Math.ceil(raw * 10) / 10);
1615
+ return formatExactGValue(Math.ceil(raw * 100) / 100);
1615
1616
  }
1616
1617
  function formatMinUsdDisplay(usd) {
1617
1618
  return formatUsdDisplay(usd);
@@ -5137,7 +5138,7 @@ function formatEntryGAmount(gdAmountWei) {
5137
5138
  try {
5138
5139
  const amountWei = BigInt(gdAmountWei || "0");
5139
5140
  if (amountWei <= 0n) return null;
5140
- return formatGWeiAmount(amountWei);
5141
+ return formatExactGWeiAmount(amountWei);
5141
5142
  } catch {
5142
5143
  return null;
5143
5144
  }
@@ -5236,7 +5237,7 @@ function sumFilteredGdWei(entries) {
5236
5237
  }, 0n);
5237
5238
  }
5238
5239
  function formatAccumulatedG(amountWei) {
5239
- return formatGAmount(Number(amountWei) / 1e18);
5240
+ return formatExactGAmount(Number(amountWei) / 1e18);
5240
5241
  }
5241
5242
  function formatShortDate(dateValue) {
5242
5243
  const date = /* @__PURE__ */ new Date(`${dateValue}T00:00:00.000Z`);