@metamask/keyring-api
Version:
MetaMask Keyring API
105 lines • 3.52 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.KeyringAccountStruct = exports.KeyringAccountTypeStruct = exports.AnyAccountType = exports.TrxAccountType = exports.SolAccountType = exports.BtcAccountType = exports.EthAccountType = void 0;
const keyring_utils_1 = require("@metamask/keyring-utils");
const superstruct_1 = require("@metamask/superstruct");
const account_options_1 = require("./account-options.cjs");
const caip_1 = require("./caip.cjs");
/**
* Supported Ethereum account types.
*/
var EthAccountType;
(function (EthAccountType) {
EthAccountType["Eoa"] = "eip155:eoa";
EthAccountType["Erc4337"] = "eip155:erc4337";
})(EthAccountType || (exports.EthAccountType = EthAccountType = {}));
/**
* Supported Bitcoin account types.
*/
var BtcAccountType;
(function (BtcAccountType) {
BtcAccountType["P2pkh"] = "bip122:p2pkh";
BtcAccountType["P2sh"] = "bip122:p2sh";
BtcAccountType["P2wpkh"] = "bip122:p2wpkh";
BtcAccountType["P2tr"] = "bip122:p2tr";
})(BtcAccountType || (exports.BtcAccountType = BtcAccountType = {}));
/**
* Supported Solana account types.
*/
var SolAccountType;
(function (SolAccountType) {
SolAccountType["DataAccount"] = "solana:data-account";
})(SolAccountType || (exports.SolAccountType = SolAccountType = {}));
/**
* Supported Tron account types.
*/
var TrxAccountType;
(function (TrxAccountType) {
TrxAccountType["Eoa"] = "tron:eoa";
})(TrxAccountType || (exports.TrxAccountType = TrxAccountType = {}));
/**
* A generic account type. It can be used to represent any account type that is
* not covered by the other account types. It only applies to non-EVM chains.
*/
var AnyAccountType;
(function (AnyAccountType) {
AnyAccountType["Account"] = "any:account";
})(AnyAccountType || (exports.AnyAccountType = AnyAccountType = {}));
/**
* Struct for {@link KeyringAccountType}.
*/
exports.KeyringAccountTypeStruct = (0, superstruct_1.enums)([
`${EthAccountType.Eoa}`,
`${EthAccountType.Erc4337}`,
`${BtcAccountType.P2pkh}`,
`${BtcAccountType.P2sh}`,
`${BtcAccountType.P2wpkh}`,
`${BtcAccountType.P2tr}`,
`${SolAccountType.DataAccount}`,
`${TrxAccountType.Eoa}`,
`${AnyAccountType.Account}`,
]);
/**
* A struct which represents a Keyring account object. It is abstract enough to
* be used with any blockchain. Specific blockchain account types should extend
* this struct.
*
* See {@link KeyringAccount}.
*/
exports.KeyringAccountStruct = (0, keyring_utils_1.object)({
/**
* Account ID (UUIDv4).
*/
id: keyring_utils_1.AccountIdStruct,
/**
* Account type.
*/
type: (0, superstruct_1.enums)([
`${EthAccountType.Eoa}`,
`${EthAccountType.Erc4337}`,
`${BtcAccountType.P2pkh}`,
`${BtcAccountType.P2sh}`,
`${BtcAccountType.P2wpkh}`,
`${BtcAccountType.P2tr}`,
`${SolAccountType.DataAccount}`,
`${TrxAccountType.Eoa}`,
`${AnyAccountType.Account}`,
]),
/**
* Account main address.
*/
address: (0, superstruct_1.string)(),
/**
* Account supported scopes (CAIP-2 chain IDs).
*/
scopes: (0, superstruct_1.nonempty)((0, superstruct_1.array)(caip_1.CaipChainIdStruct)),
/**
* Account options.
*/
options: account_options_1.KeyringAccountOptionsStruct,
/**
* Account supported methods.
*/
methods: (0, superstruct_1.array)((0, superstruct_1.string)()),
});
//# sourceMappingURL=account.cjs.map