@@ -30,20 +26,19 @@ export const SignedExtensions: FC<{
const SignedExtension: FC<{ id: string; value: unknown }> = ({ id, value }) => {
const knownExtension = knownSignedExtensions[id]
if (knownExtension) {
- const { expanded: ExpandedView, inline: InlineView } = knownExtension
- return ExpandedView ? (
- : null}
- >
-
-
- ) : InlineView ? (
- : null}
- />
- ) : null
+ const { expanded, inline } = knownExtension
+ const expandedElement = expanded?.(value)
+ const inlineElement = inline?.(value)
+ if (expandedElement) {
+ return (
+
+ {expandedElement}
+
+ )
+ }
+ if (inlineElement) {
+ return
+ }
}
const inlineJson = JSON.stringify(value, jsonSerialize)
@@ -59,13 +54,27 @@ const SignedExtension: FC<{ id: string; value: unknown }> = ({ id, value }) => {
export const knownSignedExtensions: Record<
string,
{
- inline?: ComponentType<{ id: string; value: unknown }>
- expanded?: ComponentType<{ id: string; value: unknown }>
+ inline?: (value: any) => ReactNode
+ expanded?: (value: any) => ReactNode
}
> = {
CheckMortality: {
- expanded: ({ value }) => ,
- inline: ({ value }) => ,
+ expanded: (value) => ,
+ inline: (value) => ,
+ },
+ ChargeAssetTxPayment: {
+ inline: (value) =>
+ value.asset_id ? (
+ canDecodeAsset(value) ? (
+
+ ) : null
+ ) : (
+
+ {value.tip}
+ {JSON.stringify(value, jsonSerialize)}
+
+ ),
+ expanded: (value) => (value.asset_id ? : null),
},
}
diff --git a/src/components/TokenAmount.tsx b/src/components/TokenAmount.tsx
index 2bbb963..62aecc2 100644
--- a/src/components/TokenAmount.tsx
+++ b/src/components/TokenAmount.tsx
@@ -3,6 +3,23 @@ import { chainProperties$ } from "@/state/chain-props.state"
import { useStateObservable } from "@react-rxjs/core"
import { FC } from "react"
+export const formatToken = (
+ amount: bigint,
+ properties: {
+ decimals: number
+ symbol?: string
+ },
+) => {
+ const formattedValue = (
+ Number(amount) /
+ 10 ** properties.decimals
+ ).toLocaleString(undefined, {
+ maximumSignificantDigits: 3,
+ })
+
+ return `${formattedValue} ${properties.symbol}`
+}
+
export const TokenAmount: FC<{
children: bigint
className?: string
@@ -15,16 +32,12 @@ export const TokenAmount: FC<{
return children.toLocaleString()
}
- const formattedValue = (
- Number(children) /
- 10 ** properties.tokenDecimals
- ).toLocaleString(undefined, {
- maximumSignificantDigits: 3,
- })
-
return (
- {`${formattedValue} ${properties.tokenSymbol}`}
+
+ {formatToken(children, {
+ decimals: properties.tokenDecimals,
+ symbol: properties.tokenSymbol,
+ })}
+
)
}