@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.
package/dist/index.js CHANGED
@@ -27,7 +27,7 @@ import {
27
27
  totalCreditUsdFromStatus,
28
28
  usdToCredits,
29
29
  useAiCreditsAdapter
30
- } from "./chunk-3QY3YZDH.js";
30
+ } from "./chunk-HFKD7MN7.js";
31
31
  export {
32
32
  AiCreditsWidget,
33
33
  CELO_GOODID_ADDRESS,
@@ -156,7 +156,7 @@ function clearDeepLinkArtifacts() {
156
156
  var import_viem = require("viem");
157
157
 
158
158
  // src/format.ts
159
- var G_COMPACT_FROM = 1e6;
159
+ var G_COMPACT_FROM = 1e3;
160
160
  var USD_MIN_VISIBLE = 5e-3;
161
161
  var gGrouped = new Intl.NumberFormat("en-US", {
162
162
  minimumFractionDigits: 0,
@@ -164,7 +164,7 @@ var gGrouped = new Intl.NumberFormat("en-US", {
164
164
  });
165
165
  var gCompact = new Intl.NumberFormat("en-US", {
166
166
  notation: "compact",
167
- maximumFractionDigits: 2
167
+ maximumFractionDigits: 1
168
168
  });
169
169
  var usdGrouped = new Intl.NumberFormat("en-US", {
170
170
  minimumFractionDigits: 2,
@@ -190,20 +190,21 @@ function formatGValue(amount) {
190
190
  if (value < 0.01) return "<0.01";
191
191
  return gGrouped.format(value);
192
192
  }
193
- function formatGAmount(amount) {
194
- return `${formatGValue(amount)} G$`;
195
- }
196
193
  function isGValueCompacted(amount) {
197
194
  const value = toNumber(amount);
198
195
  return Number.isFinite(value) && value >= G_COMPACT_FROM;
199
196
  }
200
- function formatExactGAmount(amount) {
197
+ function formatExactGValue(amount) {
201
198
  const value = toNumber(amount);
202
- if (!Number.isFinite(value) || value <= 0) return "0 G$";
203
- return `${gGrouped.format(value)} G$`;
199
+ if (!Number.isFinite(value) || value <= 0) return "0";
200
+ if (value < 0.01) return "<0.01";
201
+ return gGrouped.format(value);
202
+ }
203
+ function formatExactGAmount(amount) {
204
+ return `${formatExactGValue(amount)} G$`;
204
205
  }
205
- function formatGWeiAmount(amountWei) {
206
- return formatGAmount(weiToNumber(amountWei));
206
+ function formatExactGWeiAmount(amountWei) {
207
+ return formatExactGAmount(weiToNumber(amountWei));
207
208
  }
208
209
  function formatUsdValue(amount) {
209
210
  const value = toNumber(amount);
@@ -1558,9 +1559,9 @@ var VAULT_MINIMUMS_ABI = (0, import_viem7.parseAbi)([
1558
1559
  function formatMinGDisplay(amountWei) {
1559
1560
  const raw = Number(amountWei) / 1e18;
1560
1561
  if (!Number.isFinite(raw) || raw <= 0) return "0";
1561
- if (raw >= 1e3) return formatGValue(Math.ceil(raw));
1562
- if (raw >= 10) return formatGValue(Math.ceil(raw * 10) / 10);
1563
- return formatGValue(Math.ceil(raw * 100) / 100);
1562
+ if (raw >= 1e3) return formatExactGValue(Math.ceil(raw));
1563
+ if (raw >= 10) return formatExactGValue(Math.ceil(raw * 10) / 10);
1564
+ return formatExactGValue(Math.ceil(raw * 100) / 100);
1564
1565
  }
1565
1566
  function formatMinUsdDisplay(usd) {
1566
1567
  return formatUsdDisplay(usd);
@@ -4954,7 +4955,7 @@ function formatEntryGAmount(gdAmountWei) {
4954
4955
  try {
4955
4956
  const amountWei = BigInt(gdAmountWei || "0");
4956
4957
  if (amountWei <= 0n) return null;
4957
- return formatGWeiAmount(amountWei);
4958
+ return formatExactGWeiAmount(amountWei);
4958
4959
  } catch {
4959
4960
  return null;
4960
4961
  }
@@ -5053,7 +5054,7 @@ function sumFilteredGdWei(entries) {
5053
5054
  }, 0n);
5054
5055
  }
5055
5056
  function formatAccumulatedG(amountWei) {
5056
- return formatGAmount(Number(amountWei) / 1e18);
5057
+ return formatExactGAmount(Number(amountWei) / 1e18);
5057
5058
  }
5058
5059
  function formatShortDate(dateValue) {
5059
5060
  const date = /* @__PURE__ */ new Date(`${dateValue}T00:00:00.000Z`);