@lukso/transaction-view-core 0.5.0-dev.a98e9bc → 0.5.0-dev.f500300

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.
@@ -10,24 +10,24 @@
10
10
  ESM Build start
11
11
  CJS Build start
12
12
  DTS Build start
13
- CJS dist/index.cjs 264.07 KB
14
- CJS dist/shared/index.cjs 208.67 KB
13
+ CJS dist/index.cjs 265.06 KB
14
+ CJS dist/shared/index.cjs 208.69 KB
15
15
  CJS dist/styles/index.cjs 131.97 KB
16
- CJS dist/index.cjs.map 359.99 KB
17
- CJS dist/shared/index.cjs.map 268.57 KB
16
+ CJS dist/index.cjs.map 363.28 KB
17
+ CJS dist/shared/index.cjs.map 270.84 KB
18
18
  CJS dist/styles/index.cjs.map 140.12 KB
19
- CJS ⚡️ Build success in 4769ms
20
- ESM dist/index.js 255.97 KB
21
- ESM dist/shared/index.js 203.25 KB
19
+ CJS ⚡️ Build success in 4994ms
20
+ ESM dist/index.js 256.95 KB
21
+ ESM dist/shared/index.js 203.27 KB
22
22
  ESM dist/styles/index.js 130.92 KB
23
- ESM dist/index.js.map 359.19 KB
24
- ESM dist/shared/index.js.map 267.70 KB
23
+ ESM dist/index.js.map 362.49 KB
24
+ ESM dist/shared/index.js.map 269.97 KB
25
25
  ESM dist/styles/index.js.map 140.06 KB
26
- ESM ⚡️ Build success in 4797ms
27
- DTS ⚡️ Build success in 11927ms
26
+ ESM ⚡️ Build success in 5001ms
27
+ DTS ⚡️ Build success in 12236ms
28
28
  DTS dist/styles/index.d.ts 233.00 B
29
- DTS dist/index.d.ts 14.07 KB
30
- DTS dist/shared/index.d.ts 23.56 KB
29
+ DTS dist/index.d.ts 14.06 KB
30
+ DTS dist/shared/index.d.ts 23.60 KB
31
31
  DTS dist/styles/index.d.cts 233.00 B
