Get displayDenomExponent from chain registry
This commit is contained in:
@@ -9,6 +9,7 @@ import { useAppContext } from "../../context/AppContext";
|
||||
import Select from "../inputs/Select";
|
||||
import StackableContainer from "../layout/StackableContainer";
|
||||
import { assert } from "@cosmjs/utils";
|
||||
import { ChainRegistryAsset } from "./chainregistry";
|
||||
|
||||
interface ChainOption {
|
||||
label: string;
|
||||
@@ -141,11 +142,12 @@ const ChainSelect = () => {
|
||||
setChainError("Multiple token denoms available, enter manually");
|
||||
setShowSettings(true);
|
||||
} else {
|
||||
const asset = assetData.assets[0];
|
||||
const asset: ChainRegistryAsset = assetData.assets[0];
|
||||
denom = asset.base;
|
||||
displayDenom = asset.symbol;
|
||||
gasPrice = `0.03${asset.base}`;
|
||||
displayDenomExponent = 6; // TODO: determine dynamically
|
||||
const displayUnit = asset.denom_units.find((u) => u.denom == asset.display);
|
||||
displayDenomExponent = displayUnit?.exponent ?? 6;
|
||||
}
|
||||
|
||||
// test client connection
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* See https://github.com/cosmos/chain-registry/blob/1e9ecde770951cab90f0853a624411d79af90b83/provenance/assetlist.json#L8-L12
|
||||
*/
|
||||
export interface ChainRegistryDemonUnit {
|
||||
denom: string;
|
||||
exponent: number;
|
||||
aliases: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* See https://github.com/cosmos/chain-registry/blob/1e9ecde770951cab90f0853a624411d79af90b83/provenance/assetlist.json#L5-L28
|
||||
*/
|
||||
export interface ChainRegistryAsset {
|
||||
description: string;
|
||||
denom_units: ChainRegistryDemonUnit[];
|
||||
base: string;
|
||||
name: string;
|
||||
display: string;
|
||||
symbol: string;
|
||||
logo_URIs: {
|
||||
png: string;
|
||||
svg: string;
|
||||
};
|
||||
coingecko_id: string;
|
||||
}
|
||||
Reference in New Issue
Block a user