@goodwidget/ai-credits-widget 0.1.11 → 0.1.13

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/element.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  AiCreditsWidget
3
- } from "./chunk-3QY3YZDH.js";
3
+ } from "./chunk-5AGZTMIN.js";
4
4
 
5
5
  // src/element.ts
6
6
  import { createMiniAppElement } from "@goodwidget/embed";
package/dist/index.cjs CHANGED
@@ -196,7 +196,7 @@ function clearDeepLinkArtifacts() {
196
196
  var import_viem = require("viem");
197
197
 
198
198
  // src/format.ts
199
- var G_COMPACT_FROM = 1e6;
199
+ var G_COMPACT_FROM = 1e3;
200
200
  var USD_MIN_VISIBLE = 5e-3;
201
201
  var gGrouped = new Intl.NumberFormat("en-US", {
202
202
  minimumFractionDigits: 0,
@@ -204,7 +204,7 @@ var gGrouped = new Intl.NumberFormat("en-US", {
204
204
  });
205
205
  var gCompact = new Intl.NumberFormat("en-US", {
206
206
  notation: "compact",
207
- maximumFractionDigits: 2
207
+ maximumFractionDigits: 1
208
208
  });
209
209
  var usdGrouped = new Intl.NumberFormat("en-US", {
210
210
  minimumFractionDigits: 2,
@@ -230,20 +230,21 @@ function formatGValue(amount) {
230
230
  if (value < 0.01) return "<0.01";
231
231
  return gGrouped.format(value);
232
232
  }
233
- function formatGAmount(amount) {
234
- return `${formatGValue(amount)} G$`;
235
- }
236
233
  function isGValueCompacted(amount) {
237
234
  const value = toNumber(amount);
238
235
  return Number.isFinite(value) && value >= G_COMPACT_FROM;
239
236
  }
240
- function formatExactGAmount(amount) {
237
+ function formatExactGValue(amount) {
241
238
  const value = toNumber(amount);
242
- if (!Number.isFinite(value) || value <= 0) return "0 G$";
243
- return `${gGrouped.format(value)} G$`;
239
+ if (!Number.isFinite(value) || value <= 0) return "0";
240
+ if (value < 0.01) return "<0.01";
241
+ return gGrouped.format(value);
242
+ }
243
+ function formatExactGAmount(amount) {
244
+ return `${formatExactGValue(amount)} G$`;
244
245
  }
245
- function formatGWeiAmount(amountWei) {
246
- return formatGAmount(weiToNumber(amountWei));
246
+ function formatExactGWeiAmount(amountWei) {
247
+ return formatExactGAmount(weiToNumber(amountWei));
247
248
  }
248
249
  function formatUsdValue(amount) {
249
250
  const value = toNumber(amount);
@@ -1037,7 +1038,10 @@ var ANTSEED_BUYER_OPERATOR_DOMAIN = {
1037
1038
  };
1038
1039
  var WITHDRAW_PRINCIPAL_TYPES = {
1039
1040
  WithdrawPrincipal: [
1040
- { name: "signer", type: "address" },
1041
+ // `buyer` is the contract's field name; the value is our signer address.
1042
+ // EIP-712 hashes field names, so renaming this to `signer` changes the
1043
+ // struct hash and the vault rejects the withdrawal with InvalidSignature().
1044
+ { name: "buyer", type: "address" },
1041
1045
  { name: "amount", type: "uint256" },
1042
1046
  { name: "recipient", type: "address" },
1043
1047
  { name: "nonce", type: "uint256" }
@@ -1073,7 +1077,7 @@ async function signWithdrawPrincipal(params) {
1073
1077
  types: WITHDRAW_PRINCIPAL_TYPES,
1074
1078
  primaryType: "WithdrawPrincipal",
1075
1079
  message: {
1076
- signer: params.signer,
1080
+ buyer: params.signer,
1077
1081
  amount: params.amountMicro,
1078
1082
  recipient: params.recipient,
1079
1083
  nonce: params.nonce
@@ -1607,9 +1611,9 @@ var VAULT_MINIMUMS_ABI = (0, import_viem7.parseAbi)([
1607
1611
  function formatMinGDisplay(amountWei) {
1608
1612
  const raw = Number(amountWei) / 1e18;
1609
1613
  if (!Number.isFinite(raw) || raw <= 0) return "0";
1610
- if (raw >= 1e3) return formatGValue(Math.ceil(raw));
1611
- if (raw >= 10) return formatGValue(Math.ceil(raw * 10) / 10);
1612
- return formatGValue(Math.ceil(raw * 100) / 100);
1614
+ if (raw >= 1e3) return formatExactGValue(Math.ceil(raw));
1615
+ if (raw >= 10) return formatExactGValue(Math.ceil(raw * 10) / 10);
1616
+ return formatExactGValue(Math.ceil(raw * 100) / 100);
1613
1617
  }
1614
1618
  function formatMinUsdDisplay(usd) {
1615
1619
  return formatUsdDisplay(usd);
@@ -3287,6 +3291,12 @@ var import_react18 = __toESM(require("react"), 1);
3287
3291
  var import_core3 = require("@goodwidget/core");
3288
3292
  var import_ui20 = require("@goodwidget/ui");
3289
3293
 
3294
+ // package.json
3295
+ var version = "0.1.13";
3296
+
3297
+ // src/AiCreditsWidget.tsx
3298
+ var import_ui21 = require("@goodwidget/ui");
3299
+
3290
3300
  // src/useAiCreditsHistory.ts
3291
3301
  var import_react2 = require("react");
3292
3302
  var HISTORY_PAGE_SIZE = 10;
@@ -5003,7 +5013,7 @@ function formatEntryGAmount(gdAmountWei) {
5003
5013
  try {
5004
5014
  const amountWei = BigInt(gdAmountWei || "0");
5005
5015
  if (amountWei <= 0n) return null;
5006
- return formatGWeiAmount(amountWei);
5016
+ return formatExactGWeiAmount(amountWei);
5007
5017
  } catch {
5008
5018
  return null;
5009
5019
  }
@@ -5102,7 +5112,7 @@ function sumFilteredGdWei(entries) {
5102
5112
  }, 0n);
5103
5113
  }
5104
5114
  function formatAccumulatedG(amountWei) {
5105
- return formatGAmount(Number(amountWei) / 1e18);
5115
+ return formatExactGAmount(Number(amountWei) / 1e18);
5106
5116
  }
5107
5117
  function formatShortDate(dateValue) {
5108
5118
  const date = /* @__PURE__ */ new Date(`${dateValue}T00:00:00.000Z`);
@@ -6823,7 +6833,8 @@ function AiCreditsWidget({
6823
6833
  showWalletControls
6824
6834
  }
6825
6835
  ),
6826
- /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui20.ToastContainer, {})
6836
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui20.ToastContainer, {}),
6837
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.WidgetVersion, { name: "AI Credits", version })
6827
6838
  ] })
6828
6839
  }
6829
6840
  );