@metamask/keyring-internal-api
Version:
MetaMask Keyring Internal API
65 lines • 2.74 kB
JavaScript
/* eslint-disable @typescript-eslint/no-redundant-type-constituents */
/* eslint-disable @typescript-eslint/no-duplicate-type-constituents */
// FIXME: Those rules seem to be triggering a false positive on the `InternalAccountStructs`
// and `InternalAccountTypes`.
import { BtcAccountType, EthAccountType, KeyringAccountStruct, SolAccountType, BtcP2pkhAccountStruct, BtcP2shAccountStruct, BtcP2wpkhAccountStruct, BtcP2trAccountStruct, EthEoaAccountStruct, EthErc4337AccountStruct, SolDataAccountStruct } from "@metamask/keyring-api";
import { exactOptional, object } from "@metamask/keyring-utils";
import { boolean, string, number } from "@metamask/superstruct";
export const InternalAccountMetadataStruct = object({
metadata: object({
name: string(),
nameLastUpdatedAt: exactOptional(number()),
snap: exactOptional(object({
id: string(),
enabled: boolean(),
name: string(),
})),
lastSelected: exactOptional(number()),
importTime: number(),
keyring: object({
type: string(),
}),
}),
});
export const InternalEthEoaAccountStruct = object({
...EthEoaAccountStruct.schema,
...InternalAccountMetadataStruct.schema,
});
export const InternalEthErc4337AccountStruct = object({
...EthErc4337AccountStruct.schema,
...InternalAccountMetadataStruct.schema,
});
export const InternalBtcP2pkhAccountStruct = object({
...BtcP2pkhAccountStruct.schema,
...InternalAccountMetadataStruct.schema,
});
export const InternalBtcP2shAccountStruct = object({
...BtcP2shAccountStruct.schema,
...InternalAccountMetadataStruct.schema,
});
export const InternalBtcP2wpkhAccountStruct = object({
...BtcP2wpkhAccountStruct.schema,
...InternalAccountMetadataStruct.schema,
});
export const InternalBtcP2trAccountStruct = object({
...BtcP2trAccountStruct.schema,
...InternalAccountMetadataStruct.schema,
});
export const InternalSolDataAccountStruct = object({
...SolDataAccountStruct.schema,
...InternalAccountMetadataStruct.schema,
});
export const InternalAccountStructs = {
[`${EthAccountType.Eoa}`]: InternalEthEoaAccountStruct,
[`${EthAccountType.Erc4337}`]: InternalEthErc4337AccountStruct,
[`${BtcAccountType.P2pkh}`]: InternalBtcP2pkhAccountStruct,
[`${BtcAccountType.P2sh}`]: InternalBtcP2shAccountStruct,
[`${BtcAccountType.P2wpkh}`]: InternalBtcP2wpkhAccountStruct,
[`${BtcAccountType.P2tr}`]: InternalBtcP2trAccountStruct,
[`${SolAccountType.DataAccount}`]: InternalSolDataAccountStruct,
};
export const InternalAccountStruct = object({
...KeyringAccountStruct.schema,
...InternalAccountMetadataStruct.schema,
});
//# sourceMappingURL=types.mjs.map