@unicitylabs/uniclaw 0.1.0 → 0.1.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.
- package/package.json +1 -1
- package/src/assets.ts +10 -7
package/package.json
CHANGED
package/src/assets.ts
CHANGED
|
@@ -50,9 +50,10 @@ function loadRegistry(): AssetRegistry {
|
|
|
50
50
|
const name = entry.name;
|
|
51
51
|
const symbol = entry.symbol;
|
|
52
52
|
|
|
53
|
-
// Map
|
|
53
|
+
// Map name, symbol (lowercase), and coin id to the faucet coin name
|
|
54
54
|
aliases.set(name.toLowerCase(), name);
|
|
55
55
|
aliases.set(symbol.toLowerCase(), name);
|
|
56
|
+
aliases.set(entry.id, name);
|
|
56
57
|
|
|
57
58
|
// Store display symbol and decimals
|
|
58
59
|
symbols.set(name, symbol);
|
|
@@ -73,16 +74,18 @@ export function resolveCoinId(input: string): string | null {
|
|
|
73
74
|
return registry.aliases.get(input.toLowerCase().trim()) ?? null;
|
|
74
75
|
}
|
|
75
76
|
|
|
76
|
-
/** Get display symbol for a
|
|
77
|
-
export function getCoinSymbol(
|
|
77
|
+
/** Get display symbol for a coin (accepts name, symbol, or coin id) */
|
|
78
|
+
export function getCoinSymbol(coin: string): string {
|
|
78
79
|
const registry = loadRegistry();
|
|
79
|
-
|
|
80
|
+
const name = registry.aliases.get(coin) ?? registry.aliases.get(coin.toLowerCase()) ?? coin;
|
|
81
|
+
return registry.symbols.get(name) ?? coin.toUpperCase();
|
|
80
82
|
}
|
|
81
83
|
|
|
82
|
-
/** Get decimals for a
|
|
83
|
-
export function getCoinDecimals(
|
|
84
|
+
/** Get decimals for a coin (accepts name, symbol, or coin id) */
|
|
85
|
+
export function getCoinDecimals(coin: string): number | undefined {
|
|
84
86
|
const registry = loadRegistry();
|
|
85
|
-
|
|
87
|
+
const name = registry.aliases.get(coin) ?? registry.aliases.get(coin.toLowerCase());
|
|
88
|
+
return name ? registry.decimals.get(name) : registry.decimals.get(coin);
|
|
86
89
|
}
|
|
87
90
|
|
|
88
91
|
/** Get list of all available symbols for display */
|