@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/{chunk-3QY3YZDH.js → chunk-5AGZTMIN.js} +30 -19
- package/dist/chunk-5AGZTMIN.js.map +1 -0
- package/dist/element.cjs +29 -18
- package/dist/element.cjs.map +1 -1
- package/dist/element.js +1 -1
- package/dist/index.cjs +29 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/mocked/index.cjs +29 -18
- package/dist/mocked/index.cjs.map +1 -1
- package/dist/mocked/index.js +1 -1
- package/dist/register.cjs +34 -19
- package/dist/register.cjs.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-3QY3YZDH.js.map +0 -1
package/dist/index.js
CHANGED
package/dist/mocked/index.cjs
CHANGED
|
@@ -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 =
|
|
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:
|
|
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
|
|
197
|
+
function formatExactGValue(amount) {
|
|
201
198
|
const value = toNumber(amount);
|
|
202
|
-
if (!Number.isFinite(value) || value <= 0) return "0
|
|
203
|
-
|
|
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
|
|
206
|
-
return
|
|
206
|
+
function formatExactGWeiAmount(amountWei) {
|
|
207
|
+
return formatExactGAmount(weiToNumber(amountWei));
|
|
207
208
|
}
|
|
208
209
|
function formatUsdValue(amount) {
|
|
209
210
|
const value = toNumber(amount);
|
|
@@ -988,7 +989,10 @@ var ANTSEED_BUYER_OPERATOR_DOMAIN = {
|
|
|
988
989
|
};
|
|
989
990
|
var WITHDRAW_PRINCIPAL_TYPES = {
|
|
990
991
|
WithdrawPrincipal: [
|
|
991
|
-
|
|
992
|
+
// `buyer` is the contract's field name; the value is our signer address.
|
|
993
|
+
// EIP-712 hashes field names, so renaming this to `signer` changes the
|
|
994
|
+
// struct hash and the vault rejects the withdrawal with InvalidSignature().
|
|
995
|
+
{ name: "buyer", type: "address" },
|
|
992
996
|
{ name: "amount", type: "uint256" },
|
|
993
997
|
{ name: "recipient", type: "address" },
|
|
994
998
|
{ name: "nonce", type: "uint256" }
|
|
@@ -1024,7 +1028,7 @@ async function signWithdrawPrincipal(params) {
|
|
|
1024
1028
|
types: WITHDRAW_PRINCIPAL_TYPES,
|
|
1025
1029
|
primaryType: "WithdrawPrincipal",
|
|
1026
1030
|
message: {
|
|
1027
|
-
|
|
1031
|
+
buyer: params.signer,
|
|
1028
1032
|
amount: params.amountMicro,
|
|
1029
1033
|
recipient: params.recipient,
|
|
1030
1034
|
nonce: params.nonce
|
|
@@ -1558,9 +1562,9 @@ var VAULT_MINIMUMS_ABI = (0, import_viem7.parseAbi)([
|
|
|
1558
1562
|
function formatMinGDisplay(amountWei) {
|
|
1559
1563
|
const raw = Number(amountWei) / 1e18;
|
|
1560
1564
|
if (!Number.isFinite(raw) || raw <= 0) return "0";
|
|
1561
|
-
if (raw >= 1e3) return
|
|
1562
|
-
if (raw >= 10) return
|
|
1563
|
-
return
|
|
1565
|
+
if (raw >= 1e3) return formatExactGValue(Math.ceil(raw));
|
|
1566
|
+
if (raw >= 10) return formatExactGValue(Math.ceil(raw * 10) / 10);
|
|
1567
|
+
return formatExactGValue(Math.ceil(raw * 100) / 100);
|
|
1564
1568
|
}
|
|
1565
1569
|
function formatMinUsdDisplay(usd) {
|
|
1566
1570
|
return formatUsdDisplay(usd);
|
|
@@ -3238,6 +3242,12 @@ var import_react18 = __toESM(require("react"), 1);
|
|
|
3238
3242
|
var import_core3 = require("@goodwidget/core");
|
|
3239
3243
|
var import_ui20 = require("@goodwidget/ui");
|
|
3240
3244
|
|
|
3245
|
+
// package.json
|
|
3246
|
+
var version = "0.1.13";
|
|
3247
|
+
|
|
3248
|
+
// src/AiCreditsWidget.tsx
|
|
3249
|
+
var import_ui21 = require("@goodwidget/ui");
|
|
3250
|
+
|
|
3241
3251
|
// src/useAiCreditsHistory.ts
|
|
3242
3252
|
var import_react2 = require("react");
|
|
3243
3253
|
var HISTORY_PAGE_SIZE = 10;
|
|
@@ -4954,7 +4964,7 @@ function formatEntryGAmount(gdAmountWei) {
|
|
|
4954
4964
|
try {
|
|
4955
4965
|
const amountWei = BigInt(gdAmountWei || "0");
|
|
4956
4966
|
if (amountWei <= 0n) return null;
|
|
4957
|
-
return
|
|
4967
|
+
return formatExactGWeiAmount(amountWei);
|
|
4958
4968
|
} catch {
|
|
4959
4969
|
return null;
|
|
4960
4970
|
}
|
|
@@ -5053,7 +5063,7 @@ function sumFilteredGdWei(entries) {
|
|
|
5053
5063
|
}, 0n);
|
|
5054
5064
|
}
|
|
5055
5065
|
function formatAccumulatedG(amountWei) {
|
|
5056
|
-
return
|
|
5066
|
+
return formatExactGAmount(Number(amountWei) / 1e18);
|
|
5057
5067
|
}
|
|
5058
5068
|
function formatShortDate(dateValue) {
|
|
5059
5069
|
const date = /* @__PURE__ */ new Date(`${dateValue}T00:00:00.000Z`);
|
|
@@ -6774,7 +6784,8 @@ function AiCreditsWidget({
|
|
|
6774
6784
|
showWalletControls
|
|
6775
6785
|
}
|
|
6776
6786
|
),
|
|
6777
|
-
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui20.ToastContainer, {})
|
|
6787
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui20.ToastContainer, {}),
|
|
6788
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_ui21.WidgetVersion, { name: "AI Credits", version })
|
|
6778
6789
|
] })
|
|
6779
6790
|
}
|
|
6780
6791
|
);
|