add token type on token instructions + symbol on amount (#12398)
This commit is contained in:
parent
6563726f22
commit
bb72cbe7ae
|
@ -19,6 +19,8 @@ import {
|
||||||
} from "providers/accounts";
|
} from "providers/accounts";
|
||||||
import { normalizeTokenAmount } from "utils";
|
import { normalizeTokenAmount } from "utils";
|
||||||
import { reportError } from "utils/sentry";
|
import { reportError } from "utils/sentry";
|
||||||
|
import { useCluster } from "providers/cluster";
|
||||||
|
import { TokenRegistry } from "tokenRegistry";
|
||||||
|
|
||||||
type DetailsProps = {
|
type DetailsProps = {
|
||||||
tx: ParsedTransaction;
|
tx: ParsedTransaction;
|
||||||
|
@ -81,6 +83,7 @@ function TokenInstruction(props: InfoProps) {
|
||||||
const tokenInfo = useTokenAccountInfo(tokenAddress);
|
const tokenInfo = useTokenAccountInfo(tokenAddress);
|
||||||
const mintAddress = infoMintAddress || tokenInfo?.mint.toBase58();
|
const mintAddress = infoMintAddress || tokenInfo?.mint.toBase58();
|
||||||
const mintInfo = useMintAccountInfo(mintAddress);
|
const mintInfo = useMintAccountInfo(mintAddress);
|
||||||
|
const { cluster } = useCluster();
|
||||||
const fetchAccountInfo = useFetchAccountInfo();
|
const fetchAccountInfo = useFetchAccountInfo();
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
|
@ -97,6 +100,26 @@ function TokenInstruction(props: InfoProps) {
|
||||||
|
|
||||||
const decimals = mintInfo?.decimals;
|
const decimals = mintInfo?.decimals;
|
||||||
const attributes = [];
|
const attributes = [];
|
||||||
|
|
||||||
|
let tokenSymbol = "";
|
||||||
|
|
||||||
|
if (mintAddress) {
|
||||||
|
const tokenDetails = TokenRegistry.get(mintAddress, cluster);
|
||||||
|
|
||||||
|
if (tokenDetails && "symbol" in tokenDetails) {
|
||||||
|
tokenSymbol = tokenDetails.symbol;
|
||||||
|
}
|
||||||
|
|
||||||
|
attributes.push(
|
||||||
|
<tr key={mintAddress}>
|
||||||
|
<td>Token</td>
|
||||||
|
<td className="text-lg-right">
|
||||||
|
<Address pubkey={new PublicKey(mintAddress)} alignRight link />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
for (let key in props.info) {
|
for (let key in props.info) {
|
||||||
const value = props.info[key];
|
const value = props.info[key];
|
||||||
if (value === undefined) continue;
|
if (value === undefined) continue;
|
||||||
|
@ -116,7 +139,11 @@ function TokenInstruction(props: InfoProps) {
|
||||||
maximumFractionDigits: decimals,
|
maximumFractionDigits: decimals,
|
||||||
}).format(normalizeTokenAmount(value, decimals));
|
}).format(normalizeTokenAmount(value, decimals));
|
||||||
}
|
}
|
||||||
tag = <>{amount}</>;
|
tag = (
|
||||||
|
<>
|
||||||
|
{amount} {tokenSymbol}
|
||||||
|
</>
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
tag = <>{value}</>;
|
tag = <>{value}</>;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue