diff --git a/explorer/src/utils/anchor.tsx b/explorer/src/utils/anchor.tsx
index 84ed844463..8ae0e6c1ee 100644
--- a/explorer/src/utils/anchor.tsx
+++ b/explorer/src/utils/anchor.tsx
@@ -6,6 +6,7 @@ import { useAnchorProgram } from "providers/anchor";
import { getProgramName } from "utils/tx";
import { snakeToTitleCase, camelToTitleCase, numberWithSeparator } from "utils";
import {
+ IdlField,
IdlInstruction,
IdlType,
IdlTypeDef,
@@ -279,8 +280,43 @@ function mapField(
);
} else {
- const enumValue = Object.keys(value)[0];
- return (
+ const enumVariantName = Object.keys(value)[0];
+ const variant = fieldType.type.variants.find(
+ (val) =>
+ val.name.toLocaleLowerCase() === enumVariantName.toLocaleLowerCase()
+ );
+
+ return variant && variant.fields ? (
+
+
+ {Object.entries(value[enumVariantName]).map(
+ ([innerKey, innerValue]: [string, any], index) => {
+ const innerFieldType = variant.fields![index];
+ if (!innerFieldType) {
+ throw Error(
+ `Could not type definition for ${innerKey} field in user-defined struct ${fieldType.name}`
+ );
+ }
+ return mapField(
+ innerKey,
+ innerValue,
+ (innerFieldType as any).name
+ ? (innerFieldType as IdlField).type
+ : (innerFieldType as IdlType),
+ idl,
+ key,
+ nestingLevel + 1
+ );
+ }
+ )}
+
+
+ ) : (
- {camelToTitleCase(enumValue)}
+ {camelToTitleCase(enumVariantName)}
);
}