@kheopskit/core 0.0.1-alpha.1 → 0.0.2

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.
@@ -0,0 +1,36 @@
1
+ import type { WalletAccount } from "@/api";
2
+
3
+ export const sortAccounts = (a1: WalletAccount, a2: WalletAccount) => {
4
+ if (a1.platform === "polkadot") {
5
+ if (a2.platform === "polkadot") {
6
+ // sort by wallet name, fallback to address
7
+ if (a1.walletName !== a2.walletName) {
8
+ if (a1.walletName === "talisman") return -1;
9
+ if (a2.walletName === "talisman") return 1;
10
+ return a1.walletName.localeCompare(a2.walletName);
11
+ }
12
+
13
+ // sort by name, fallback to address
14
+ return a1.name !== a2.name
15
+ ? (a1.name ?? "").localeCompare(a2.name ?? "")
16
+ : a1.address.localeCompare(a2.address);
17
+ }
18
+
19
+ return -1; // polkadot accounts first
20
+ }
21
+
22
+ if (a2.platform === "ethereum") {
23
+ // sort by wallet name, fallback to address
24
+ if (a1.walletName !== a2.walletName) {
25
+ if (a1.walletName === "Talisman") return -1;
26
+ if (a2.walletName === "Talisman") return 1;
27
+ return a1.walletName.localeCompare(a2.walletName);
28
+ }
29
+
30
+ // keep order as provider by the wallet
31
+ return 0;
32
+ }
33
+
34
+ // impossible case
35
+ return 0;
36
+ };
@@ -0,0 +1,14 @@
1
+ import type { Wallet } from "@/api";
2
+
3
+ export const sortWallets = (w1: Wallet, w2: Wallet) => {
4
+ // Sort by platform first: polkadot first, then ethereum
5
+ if (w1.platform !== w2.platform) {
6
+ return w1.platform === "polkadot" ? -1 : 1;
7
+ }
8
+
9
+ // Sort by name, but Talisman first
10
+ if (w1.name.toLowerCase() === "talisman") return -1;
11
+ if (w2.name.toLowerCase() === "talisman") return 1;
12
+
13
+ return w1.name.localeCompare(w2.name);
14
+ };
@@ -1,3 +0,0 @@
1
- export const isTruthy = <T>(
2
- value: T | null | undefined | false | 0 | ""
3
- ): value is T => !!value;
@@ -1,5 +0,0 @@
1
- // TODO: mnve file to its own @kheopswap/types package ?
2
-
3
- export type AccountAddressType = "ss58" | "ethereum";
4
-
5
- export type UnsubscribeFn = () => void;