Skip to content

Commit 8fbc107

Browse files
fix: Improve error messages for AddressStruct
1 parent e871704 commit 8fbc107

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/snaps-sdk/src/jsx/validation.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,12 @@ export const DropdownStruct: Describe<DropdownElement> = element('Dropdown', {
385385
* A struct for the {@link AddressElement} type.
386386
*/
387387
export const AddressStruct: Describe<AddressElement> = element('Address', {
388-
address: nullUnion([HexChecksumAddressStruct, CaipAccountIdStruct]),
388+
address: selectiveUnion((value) => {
389+
if (typeof value === 'string' && value.startsWith('0x')) {
390+
return HexChecksumAddressStruct;
391+
}
392+
return CaipAccountIdStruct;
393+
}),
389394
truncate: optional(boolean()),
390395
displayName: optional(boolean()),
391396
avatar: optional(boolean()),

0 commit comments

Comments
 (0)