diff --git a/packages/keyring-api/CHANGELOG.md b/packages/keyring-api/CHANGELOG.md index c4b3e299..576dae57 100644 --- a/packages/keyring-api/CHANGELOG.md +++ b/packages/keyring-api/CHANGELOG.md @@ -13,6 +13,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - These have been moved to the new `@metamask/keyring-sdk` package. - `@ethereumjs/tx`, `@metamask/eth-sig-util`, and `async-mutex` are no longer dependencies of this package. +### Fixed + +- Change `KeyringCapabilitiesStruct` to use `optional` instead of `exactOptional` for nested fields ([#481](https://github.com/MetaMask/accounts/pull/481)) + - No runtime behavior change for JSON-sourced data; `undefined` cannot appear in JSON. + ## [21.6.0] ### Added diff --git a/packages/keyring-api/src/api/v2/keyring-capabilities.ts b/packages/keyring-api/src/api/v2/keyring-capabilities.ts index c5c3a09b..b82d6d2d 100644 --- a/packages/keyring-api/src/api/v2/keyring-capabilities.ts +++ b/packages/keyring-api/src/api/v2/keyring-capabilities.ts @@ -1,7 +1,7 @@ import { array, boolean, - exactOptional, + optional, nonempty, object, partial, @@ -25,39 +25,39 @@ export const KeyringCapabilitiesStruct = object({ /** * BIP-44 capabilities supported by this keyring. */ - bip44: exactOptional( + bip44: optional( object({ /** * Whether the keyring supports deriving accounts from a specific BIP-44 path. */ - derivePath: exactOptional(boolean()), + derivePath: optional(boolean()), /** * Whether the keyring supports deriving accounts from a BIP-44 account index. */ - deriveIndex: exactOptional(boolean()), + deriveIndex: optional(boolean()), /** * Whether the keyring supports deriving accounts from a range of BIP-44 account indices. */ - deriveIndexRange: exactOptional(boolean()), + deriveIndexRange: optional(boolean()), /** * Whether the keyring supports BIP-44 account discovery. */ - discover: exactOptional(boolean()), + discover: optional(boolean()), }), ), /** * Private key capabilities supported by this keyring. */ - privateKey: exactOptional( + privateKey: optional( object({ /** * List of supported formats for importing private keys. */ - importFormats: exactOptional(array(ImportPrivateKeyFormatStruct)), + importFormats: optional(array(ImportPrivateKeyFormatStruct)), /** * List of supported formats for exporting private keys. */ - exportFormats: exactOptional(array(ExportPrivateKeyFormatStruct)), + exportFormats: optional(array(ExportPrivateKeyFormatStruct)), }), ), /** @@ -67,7 +67,7 @@ export const KeyringCapabilitiesStruct = object({ * accepts custom options for that method, different from the standard API. * This is a workaround for keyrings with very specific requirements. */ - custom: exactOptional( + custom: optional( partial( object({ createAccounts: boolean(),