32
- DTS dist/index.d.cts 14.07 KB
33
- DTS dist/shared/index.d.cts 23.56 KB
32
+ DTS dist/index.d.cts 14.06 KB
33
+ DTS dist/shared/index.d.cts 23.60 KB
package/dist/index.cjs CHANGED
@@ -2045,6 +2045,8 @@ var import_transaction_view_headless6 = require("@lukso/transaction-view-headles
2045
2045
  var import_lit12 = require("lit");
2046
2046
  var import_decorators11 = require("lit/decorators.js");
2047
2047
  var import_when = require("lit/directives/when.js");
2048
+
2049
+ // src/utils.ts
2048
2050
  function formatUnits(value, decimals = 18) {
2049
2051
  const divisor = 10n ** BigInt(decimals);
2050
2052
  const quotient = value / divisor;
@@ -2056,6 +2058,30 @@ function formatUnits(value, decimals = 18) {
2056
2058
  const trimmed = remainderStr.replace(/0+$/, "");
2057
2059
  return `${quotient}.${trimmed}`;
2058
2060
  }
2061
+ function isBigIntString(str) {
2062
+ const trimmed = str.trim();
2063
+ if (trimmed.endsWith("n"))
2064
+ return /^[0-9]+n$/.test(trimmed) || /^0x[0-9a-fA-F]+n$/.test(trimmed);
2065
+ return /^[0-9]+$/.test(trimmed) || /^0x[0-9a-fA-F]+$/.test(trimmed);
2066
+ }
2067
+ function parseBigInt(value) {
2068
+ if (!value) return void 0;
2069
+ if (typeof value === "bigint") return value;
2070
+ if (typeof value === "number") {
2071
+ if (!Number.isInteger(value)) return void 0;
2072
+ return BigInt(value);
2073
+ }
2074
+ const trimmed = value.trim();
2075
+ const cleaned = trimmed.endsWith("n") ? trimmed.slice(0, -1) : trimmed;
2076
+ if (!isBigIntString(cleaned)) return void 0;
2077
+ try {
2078
+ return BigInt(cleaned);
2079
+ } catch {
2080
+ return void 0;
2081
+ }
2082
+ }
2083
+
2084
+ // src/shared/value-view.ts
2059
2085
  var ValueView = class extends CoreLitElement {
2060
2086
  constructor() {
2061
2087
  super(...arguments);
@@ -2288,7 +2314,7 @@ var ValueView = class extends CoreLitElement {
2288
2314
  `;
2289
2315
  if (effectiveType === "currency") {
2290
2316
  const { numeric, symbol } = this.getCurrencyParts();
2291
- if (this.label && this.label.trim() !== "") {
2317
+ if (this.label) {
2292
2318
  headerText = this.label;
2293
2319
  contentTemplate = import_lit12.html`
2294
2320
  <span class="inline-block overflow-hidden text-ellipsis whitespace-nowrap min-w-0 ${this.getNumericClass()}">${numeric}</span>
@@ -2997,22 +3023,10 @@ var import_when3 = require("lit/directives/when.js");
2997
3023
  var import_web_components = require("@lukso/web-components");
2998
3024
  var import_task6 = require("@lit/task");
2999
3025
  var import_transaction_view_headless8 = require("@lukso/transaction-view-headless");
3000
- function formatUnits2(value, decimals = 18) {
3001
- const divisor = 10n ** BigInt(decimals);
3002
- const quotient = value / divisor;
3003
- const remainder = value % divisor;
3004
- if (remainder === 0n) {
3005
- return quotient.toString();
3006
- }
3007
- const remainderStr = remainder.toString().padStart(decimals, "0");
3008
- const trimmed = remainderStr.replace(/0+$/, "");
3009
- return `${quotient}.${trimmed}`;
3010
- }
3011
3026
  var AssetCard = class extends CoreLitElement {
3012
3027
  constructor() {
3013
3028
  super(...arguments);
3014
3029
  this.functionIcon = "code-outline";
3015
- this.size = "medium";
3016
3030
  this.showInfoButton = true;
3017
3031
  this.showCreator = true;
3018
3032
  this.displayDetails = false;
@@ -3139,7 +3153,7 @@ var AssetCard = class extends CoreLitElement {
3139
3153
  const formattedTokenId = this._resolvedData?.formattedTokenId;
3140
3154
  const displayTokenId = formattedTokenId ? `${formattedTokenId}` : "";
3141
3155
  if (displayTokenId) return displayTokenId;
3142
- return this.tokenId && !this._resolvedData?.isCollection ? `${parseInt(this.tokenId, 16)}` : void 0;
3156
+ return this.tokenId ? `${parseInt(this.tokenId, 16)}` : void 0;
3143
3157
  }
3144
3158
  _renderTokenId() {
3145
3159
  const displayTokenId = this.displayedTokenId;
@@ -3197,6 +3211,7 @@ var AssetCard = class extends CoreLitElement {
3197
3211
  _renderImages() {
3198
3212
  const images = this._resolvedData?.images || [];
3199
3213
  if (images.length === 0) return "";
3214
+ if (!this.address) return "";
3200
3215
  return import_lit15.html`
3201
3216
  <image-list
3202
3217
  address=${this.address}
@@ -3209,6 +3224,7 @@ var AssetCard = class extends CoreLitElement {
3209
3224
  _renderAssets() {
3210
3225
  const assets = this._resolvedData?.assets || [];
3211
3226
  if (assets.length === 0) return "";
3227
+ if (!this.address) return "";
3212
3228
  return import_lit15.html`
3213
3229
  <div class="section">
3214
3230
  <div class="section-title">Assets</div>
@@ -3224,11 +3240,11 @@ var AssetCard = class extends CoreLitElement {
3224
3240
  return import_lit15.html`
3225
3241
  <div class="flex justify-between items-center my-4">
3226
3242
  <function-name-view
3227
- label=${this.functionName}
3228
- size="small"
3229
- icon=${this.functionIcon ? this.functionIcon : "code-outline"}
3243
+ label=${this.functionName || "Execute"}
3244
+ size="small"
3245
+ icon=${this.functionIcon ? this.functionIcon : "code-outline"}
3230
3246
  ></function-name-view>
3231
- <function-name-view label=${this._resolvedData?.standard} size="small"></function-name-view>
3247
+ <function-name-view label=${this._resolvedData?.standard ?? "Unknown"} size="small"></function-name-view>
3232
3248
  </div>
3233
3249
  `;
3234
3250
  }
@@ -3247,6 +3263,14 @@ var AssetCard = class extends CoreLitElement {
3247
3263
  </div>
3248
3264
  `;
3249
3265
  }
3266
+ _formattedAmount() {
3267
+ const data = this._resolutionTask.value;
3268
+ const amt = this.amount;
3269
+ if (amt === void 0 || amt === null || amt === "") return void 0;
3270
+ const bigintAmount = parseBigInt(amt);
3271
+ if (bigintAmount === void 0) return void 0;
3272
+ return formatUnits(bigintAmount, data?.decimals);
3273
+ }
3250
3274
  renderFormattedTokenIdBadge() {
3251
3275
  if (!this.displayedTokenId) return "";
3252
3276
  return import_lit15.html`
@@ -3257,51 +3281,61 @@ var AssetCard = class extends CoreLitElement {
3257
3281
  return import_lit15.html`
3258
3282
  <div >
3259
3283
  ${this._renderStandards()}
3260
- <div class="mt-6 flex-col">
3261
- <div class="flex items-center justify-center gap-4">
3262
- <div class="flex justify-end w-[48%]">
3263
- <div class="border relative border-neutral-90 rounded-xl">
3264
- ${this.renderFormattedTokenIdBadge()}
3265
- <div class="p-2 relative">
3266
- <icon-view
3267
- address="${this.address}"
3268
- size="2x-large"
3269
- .showName=${false}
3270
- ></icon-view>
3271
- </div>
3272
- <div style="height: 1px;" class="bg-neutral-90 w-full"></div>
3273
- <div class="px-2">
3274
- ${this._renderAddressSection()}
3284
+ <div class="mt-6 flex-col">
3285
+ <div class="flex items-center justify-center gap-4">
3286
+ <div class="flex justify-end w-[48%]">
3287
+ <div class="border relative border-neutral-90 rounded-xl">
3288
+ ${this.renderFormattedTokenIdBadge()}
3289
+ <div class="p-2 relative">
3290
+ ${(0, import_when3.when)(
3291
+ this.address,
3292
+ () => import_lit15.html`
3293
+ <icon-view
3294
+ address=${this.address ?? ""}
3295
+ size="2x-large"
3296
+ .showName=${false}
3297
+ ></icon-view>
3298
+ `
3299
+ )}
3300
+ </div>
3301
+ <div style="height: 1px;" class="bg-neutral-90 w-full"></div>
3302
+ <div class="px-2">
3303
+ ${this._renderAddressSection()}
3304
+ </div>
3275
3305
  </div>
3276
3306
  </div>
3277
- </div>
3278
3307
 
3279
- <div class="flex flex-col gap-1 w-[51%]">
3280
- <div class="text-[14px] font-bold text-neutral-20">
3281
- ${this._resolvedData?.lsp4TokenName || "UNKNOWN"}
3282
- </div>
3283
- <div class="text-[17px] font-semibold text-neutral-20">
3308
+ <div class="flex flex-col gap-1 w-[51%]">
3309
+ <div class="text-[14px] font-bold text-neutral-20">
3310
+ ${this._resolvedData?.lsp4TokenName || "UNKNOWN"}
3311
+ </div>
3312
+ <div class="text-[17px] font-semibold text-neutral-20">
3313
+ ${(0, import_when3.when)(
3314
+ this.amount,
3315
+ () => import_lit15.html`
3316
+ <span class="">${this._formattedAmount() ?? ""}</span>
3317
+ <span class="ml-1 text-neutral-60 max-w-[60px] whitespace-nowrap overflow-hidden text-ellipsis text-[14px] font-semibold">${this._resolvedData?.lsp4TokenSymbol || ""}</span>
3318
+ `,
3319
+ () => import_lit15.html`${this._resolvedData?.lsp4TokenSymbol || ""}`
3320
+ )}
3321
+ </div>
3322
+
3284
3323
  ${(0, import_when3.when)(
3285
3324
  this.amount,
3286
3325
  () => import_lit15.html`
3287
- <span class="">${formatUnits2(BigInt(this.amount || 0), this._resolvedData?.decimals)}</span>
3326
+ <span class="">${formatUnits(BigInt(this.amount || 0), this._resolvedData?.decimals)}</span>
3288
3327
  <span class="ml-1 text-neutral-60 max-w-[60px] whitespace-nowrap overflow-hidden text-ellipsis text-[14px] font-semibold">${this._resolvedData?.lsp4TokenSymbol || ""}</span>
3289
3328
  `,
3290
3329
  () => import_lit15.html`${this._resolvedData?.lsp4TokenSymbol || ""}`
3291
3330
  )}
3292
- </div>
3293
-
3294
- ${(0, import_when3.when)(
3295
- this.displayedTokenId,
3296
- () => import_lit15.html`<div class="text-[14px] font-medium text-neutral-60"><span class="font-bold">#${this.displayedTokenId}</span></div>`
3297
- )}
3298
- <div class="mt-4">
3299
- ${(0, import_when3.when)(this.showCreator, () => this._renderCreatorSection())}
3331
+ <div class="mt-4">
3332
+ ${(0, import_when3.when)(this.showCreator, () => this._renderCreatorSection())}
3333
+ </div>
3300
3334
  </div>
3301
3335
  </div>
3302
- </div>
3303
- <div class="border-neutral-90 pt-2">
3304
- ${this._renderTokenDetails()}
3336
+ <div class="border-neutral-90 pt-2">
3337
+ ${this._renderTokenDetails()}
3338
+ </div>
3305
3339
  </div>
3306
3340
  </div>
3307
3341
  `;
@@ -3325,9 +3359,6 @@ __decorateClass([
3325
3359
  __decorateClass([
3326
3360
  (0, import_decorators14.property)({ type: String, attribute: "function-icon" })
3327
3361
  ], AssetCard.prototype, "functionIcon", 2);
3328
- __decorateClass([
3329
- (0, import_decorators14.property)({ type: String })
3330
- ], AssetCard.prototype, "size", 2);
3331
3362
  __decorateClass([
3332
3363
  (0, import_decorators14.property)({ type: Boolean, attribute: "show-info-button" })
3333
3364
  ], AssetCard.prototype, "showInfoButton", 2);