@le-space/ui 0.1.56 → 0.1.57

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@le-space/ui",
3
- "version": "0.1.56",
3
+ "version": "0.1.57",
4
4
  "description": "Floating Aleph sponsor relay UI components for Svelte and React.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -36,9 +36,9 @@
36
36
  "access": "public"
37
37
  },
38
38
  "dependencies": {
39
- "@noble/hashes": "^1.8.0",
40
- "@le-space/browser": "0.1.52",
41
- "@le-space/core": "0.1.52"
39
+ "@le-space/browser": "0.1.57",
40
+ "@le-space/core": "0.1.57",
41
+ "viem": "^2.38.5"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "react": ">=18",
package/react/index.js CHANGED
@@ -48,7 +48,8 @@ function formatNumber(value, digits = 0) {
48
48
  }
49
49
  function formatDateTime(value) {
50
50
  if (!value) return "-";
51
- const date = typeof value === "number" ? new Date(value) : new Date(value);
51
+ const normalizedValue = typeof value === "number" && value > 0 && value < 1e10 ? value * 1e3 : value;
52
+ const date = typeof normalizedValue === "number" ? new Date(normalizedValue) : new Date(normalizedValue);
52
53
  if (Number.isNaN(date.getTime())) return String(value);
53
54
  return date.toLocaleString();
54
55
  }
@@ -183,7 +184,7 @@ async function fetchInstances(address, apiHost = DEFAULT_ALEPH_API_HOST) {
183
184
  const payload = await response.json();
184
185
  return (payload.messages ?? []).map((message) => ({
185
186
  ...message,
186
- status: typeof message.status === "string" && message.status.trim() ? message.status : message.confirmed ? "processed" : message.status
187
+ status: typeof message.status === "string" && message.status.trim() ? message.status : message.confirmed ? "processed" : "pending"
187
188
  }));
188
189
  }
189
190
  async function fetch2n6WebAccessUrl(itemHash, twoN6ApiHost = DEFAULT_2N6_API_HOST) {
@@ -709,21 +710,16 @@ function resolveManifestSource(args) {
709
710
  }
710
711
 
711
712
  // src/shared/wallet-controller.ts
712
- import { keccak_256 } from "@noble/hashes/sha3";
713
+ import { getAddress } from "viem";
713
714
  function getEthereumProvider() {
714
715
  return globalThis.window?.ethereum ?? null;
715
716
  }
716
717
  function toChecksumAddress(address) {
717
- if (!/^0x[0-9a-fA-F]{40}$/.test(address)) {
718
+ try {
719
+ return getAddress(address);
720
+ } catch {
718
721
  throw new Error("Invalid EVM address.");
719
722
  }
720
- const normalized = address.slice(2).toLowerCase();
721
- const hash = Array.from(keccak_256(new TextEncoder().encode(normalized))).map((byte) => byte.toString(16).padStart(2, "0")).join("");
722
- let result = "0x";
723
- for (let index = 0; index < normalized.length; index += 1) {
724
- result += Number.parseInt(hash[index], 16) >= 8 ? normalized[index].toUpperCase() : normalized[index];
725
- }
726
- return result;
727
723
  }
728
724
  async function connectWallet(provider = getEthereumProvider()) {
729
725
  if (!provider) {
package/shared/index.js CHANGED
@@ -45,7 +45,8 @@ function formatNumber(value, digits = 0) {
45
45
  }
46
46
  function formatDateTime(value) {
47
47
  if (!value) return "-";
48
- const date = typeof value === "number" ? new Date(value) : new Date(value);
48
+ const normalizedValue = typeof value === "number" && value > 0 && value < 1e10 ? value * 1e3 : value;
49
+ const date = typeof normalizedValue === "number" ? new Date(normalizedValue) : new Date(normalizedValue);
49
50
  if (Number.isNaN(date.getTime())) return String(value);
50
51
  return date.toLocaleString();
51
52
  }
@@ -180,7 +181,7 @@ async function fetchInstances(address, apiHost = DEFAULT_ALEPH_API_HOST) {
180
181
  const payload = await response.json();
181
182
  return (payload.messages ?? []).map((message) => ({
182
183
  ...message,
183
- status: typeof message.status === "string" && message.status.trim() ? message.status : message.confirmed ? "processed" : message.status
184
+ status: typeof message.status === "string" && message.status.trim() ? message.status : message.confirmed ? "processed" : "pending"
184
185
  }));
185
186
  }
186
187
  async function fetch2n6WebAccessUrl(itemHash, twoN6ApiHost = DEFAULT_2N6_API_HOST) {
@@ -706,21 +707,16 @@ function resolveManifestSource(args) {
706
707
  }
707
708
 
708
709
  // src/shared/wallet-controller.ts
709
- import { keccak_256 } from "@noble/hashes/sha3";
710
+ import { getAddress } from "viem";
710
711
  function getEthereumProvider() {
711
712
  return globalThis.window?.ethereum ?? null;
712
713
  }
713
714
  function toChecksumAddress(address) {
714
- if (!/^0x[0-9a-fA-F]{40}$/.test(address)) {
715
+ try {
716
+ return getAddress(address);
717
+ } catch {
715
718
  throw new Error("Invalid EVM address.");
716
719
  }
717
- const normalized = address.slice(2).toLowerCase();
718
- const hash = Array.from(keccak_256(new TextEncoder().encode(normalized))).map((byte) => byte.toString(16).padStart(2, "0")).join("");
719
- let result = "0x";
720
- for (let index = 0; index < normalized.length; index += 1) {
721
- result += Number.parseInt(hash[index], 16) >= 8 ? normalized[index].toUpperCase() : normalized[index];
722
- }
723
- return result;
724
720
  }
725
721
  async function connectWallet(provider = getEthereumProvider()) {
726
722
  if (!provider) {