UNPKG

@metamask/keyring-api

Version:
83 lines 3.21 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.EthErc4337AccountStruct = exports.EthEoaAccountStruct = exports.EthMethod = exports.EthUint256Struct = exports.EthAddressStruct = exports.EthBytesStruct = void 0; const keyring_utils_1 = require("@metamask/keyring-utils"); const superstruct_1 = require("@metamask/superstruct"); const utils_1 = require("@metamask/utils"); const _1 = require("./index.cjs"); const api_1 = require("../api/index.cjs"); exports.EthBytesStruct = (0, utils_1.definePattern)('EthBytes', /^0x[0-9a-f]*$/iu); exports.EthAddressStruct = (0, utils_1.definePattern)('EthAddress', /^0x[0-9a-f]{40}$/iu); exports.EthUint256Struct = (0, utils_1.definePattern)('EthUint256', /^0x([1-9a-f][0-9a-f]*|0)$/iu); /** * Supported Ethereum methods. */ var EthMethod; (function (EthMethod) { // General signing methods EthMethod["PersonalSign"] = "personal_sign"; EthMethod["Sign"] = "eth_sign"; EthMethod["SignTransaction"] = "eth_signTransaction"; EthMethod["SignTypedDataV1"] = "eth_signTypedData_v1"; EthMethod["SignTypedDataV3"] = "eth_signTypedData_v3"; EthMethod["SignTypedDataV4"] = "eth_signTypedData_v4"; // ERC-4337 methods EthMethod["PrepareUserOperation"] = "eth_prepareUserOperation"; EthMethod["PatchUserOperation"] = "eth_patchUserOperation"; EthMethod["SignUserOperation"] = "eth_signUserOperation"; })(EthMethod || (exports.EthMethod = EthMethod = {})); exports.EthEoaAccountStruct = (0, keyring_utils_1.object)({ ...api_1.KeyringAccountStruct.schema, /** * Account address. */ address: exports.EthAddressStruct, /** * Account type. */ type: (0, superstruct_1.literal)(`${api_1.EthAccountType.Eoa}`), /** * Account scopes (must be ['eip155:0']). */ scopes: (0, superstruct_1.nonempty)((0, superstruct_1.array)((0, superstruct_1.literal)(_1.EthScope.Eoa))), /** * Account supported methods. */ methods: (0, superstruct_1.array)((0, superstruct_1.enums)([ `${EthMethod.PersonalSign}`, `${EthMethod.Sign}`, `${EthMethod.SignTransaction}`, `${EthMethod.SignTypedDataV1}`, `${EthMethod.SignTypedDataV3}`, `${EthMethod.SignTypedDataV4}`, ])), }); exports.EthErc4337AccountStruct = (0, keyring_utils_1.object)({ ...api_1.KeyringAccountStruct.schema, /** * Account address. */ address: exports.EthAddressStruct, /** * Account type. */ type: (0, superstruct_1.literal)(`${api_1.EthAccountType.Erc4337}`), /** * Account supported scopes (CAIP-2 chain IDs). */ scopes: (0, superstruct_1.nonempty)((0, superstruct_1.array)(api_1.CaipChainIdStruct)), /** * Account supported methods. */ methods: (0, superstruct_1.array)((0, superstruct_1.enums)([ `${EthMethod.PersonalSign}`, `${EthMethod.Sign}`, `${EthMethod.SignTypedDataV1}`, `${EthMethod.SignTypedDataV3}`, `${EthMethod.SignTypedDataV4}`, `${EthMethod.PrepareUserOperation}`, `${EthMethod.PatchUserOperation}`, `${EthMethod.SignUserOperation}`, ])), }); //# sourceMappingURL=types.cjs.map