@metamask/keyring-api
Advanced tools
Comparing version 6.0.0 to 6.1.0
@@ -10,2 +10,16 @@ # Changelog | ||
## [6.1.0] | ||
### Added | ||
- Add `isEvmAccountType` helper ([#297](https://github.com/MetaMask/keyring-api/pull/297)) | ||
- Add `bip121:p2wpkh` account support ([#294](https://github.com/MetaMask/keyring-api/pull/294)) | ||
### Changed | ||
- Remove incorrect `SignTransaction` from `EthErc4337Account` ([#300](https://github.com/MetaMask/keyring-api/pull/300)) | ||
- Bump @metamask/providers from 16.0.0 to 16.1.0 ([#298](https://github.com/MetaMask/keyring-api/pull/298)) | ||
- Bump @metamask/snaps-sdk from 4.0.0 to 4.0.1 ([#292](https://github.com/MetaMask/keyring-api/pull/292)) | ||
- Split account types (EOA + Erc4337) ([#293](https://github.com/MetaMask/keyring-api/pull/293)) | ||
## [6.0.0] | ||
@@ -266,3 +280,4 @@ | ||
[Unreleased]: https://github.com/MetaMask/keyring-api/compare/v6.0.0...HEAD | ||
[Unreleased]: https://github.com/MetaMask/keyring-api/compare/v6.1.0...HEAD | ||
[6.1.0]: https://github.com/MetaMask/keyring-api/compare/v6.0.0...v6.1.0 | ||
[6.0.0]: https://github.com/MetaMask/keyring-api/compare/v5.1.0...v6.0.0 | ||
@@ -269,0 +284,0 @@ [5.1.0]: https://github.com/MetaMask/keyring-api/compare/v5.0.0...v5.1.0 |
import type { Json } from '@metamask/utils'; | ||
import type { Infer } from 'superstruct'; | ||
import type { Infer, Struct } from 'superstruct'; | ||
import type { StaticAssertAbstractAccount } from './base-types'; | ||
import type { BtcP2wpkhAccount } from './btc'; | ||
import type { EthEoaAccount, EthErc4337Account } from './eth'; | ||
/** | ||
* Supported Ethereum methods. | ||
* Type of supported accounts. | ||
*/ | ||
export declare enum EthMethod { | ||
PersonalSign = "personal_sign", | ||
Sign = "eth_sign", | ||
SignTransaction = "eth_signTransaction", | ||
SignTypedDataV1 = "eth_signTypedData_v1", | ||
SignTypedDataV3 = "eth_signTypedData_v3", | ||
SignTypedDataV4 = "eth_signTypedData_v4", | ||
PrepareUserOperation = "eth_prepareUserOperation", | ||
PatchUserOperation = "eth_patchUserOperation", | ||
SignUserOperation = "eth_signUserOperation" | ||
} | ||
export declare type KeyringAccounts = StaticAssertAbstractAccount<EthEoaAccount | EthErc4337Account | BtcP2wpkhAccount>; | ||
/** | ||
* Supported Ethereum account types. | ||
* Mapping between account types and their matching `superstruct` schema. | ||
*/ | ||
export declare enum EthAccountType { | ||
Eoa = "eip155:eoa", | ||
Erc4337 = "eip155:erc4337" | ||
} | ||
export declare const KeyringAccountStruct: import("superstruct").Struct<{ | ||
type: "eip155:eoa" | "eip155:erc4337"; | ||
id: string; | ||
address: string; | ||
options: Record<string, Json>; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[]; | ||
export declare const KeyringAccountStructs: Record<string, Struct<EthEoaAccount> | Struct<EthErc4337Account> | Struct<BtcP2wpkhAccount>>; | ||
/** | ||
* Base type for `KeyringAccount` as a `superstruct.object`. | ||
*/ | ||
export declare const BaseKeyringAccountStruct: Struct<{ | ||
type: "bip122:p2wpkh" | "eip155:eoa" | "eip155:erc4337"; | ||
}, { | ||
/** | ||
* Account ID (UUIDv4). | ||
*/ | ||
id: import("superstruct").Struct<string, null>; | ||
/** | ||
* Account address or next receive address (UTXO). | ||
*/ | ||
address: import("superstruct").Struct<string, null>; | ||
/** | ||
* Keyring-dependent account options. | ||
*/ | ||
options: import("superstruct").Struct<Record<string, Json>, null>; | ||
/** | ||
* Account supported methods. | ||
*/ | ||
methods: import("superstruct").Struct<("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[], import("superstruct").Struct<"personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation", { | ||
personal_sign: "personal_sign"; | ||
eth_sign: "eth_sign"; | ||
eth_signTransaction: "eth_signTransaction"; | ||
eth_signTypedData_v1: "eth_signTypedData_v1"; | ||
eth_signTypedData_v3: "eth_signTypedData_v3"; | ||
eth_signTypedData_v4: "eth_signTypedData_v4"; | ||
eth_prepareUserOperation: "eth_prepareUserOperation"; | ||
eth_patchUserOperation: "eth_patchUserOperation"; | ||
eth_signUserOperation: "eth_signUserOperation"; | ||
}>>; | ||
/** | ||
* Account type. | ||
*/ | ||
type: import("superstruct").Struct<"eip155:eoa" | "eip155:erc4337", { | ||
type: Struct<"bip122:p2wpkh" | "eip155:eoa" | "eip155:erc4337", { | ||
"bip122:p2wpkh": "bip122:p2wpkh"; | ||
"eip155:eoa": "eip155:eoa"; | ||
@@ -66,2 +30,26 @@ "eip155:erc4337": "eip155:erc4337"; | ||
/** | ||
* Account as a `superstruct.object`. | ||
* | ||
* See {@link KeyringAccount}. | ||
*/ | ||
export declare const KeyringAccountStruct: Struct<{ | ||
type: "bip122:p2wpkh"; | ||
id: string; | ||
address: string; | ||
options: Record<string, Json>; | ||
methods: "btc_sendmany"[]; | ||
} | { | ||
type: "eip155:eoa"; | ||
id: string; | ||
address: string; | ||
options: Record<string, Json>; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4")[]; | ||
} | { | ||
type: "eip155:erc4337"; | ||
id: string; | ||
address: string; | ||
options: Record<string, Json>; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[]; | ||
}, null>; | ||
/** | ||
* Account object. | ||
@@ -72,6 +60,6 @@ * | ||
export declare type KeyringAccount = Infer<typeof KeyringAccountStruct>; | ||
export declare const KeyringRequestStruct: import("superstruct").Struct<{ | ||
export declare const KeyringRequestStruct: Struct<{ | ||
id: string; | ||
account: string; | ||
scope: string; | ||
account: string; | ||
request: { | ||
@@ -85,20 +73,20 @@ method: string; | ||
*/ | ||
id: import("superstruct").Struct<string, null>; | ||
id: Struct<string, null>; | ||
/** | ||
* Request's scope (CAIP-2 chain ID). | ||
*/ | ||
scope: import("superstruct").Struct<string, null>; | ||
scope: Struct<string, null>; | ||
/** | ||
* Account ID (UUIDv4). | ||
*/ | ||
account: import("superstruct").Struct<string, null>; | ||
account: Struct<string, null>; | ||
/** | ||
* Inner request sent by the client application. | ||
*/ | ||
request: import("superstruct").Struct<{ | ||
request: Struct<{ | ||
method: string; | ||
params?: Json[] | Record<string, Json>; | ||
}, { | ||
method: import("superstruct").Struct<string, null>; | ||
params: import("superstruct").Struct<import("./superstruct").ExactOptionalTag | Json[] | Record<string, Json>, null>; | ||
method: Struct<string, null>; | ||
params: Struct<import("./superstruct").ExactOptionalTag | Json[] | Record<string, Json>, null>; | ||
}>; | ||
@@ -112,3 +100,3 @@ }>; | ||
export declare type KeyringRequest = Infer<typeof KeyringRequestStruct>; | ||
export declare const KeyringAccountDataStruct: import("superstruct").Struct<Record<string, Json>, null>; | ||
export declare const KeyringAccountDataStruct: Struct<Record<string, Json>, null>; | ||
/** | ||
@@ -120,3 +108,3 @@ * Response to a call to `exportAccount`. | ||
export declare type KeyringAccountData = Infer<typeof KeyringAccountDataStruct>; | ||
export declare const KeyringResponseStruct: import("superstruct").Struct<{ | ||
export declare const KeyringResponseStruct: Struct<{ | ||
pending: true; | ||
@@ -123,0 +111,0 @@ redirect?: { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.KeyringResponseStruct = exports.KeyringAccountDataStruct = exports.KeyringRequestStruct = exports.KeyringAccountStruct = exports.EthAccountType = exports.EthMethod = void 0; | ||
exports.KeyringResponseStruct = exports.KeyringAccountDataStruct = exports.KeyringRequestStruct = exports.KeyringAccountStruct = exports.BaseKeyringAccountStruct = exports.KeyringAccountStructs = void 0; | ||
const utils_1 = require("@metamask/utils"); | ||
const superstruct_1 = require("superstruct"); | ||
const btc_1 = require("./btc"); | ||
const eth_1 = require("./eth"); | ||
const superstruct_2 = require("./superstruct"); | ||
const utils_2 = require("./utils"); | ||
/** | ||
* Supported Ethereum methods. | ||
* Mapping between account types and their matching `superstruct` schema. | ||
*/ | ||
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 || (exports.EthMethod = {})); | ||
exports.KeyringAccountStructs = { | ||
[`${eth_1.EthAccountType.Eoa}`]: eth_1.EthEoaAccountStruct, | ||
[`${eth_1.EthAccountType.Erc4337}`]: eth_1.EthErc4337AccountStruct, | ||
[`${btc_1.BtcAccountType.P2wpkh}`]: btc_1.BtcP2wpkhAccountStruct, | ||
}; | ||
/** | ||
* Supported Ethereum account types. | ||
* Base type for `KeyringAccount` as a `superstruct.object`. | ||
*/ | ||
var EthAccountType; | ||
(function (EthAccountType) { | ||
EthAccountType["Eoa"] = "eip155:eoa"; | ||
EthAccountType["Erc4337"] = "eip155:erc4337"; | ||
})(EthAccountType = exports.EthAccountType || (exports.EthAccountType = {})); | ||
exports.KeyringAccountStruct = (0, superstruct_2.object)({ | ||
exports.BaseKeyringAccountStruct = (0, superstruct_2.object)({ | ||
/** | ||
* Account ID (UUIDv4). | ||
*/ | ||
id: utils_2.UuidStruct, | ||
/** | ||
* Account address or next receive address (UTXO). | ||
*/ | ||
address: (0, superstruct_1.string)(), | ||
/** | ||
* Keyring-dependent account options. | ||
*/ | ||
options: (0, superstruct_1.record)((0, superstruct_1.string)(), utils_1.JsonStruct), | ||
/** | ||
* Account supported methods. | ||
*/ | ||
methods: (0, superstruct_1.array)((0, superstruct_1.enums)([ | ||
`${EthMethod.PersonalSign}`, | ||
`${EthMethod.Sign}`, | ||
`${EthMethod.SignTransaction}`, | ||
`${EthMethod.SignTypedDataV1}`, | ||
`${EthMethod.SignTypedDataV3}`, | ||
`${EthMethod.SignTypedDataV4}`, | ||
`${EthMethod.PrepareUserOperation}`, | ||
`${EthMethod.PatchUserOperation}`, | ||
`${EthMethod.SignUserOperation}`, | ||
])), | ||
/** | ||
* Account type. | ||
*/ | ||
type: (0, superstruct_1.enums)([`${EthAccountType.Eoa}`, `${EthAccountType.Erc4337}`]), | ||
type: (0, superstruct_1.enums)([ | ||
`${eth_1.EthAccountType.Eoa}`, | ||
`${eth_1.EthAccountType.Erc4337}`, | ||
`${btc_1.BtcAccountType.P2wpkh}`, | ||
]), | ||
}); | ||
/** | ||
* Account as a `superstruct.object`. | ||
* | ||
* See {@link KeyringAccount}. | ||
*/ | ||
exports.KeyringAccountStruct = (0, superstruct_1.define)( | ||
// We do use a custom `define` for this type to avoid having to use a `union` since error | ||
// messages are a bit confusing. | ||
// | ||
// Doing manual validation allows us to use the "concrete" type of each supported acounts giving | ||
// use a much nicer message from `superstruct`. | ||
'KeyringAccount', (value) => { | ||
// This will also raise if `value` does not match any of the supported account types! | ||
const account = (0, superstruct_1.mask)(value, exports.BaseKeyringAccountStruct); | ||
// At this point, we know that `value.type` can be used as an index for `KeyringAccountStructs` | ||
const [error] = (0, superstruct_1.validate)(value, exports.KeyringAccountStructs[account.type]); | ||
return error ?? true; | ||
}); | ||
exports.KeyringRequestStruct = (0, superstruct_2.object)({ | ||
@@ -66,0 +50,0 @@ /** |
@@ -38,4 +38,4 @@ import { type Infer } from 'superstruct'; | ||
value: string; | ||
to: string; | ||
data: string; | ||
to: string; | ||
}, { | ||
@@ -42,0 +42,0 @@ /** |
export * from './erc4337'; | ||
export * from './types'; | ||
export * from './utils'; |
@@ -19,2 +19,3 @@ "use strict"; | ||
__exportStar(require("./types"), exports); | ||
__exportStar(require("./utils"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -0,3 +1,86 @@ | ||
import type { Infer } from 'superstruct'; | ||
export declare const EthBytesStruct: import("superstruct").Struct<string, null>; | ||
export declare const EthAddressStruct: import("superstruct").Struct<string, null>; | ||
export declare const EthUint256Struct: import("superstruct").Struct<string, null>; | ||
/** | ||
* Supported Ethereum methods. | ||
*/ | ||
export declare enum EthMethod { | ||
PersonalSign = "personal_sign", | ||
Sign = "eth_sign", | ||
SignTransaction = "eth_signTransaction", | ||
SignTypedDataV1 = "eth_signTypedData_v1", | ||
SignTypedDataV3 = "eth_signTypedData_v3", | ||
SignTypedDataV4 = "eth_signTypedData_v4" | ||
} | ||
/** | ||
* Supported Ethereum methods for ERC-4337 (Account Abstraction) accounts. | ||
*/ | ||
export declare enum EthErc4337Method { | ||
PrepareUserOperation = "eth_prepareUserOperation", | ||
PatchUserOperation = "eth_patchUserOperation", | ||
SignUserOperation = "eth_signUserOperation" | ||
} | ||
/** | ||
* Supported Ethereum account types. | ||
*/ | ||
export declare enum EthAccountType { | ||
Eoa = "eip155:eoa", | ||
Erc4337 = "eip155:erc4337" | ||
} | ||
export declare const EthEoaAccountStruct: import("superstruct").Struct<{ | ||
type: "eip155:eoa"; | ||
id: string; | ||
address: string; | ||
options: Record<string, import("@metamask/utils").Json>; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4")[]; | ||
}, { | ||
/** | ||
* Account type. | ||
*/ | ||
type: import("superstruct").Struct<"eip155:eoa", "eip155:eoa">; | ||
/** | ||
* Account supported methods. | ||
*/ | ||
methods: import("superstruct").Struct<("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4")[], import("superstruct").Struct<"personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4", { | ||
personal_sign: "personal_sign"; | ||
eth_sign: "eth_sign"; | ||
eth_signTransaction: "eth_signTransaction"; | ||
eth_signTypedData_v1: "eth_signTypedData_v1"; | ||
eth_signTypedData_v3: "eth_signTypedData_v3"; | ||
eth_signTypedData_v4: "eth_signTypedData_v4"; | ||
}>>; | ||
id: import("superstruct").Struct<string, null>; | ||
address: import("superstruct").Struct<string, null>; | ||
options: import("superstruct").Struct<Record<string, import("@metamask/utils").Json>, null>; | ||
}>; | ||
export declare type EthEoaAccount = Infer<typeof EthEoaAccountStruct>; | ||
export declare const EthErc4337AccountStruct: import("superstruct").Struct<{ | ||
type: "eip155:erc4337"; | ||
id: string; | ||
address: string; | ||
options: Record<string, import("@metamask/utils").Json>; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[]; | ||
}, { | ||
/** | ||
* Account type. | ||
*/ | ||
type: import("superstruct").Struct<"eip155:erc4337", "eip155:erc4337">; | ||
/** | ||
* Account supported methods. | ||
*/ | ||
methods: import("superstruct").Struct<("personal_sign" | "eth_sign" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[], import("superstruct").Struct<"personal_sign" | "eth_sign" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation", { | ||
personal_sign: "personal_sign"; | ||
eth_sign: "eth_sign"; | ||
eth_signTypedData_v1: "eth_signTypedData_v1"; | ||
eth_signTypedData_v3: "eth_signTypedData_v3"; | ||
eth_signTypedData_v4: "eth_signTypedData_v4"; | ||
eth_prepareUserOperation: "eth_prepareUserOperation"; | ||
eth_patchUserOperation: "eth_patchUserOperation"; | ||
eth_signUserOperation: "eth_signUserOperation"; | ||
}>>; | ||
id: import("superstruct").Struct<string, null>; | ||
address: import("superstruct").Struct<string, null>; | ||
options: import("superstruct").Struct<Record<string, import("@metamask/utils").Json>, null>; | ||
}>; | ||
export declare type EthErc4337Account = Infer<typeof EthErc4337AccountStruct>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.EthUint256Struct = exports.EthAddressStruct = exports.EthBytesStruct = void 0; | ||
const superstruct_1 = require("../superstruct"); | ||
exports.EthBytesStruct = (0, superstruct_1.definePattern)('EthBytes', /^0x[0-9a-f]*$/iu); | ||
exports.EthAddressStruct = (0, superstruct_1.definePattern)('EthAddress', /^0x[0-9a-f]{40}$/iu); | ||
exports.EthUint256Struct = (0, superstruct_1.definePattern)('EthUint256', /^0x([1-9a-f][0-9a-f]*|0)$/iu); | ||
exports.EthErc4337AccountStruct = exports.EthEoaAccountStruct = exports.EthAccountType = exports.EthErc4337Method = exports.EthMethod = exports.EthUint256Struct = exports.EthAddressStruct = exports.EthBytesStruct = void 0; | ||
const superstruct_1 = require("superstruct"); | ||
const base_types_1 = require("../base-types"); | ||
const superstruct_2 = require("../superstruct"); | ||
exports.EthBytesStruct = (0, superstruct_2.definePattern)('EthBytes', /^0x[0-9a-f]*$/iu); | ||
exports.EthAddressStruct = (0, superstruct_2.definePattern)('EthAddress', /^0x[0-9a-f]{40}$/iu); | ||
exports.EthUint256Struct = (0, superstruct_2.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"; | ||
})(EthMethod = exports.EthMethod || (exports.EthMethod = {})); | ||
/** | ||
* Supported Ethereum methods for ERC-4337 (Account Abstraction) accounts. | ||
*/ | ||
var EthErc4337Method; | ||
(function (EthErc4337Method) { | ||
// ERC-4337 methods | ||
EthErc4337Method["PrepareUserOperation"] = "eth_prepareUserOperation"; | ||
EthErc4337Method["PatchUserOperation"] = "eth_patchUserOperation"; | ||
EthErc4337Method["SignUserOperation"] = "eth_signUserOperation"; | ||
})(EthErc4337Method = exports.EthErc4337Method || (exports.EthErc4337Method = {})); | ||
/** | ||
* Supported Ethereum account types. | ||
*/ | ||
var EthAccountType; | ||
(function (EthAccountType) { | ||
EthAccountType["Eoa"] = "eip155:eoa"; | ||
EthAccountType["Erc4337"] = "eip155:erc4337"; | ||
})(EthAccountType = exports.EthAccountType || (exports.EthAccountType = {})); | ||
exports.EthEoaAccountStruct = (0, superstruct_1.object)({ | ||
...base_types_1.BaseAccount, | ||
/** | ||
* Account type. | ||
*/ | ||
type: (0, superstruct_1.literal)(`${EthAccountType.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, superstruct_1.object)({ | ||
...base_types_1.BaseAccount, | ||
/** | ||
* Account type. | ||
*/ | ||
type: (0, superstruct_1.literal)(`${EthAccountType.Erc4337}`), | ||
/** | ||
* Account supported methods. | ||
*/ | ||
methods: (0, superstruct_1.array)((0, superstruct_1.enums)([ | ||
`${EthMethod.PersonalSign}`, | ||
`${EthMethod.Sign}`, | ||
`${EthMethod.SignTypedDataV1}`, | ||
`${EthMethod.SignTypedDataV3}`, | ||
`${EthMethod.SignTypedDataV4}`, | ||
`${EthErc4337Method.PrepareUserOperation}`, | ||
`${EthErc4337Method.PatchUserOperation}`, | ||
`${EthErc4337Method.SignUserOperation}`, | ||
])), | ||
}); | ||
//# sourceMappingURL=types.js.map |
export * from './api'; | ||
export * from './btc'; | ||
export * from './contexts'; | ||
@@ -3,0 +4,0 @@ export * from './eth'; |
@@ -18,2 +18,3 @@ "use strict"; | ||
__exportStar(require("./api"), exports); | ||
__exportStar(require("./btc"), exports); | ||
__exportStar(require("./contexts"), exports); | ||
@@ -20,0 +21,0 @@ __exportStar(require("./eth"), exports); |
@@ -12,34 +12,39 @@ import type { Infer } from 'superstruct'; | ||
export declare type ListAccountsRequest = Infer<typeof ListAccountsRequestStruct>; | ||
export declare const ListAccountsResponseStruct: import("superstruct").Struct<{ | ||
type: "eip155:eoa" | "eip155:erc4337"; | ||
export declare const ListAccountsResponseStruct: import("superstruct").Struct<({ | ||
type: "bip122:p2wpkh"; | ||
id: string; | ||
address: string; | ||
options: Record<string, import("@metamask/utils").Json>; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[]; | ||
}[], import("superstruct").Struct<{ | ||
type: "eip155:eoa" | "eip155:erc4337"; | ||
methods: "btc_sendmany"[]; | ||
} | { | ||
type: "eip155:eoa"; | ||
id: string; | ||
address: string; | ||
options: Record<string, import("@metamask/utils").Json>; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[]; | ||
}, { | ||
id: import("superstruct").Struct<string, null>; | ||
address: import("superstruct").Struct<string, null>; | ||
options: import("superstruct").Struct<Record<string, import("@metamask/utils").Json>, null>; | ||
methods: import("superstruct").Struct<("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[], import("superstruct").Struct<"personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation", { | ||
personal_sign: "personal_sign"; | ||
eth_sign: "eth_sign"; | ||
eth_signTransaction: "eth_signTransaction"; | ||
eth_signTypedData_v1: "eth_signTypedData_v1"; | ||
eth_signTypedData_v3: "eth_signTypedData_v3"; | ||
eth_signTypedData_v4: "eth_signTypedData_v4"; | ||
eth_prepareUserOperation: "eth_prepareUserOperation"; | ||
eth_patchUserOperation: "eth_patchUserOperation"; | ||
eth_signUserOperation: "eth_signUserOperation"; | ||
}>>; | ||
type: import("superstruct").Struct<"eip155:eoa" | "eip155:erc4337", { | ||
"eip155:eoa": "eip155:eoa"; | ||
"eip155:erc4337": "eip155:erc4337"; | ||
}>; | ||
}>>; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4")[]; | ||
} | { | ||
type: "eip155:erc4337"; | ||
id: string; | ||
address: string; | ||
options: Record<string, import("@metamask/utils").Json>; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[]; | ||
})[], import("superstruct").Struct<{ | ||
type: "bip122:p2wpkh"; | ||
id: string; | ||
address: string; | ||
options: Record<string, import("@metamask/utils").Json>; | ||
methods: "btc_sendmany"[]; | ||
} | { | ||
type: "eip155:eoa"; | ||
id: string; | ||
address: string; | ||
options: Record<string, import("@metamask/utils").Json>; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4")[]; | ||
} | { | ||
type: "eip155:erc4337"; | ||
id: string; | ||
address: string; | ||
options: Record<string, import("@metamask/utils").Json>; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[]; | ||
}, null>>; | ||
export declare type ListAccountsResponse = Infer<typeof ListAccountsResponseStruct>; | ||
@@ -65,27 +70,20 @@ export declare const GetAccountRequestStruct: import("superstruct").Struct<{ | ||
export declare const GetAccountResponseStruct: import("superstruct").Struct<{ | ||
type: "eip155:eoa" | "eip155:erc4337"; | ||
type: "bip122:p2wpkh"; | ||
id: string; | ||
address: string; | ||
options: Record<string, import("@metamask/utils").Json>; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[]; | ||
}, { | ||
id: import("superstruct").Struct<string, null>; | ||
address: import("superstruct").Struct<string, null>; | ||
options: import("superstruct").Struct<Record<string, import("@metamask/utils").Json>, null>; | ||
methods: import("superstruct").Struct<("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[], import("superstruct").Struct<"personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation", { | ||
personal_sign: "personal_sign"; | ||
eth_sign: "eth_sign"; | ||
eth_signTransaction: "eth_signTransaction"; | ||
eth_signTypedData_v1: "eth_signTypedData_v1"; | ||
eth_signTypedData_v3: "eth_signTypedData_v3"; | ||
eth_signTypedData_v4: "eth_signTypedData_v4"; | ||
eth_prepareUserOperation: "eth_prepareUserOperation"; | ||
eth_patchUserOperation: "eth_patchUserOperation"; | ||
eth_signUserOperation: "eth_signUserOperation"; | ||
}>>; | ||
type: import("superstruct").Struct<"eip155:eoa" | "eip155:erc4337", { | ||
"eip155:eoa": "eip155:eoa"; | ||
"eip155:erc4337": "eip155:erc4337"; | ||
}>; | ||
}>; | ||
methods: "btc_sendmany"[]; | ||
} | { | ||
type: "eip155:eoa"; | ||
id: string; | ||
address: string; | ||
options: Record<string, import("@metamask/utils").Json>; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4")[]; | ||
} | { | ||
type: "eip155:erc4337"; | ||
id: string; | ||
address: string; | ||
options: Record<string, import("@metamask/utils").Json>; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[]; | ||
}, null>; | ||
export declare type GetAccountResponse = Infer<typeof GetAccountResponseStruct>; | ||
@@ -111,27 +109,20 @@ export declare const CreateAccountRequestStruct: import("superstruct").Struct<{ | ||
export declare const CreateAccountResponseStruct: import("superstruct").Struct<{ | ||
type: "eip155:eoa" | "eip155:erc4337"; | ||
type: "bip122:p2wpkh"; | ||
id: string; | ||
address: string; | ||
options: Record<string, import("@metamask/utils").Json>; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[]; | ||
}, { | ||
id: import("superstruct").Struct<string, null>; | ||
address: import("superstruct").Struct<string, null>; | ||
options: import("superstruct").Struct<Record<string, import("@metamask/utils").Json>, null>; | ||
methods: import("superstruct").Struct<("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[], import("superstruct").Struct<"personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation", { | ||
personal_sign: "personal_sign"; | ||
eth_sign: "eth_sign"; | ||
eth_signTransaction: "eth_signTransaction"; | ||
eth_signTypedData_v1: "eth_signTypedData_v1"; | ||
eth_signTypedData_v3: "eth_signTypedData_v3"; | ||
eth_signTypedData_v4: "eth_signTypedData_v4"; | ||
eth_prepareUserOperation: "eth_prepareUserOperation"; | ||
eth_patchUserOperation: "eth_patchUserOperation"; | ||
eth_signUserOperation: "eth_signUserOperation"; | ||
}>>; | ||
type: import("superstruct").Struct<"eip155:eoa" | "eip155:erc4337", { | ||
"eip155:eoa": "eip155:eoa"; | ||
"eip155:erc4337": "eip155:erc4337"; | ||
}>; | ||
}>; | ||
methods: "btc_sendmany"[]; | ||
} | { | ||
type: "eip155:eoa"; | ||
id: string; | ||
address: string; | ||
options: Record<string, import("@metamask/utils").Json>; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4")[]; | ||
} | { | ||
type: "eip155:erc4337"; | ||
id: string; | ||
address: string; | ||
options: Record<string, import("@metamask/utils").Json>; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[]; | ||
}, null>; | ||
export declare type CreateAccountResponse = Infer<typeof CreateAccountResponseStruct>; | ||
@@ -167,7 +158,19 @@ export declare const FilterAccountChainsStruct: import("superstruct").Struct<{ | ||
account: { | ||
type: "eip155:eoa" | "eip155:erc4337"; | ||
type: "bip122:p2wpkh"; | ||
id: string; | ||
address: string; | ||
options: Record<string, import("@metamask/utils").Json>; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[]; | ||
methods: "btc_sendmany"[]; | ||
} | { | ||
type: "eip155:eoa"; | ||
id: string; | ||
address: string; | ||
options: Record<string, import("@metamask/utils").Json>; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4")[]; | ||
} | { | ||
type: "eip155:erc4337"; | ||
id: string; | ||
address: string; | ||
options: Record<string, import("@metamask/utils").Json>; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[]; | ||
}; | ||
@@ -179,35 +182,40 @@ }; | ||
account: { | ||
type: "eip155:eoa" | "eip155:erc4337"; | ||
type: "bip122:p2wpkh"; | ||
id: string; | ||
address: string; | ||
options: Record<string, import("@metamask/utils").Json>; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[]; | ||
methods: "btc_sendmany"[]; | ||
} | { | ||
type: "eip155:eoa"; | ||
id: string; | ||
address: string; | ||
options: Record<string, import("@metamask/utils").Json>; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4")[]; | ||
} | { | ||
type: "eip155:erc4337"; | ||
id: string; | ||
address: string; | ||
options: Record<string, import("@metamask/utils").Json>; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[]; | ||
}; | ||
}, { | ||
account: import("superstruct").Struct<{ | ||
type: "eip155:eoa" | "eip155:erc4337"; | ||
type: "bip122:p2wpkh"; | ||
id: string; | ||
address: string; | ||
options: Record<string, import("@metamask/utils").Json>; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[]; | ||
}, { | ||
id: import("superstruct").Struct<string, null>; | ||
address: import("superstruct").Struct<string, null>; | ||
options: import("superstruct").Struct<Record<string, import("@metamask/utils").Json>, null>; | ||
methods: import("superstruct").Struct<("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[], import("superstruct").Struct<"personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation", { | ||
personal_sign: "personal_sign"; | ||
eth_sign: "eth_sign"; | ||
eth_signTransaction: "eth_signTransaction"; | ||
eth_signTypedData_v1: "eth_signTypedData_v1"; | ||
eth_signTypedData_v3: "eth_signTypedData_v3"; | ||
eth_signTypedData_v4: "eth_signTypedData_v4"; | ||
eth_prepareUserOperation: "eth_prepareUserOperation"; | ||
eth_patchUserOperation: "eth_patchUserOperation"; | ||
eth_signUserOperation: "eth_signUserOperation"; | ||
}>>; | ||
type: import("superstruct").Struct<"eip155:eoa" | "eip155:erc4337", { | ||
"eip155:eoa": "eip155:eoa"; | ||
"eip155:erc4337": "eip155:erc4337"; | ||
}>; | ||
}>; | ||
methods: "btc_sendmany"[]; | ||
} | { | ||
type: "eip155:eoa"; | ||
id: string; | ||
address: string; | ||
options: Record<string, import("@metamask/utils").Json>; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4")[]; | ||
} | { | ||
type: "eip155:erc4337"; | ||
id: string; | ||
address: string; | ||
options: Record<string, import("@metamask/utils").Json>; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[]; | ||
}, null>; | ||
}>; | ||
@@ -272,4 +280,4 @@ jsonrpc: import("superstruct").Struct<"2.0", "2.0">; | ||
id: string; | ||
account: string; | ||
scope: string; | ||
account: string; | ||
request: { | ||
@@ -281,4 +289,4 @@ method: string; | ||
id: string; | ||
account: string; | ||
scope: string; | ||
account: string; | ||
request: { | ||
@@ -321,4 +329,4 @@ method: string; | ||
id: string; | ||
account: string; | ||
scope: string; | ||
account: string; | ||
request: { | ||
@@ -347,4 +355,4 @@ method: string; | ||
id: string; | ||
account: string; | ||
scope: string; | ||
account: string; | ||
request: { | ||
@@ -359,4 +367,4 @@ method: string; | ||
id: string; | ||
account: string; | ||
scope: string; | ||
account: string; | ||
request: { | ||
@@ -363,0 +371,0 @@ method: string; |
@@ -5,7 +5,19 @@ export declare const AccountCreatedEventStruct: import("superstruct").Struct<{ | ||
account: { | ||
type: "eip155:eoa" | "eip155:erc4337"; | ||
type: "bip122:p2wpkh"; | ||
id: string; | ||
address: string; | ||
options: Record<string, import("@metamask/utils").Json>; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[]; | ||
methods: "btc_sendmany"[]; | ||
} | { | ||
type: "eip155:eoa"; | ||
id: string; | ||
address: string; | ||
options: Record<string, import("@metamask/utils").Json>; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4")[]; | ||
} | { | ||
type: "eip155:erc4337"; | ||
id: string; | ||
address: string; | ||
options: Record<string, import("@metamask/utils").Json>; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[]; | ||
}; | ||
@@ -17,7 +29,19 @@ }; | ||
account: { | ||
type: "eip155:eoa" | "eip155:erc4337"; | ||
type: "bip122:p2wpkh"; | ||
id: string; | ||
address: string; | ||
options: Record<string, import("@metamask/utils").Json>; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[]; | ||
methods: "btc_sendmany"[]; | ||
} | { | ||
type: "eip155:eoa"; | ||
id: string; | ||
address: string; | ||
options: Record<string, import("@metamask/utils").Json>; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4")[]; | ||
} | { | ||
type: "eip155:erc4337"; | ||
id: string; | ||
address: string; | ||
options: Record<string, import("@metamask/utils").Json>; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[]; | ||
}; | ||
@@ -29,29 +53,20 @@ }, { | ||
account: import("superstruct").Struct<{ | ||
type: "eip155:eoa" | "eip155:erc4337"; | ||
type: "bip122:p2wpkh"; | ||
id: string; | ||
address: string; | ||
options: Record<string, import("@metamask/utils").Json>; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[]; | ||
}, { | ||
id: import("superstruct").Struct<string, null>; /** | ||
* Request result. | ||
*/ | ||
address: import("superstruct").Struct<string, null>; | ||
options: import("superstruct").Struct<Record<string, import("@metamask/utils").Json>, null>; | ||
methods: import("superstruct").Struct<("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[], import("superstruct").Struct<"personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation", { | ||
personal_sign: "personal_sign"; | ||
eth_sign: "eth_sign"; | ||
eth_signTransaction: "eth_signTransaction"; | ||
eth_signTypedData_v1: "eth_signTypedData_v1"; | ||
eth_signTypedData_v3: "eth_signTypedData_v3"; | ||
eth_signTypedData_v4: "eth_signTypedData_v4"; | ||
eth_prepareUserOperation: "eth_prepareUserOperation"; | ||
eth_patchUserOperation: "eth_patchUserOperation"; | ||
eth_signUserOperation: "eth_signUserOperation"; | ||
}>>; | ||
type: import("superstruct").Struct<"eip155:eoa" | "eip155:erc4337", { | ||
"eip155:eoa": "eip155:eoa"; | ||
"eip155:erc4337": "eip155:erc4337"; | ||
}>; | ||
}>; | ||
methods: "btc_sendmany"[]; | ||
} | { | ||
type: "eip155:eoa"; | ||
id: string; | ||
address: string; | ||
options: Record<string, import("@metamask/utils").Json>; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4")[]; | ||
} | { | ||
type: "eip155:erc4337"; | ||
id: string; | ||
address: string; | ||
options: Record<string, import("@metamask/utils").Json>; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[]; | ||
}, null>; | ||
}>; | ||
@@ -63,7 +78,19 @@ }>; | ||
account: { | ||
type: "eip155:eoa" | "eip155:erc4337"; | ||
type: "bip122:p2wpkh"; | ||
id: string; | ||
address: string; | ||
options: Record<string, import("@metamask/utils").Json>; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[]; | ||
methods: "btc_sendmany"[]; | ||
} | { | ||
type: "eip155:eoa"; | ||
id: string; | ||
address: string; | ||
options: Record<string, import("@metamask/utils").Json>; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4")[]; | ||
} | { | ||
type: "eip155:erc4337"; | ||
id: string; | ||
address: string; | ||
options: Record<string, import("@metamask/utils").Json>; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[]; | ||
}; | ||
@@ -75,7 +102,19 @@ }; | ||
account: { | ||
type: "eip155:eoa" | "eip155:erc4337"; | ||
type: "bip122:p2wpkh"; | ||
id: string; | ||
address: string; | ||
options: Record<string, import("@metamask/utils").Json>; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[]; | ||
methods: "btc_sendmany"[]; | ||
} | { | ||
type: "eip155:eoa"; | ||
id: string; | ||
address: string; | ||
options: Record<string, import("@metamask/utils").Json>; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4")[]; | ||
} | { | ||
type: "eip155:erc4337"; | ||
id: string; | ||
address: string; | ||
options: Record<string, import("@metamask/utils").Json>; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[]; | ||
}; | ||
@@ -87,29 +126,20 @@ }, { | ||
account: import("superstruct").Struct<{ | ||
type: "eip155:eoa" | "eip155:erc4337"; | ||
type: "bip122:p2wpkh"; | ||
id: string; | ||
address: string; | ||
options: Record<string, import("@metamask/utils").Json>; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[]; | ||
}, { | ||
id: import("superstruct").Struct<string, null>; /** | ||
* Request result. | ||
*/ | ||
address: import("superstruct").Struct<string, null>; | ||
options: import("superstruct").Struct<Record<string, import("@metamask/utils").Json>, null>; | ||
methods: import("superstruct").Struct<("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[], import("superstruct").Struct<"personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation", { | ||
personal_sign: "personal_sign"; | ||
eth_sign: "eth_sign"; | ||
eth_signTransaction: "eth_signTransaction"; | ||
eth_signTypedData_v1: "eth_signTypedData_v1"; | ||
eth_signTypedData_v3: "eth_signTypedData_v3"; | ||
eth_signTypedData_v4: "eth_signTypedData_v4"; | ||
eth_prepareUserOperation: "eth_prepareUserOperation"; | ||
eth_patchUserOperation: "eth_patchUserOperation"; | ||
eth_signUserOperation: "eth_signUserOperation"; | ||
}>>; | ||
type: import("superstruct").Struct<"eip155:eoa" | "eip155:erc4337", { | ||
"eip155:eoa": "eip155:eoa"; | ||
"eip155:erc4337": "eip155:erc4337"; | ||
}>; | ||
}>; | ||
methods: "btc_sendmany"[]; | ||
} | { | ||
type: "eip155:eoa"; | ||
id: string; | ||
address: string; | ||
options: Record<string, import("@metamask/utils").Json>; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4")[]; | ||
} | { | ||
type: "eip155:erc4337"; | ||
id: string; | ||
address: string; | ||
options: Record<string, import("@metamask/utils").Json>; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[]; | ||
}, null>; | ||
}>; | ||
@@ -116,0 +146,0 @@ }>; |
@@ -1,8 +0,58 @@ | ||
import type { Infer } from 'superstruct'; | ||
export declare const InternalAccountStruct: import("superstruct").Struct<{ | ||
type: "eip155:eoa" | "eip155:erc4337"; | ||
import type { Infer, Struct } from 'superstruct'; | ||
import { BtcAccountType } from '../btc/types'; | ||
import { EthAccountType } from '../eth/types'; | ||
export declare type InternalAccountType = EthAccountType | BtcAccountType; | ||
export declare const InternalAccountMetadataStruct: Struct<{ | ||
metadata: { | ||
name: string; | ||
importTime: number; | ||
keyring: { | ||
type: string; | ||
}; | ||
snap?: { | ||
id: string; | ||
name: string; | ||
enabled: boolean; | ||
}; | ||
lastSelected?: number; | ||
}; | ||
}, { | ||
metadata: Struct<{ | ||
name: string; | ||
importTime: number; | ||
keyring: { | ||
type: string; | ||
}; | ||
snap?: { | ||
id: string; | ||
name: string; | ||
enabled: boolean; | ||
}; | ||
lastSelected?: number; | ||
}, { | ||
name: Struct<string, null>; | ||
snap: Struct<import("../superstruct").ExactOptionalTag | { | ||
id: string; | ||
name: string; | ||
enabled: boolean; | ||
}, { | ||
id: Struct<string, null>; | ||
enabled: Struct<boolean, null>; | ||
name: Struct<string, null>; | ||
}>; | ||
lastSelected: Struct<number | import("../superstruct").ExactOptionalTag, null>; | ||
importTime: Struct<number, null>; | ||
keyring: Struct<{ | ||
type: string; | ||
}, { | ||
type: Struct<string, null>; | ||
}>; | ||
}>; | ||
}>; | ||
export declare const InternalEthEoaAccountStruct: Struct<{ | ||
type: "eip155:eoa"; | ||
id: string; | ||
address: string; | ||
options: Record<string, import("@metamask/utils").Json>; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[]; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4")[]; | ||
metadata: { | ||
@@ -16,4 +66,4 @@ name: string; | ||
id: string; | ||
name: string; | ||
enabled: boolean; | ||
name: string; | ||
}; | ||
@@ -23,3 +73,16 @@ lastSelected?: number; | ||
}, { | ||
metadata: import("superstruct").Struct<{ | ||
type: Struct<"eip155:eoa", "eip155:eoa">; | ||
methods: Struct<("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4")[], Struct<"personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4", { | ||
personal_sign: "personal_sign"; | ||
eth_sign: "eth_sign"; | ||
eth_signTransaction: "eth_signTransaction"; | ||
eth_signTypedData_v1: "eth_signTypedData_v1"; | ||
eth_signTypedData_v3: "eth_signTypedData_v3"; | ||
eth_signTypedData_v4: "eth_signTypedData_v4"; | ||
}>>; | ||
id: Struct<string, null>; | ||
address: Struct<string, null>; | ||
options: Struct<Record<string, import("@metamask/utils").Json>, null>; | ||
} & { | ||
metadata: Struct<{ | ||
name: string; | ||
@@ -32,32 +95,50 @@ importTime: number; | ||
id: string; | ||
name: string; | ||
enabled: boolean; | ||
name: string; | ||
}; | ||
lastSelected?: number; | ||
}, { | ||
name: import("superstruct").Struct<string, null>; | ||
snap: import("superstruct").Struct<import("../superstruct").ExactOptionalTag | { | ||
name: Struct<string, null>; | ||
snap: Struct<import("../superstruct").ExactOptionalTag | { | ||
id: string; | ||
name: string; | ||
enabled: boolean; | ||
name: string; | ||
}, { | ||
id: import("superstruct").Struct<string, null>; | ||
enabled: import("superstruct").Struct<boolean, null>; | ||
name: import("superstruct").Struct<string, null>; | ||
id: Struct<string, null>; | ||
enabled: Struct<boolean, null>; | ||
name: Struct<string, null>; | ||
}>; | ||
lastSelected: import("superstruct").Struct<number | import("../superstruct").ExactOptionalTag, null>; | ||
importTime: import("superstruct").Struct<number, null>; | ||
keyring: import("superstruct").Struct<{ | ||
lastSelected: Struct<number | import("../superstruct").ExactOptionalTag, null>; | ||
importTime: Struct<number, null>; | ||
keyring: Struct<{ | ||
type: string; | ||
}, { | ||
type: import("superstruct").Struct<string, null>; | ||
type: Struct<string, null>; | ||
}>; | ||
}>; | ||
id: import("superstruct").Struct<string, null>; | ||
address: import("superstruct").Struct<string, null>; | ||
options: import("superstruct").Struct<Record<string, import("@metamask/utils").Json>, null>; | ||
methods: import("superstruct").Struct<("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[], import("superstruct").Struct<"personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation", { | ||
}>; | ||
export declare const InternalEthErc4337AccountStruct: Struct<{ | ||
type: "eip155:erc4337"; | ||
id: string; | ||
address: string; | ||
options: Record<string, import("@metamask/utils").Json>; | ||
methods: ("personal_sign" | "eth_sign" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[]; | ||
metadata: { | ||
name: string; | ||
importTime: number; | ||
keyring: { | ||
type: string; | ||
}; | ||
snap?: { | ||
id: string; | ||
name: string; | ||
enabled: boolean; | ||
}; | ||
lastSelected?: number; | ||
}; | ||
}, { | ||
type: Struct<"eip155:erc4337", "eip155:erc4337">; | ||
methods: Struct<("personal_sign" | "eth_sign" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[], Struct<"personal_sign" | "eth_sign" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation", { | ||
personal_sign: "personal_sign"; | ||
eth_sign: "eth_sign"; | ||
eth_signTransaction: "eth_signTransaction"; | ||
eth_signTypedData_v1: "eth_signTypedData_v1"; | ||
@@ -70,7 +151,104 @@ eth_signTypedData_v3: "eth_signTypedData_v3"; | ||
}>>; | ||
type: import("superstruct").Struct<"eip155:eoa" | "eip155:erc4337", { | ||
"eip155:eoa": "eip155:eoa"; | ||
"eip155:erc4337": "eip155:erc4337"; | ||
id: Struct<string, null>; | ||
address: Struct<string, null>; | ||
options: Struct<Record<string, import("@metamask/utils").Json>, null>; | ||
} & { | ||
metadata: Struct<{ | ||
name: string; | ||
importTime: number; | ||
keyring: { | ||
type: string; | ||
}; | ||
snap?: { | ||
id: string; | ||
name: string; | ||
enabled: boolean; | ||
}; | ||
lastSelected?: number; | ||
}, { | ||
name: Struct<string, null>; | ||
snap: Struct<import("../superstruct").ExactOptionalTag | { | ||
id: string; | ||
name: string; | ||
enabled: boolean; | ||
}, { | ||
id: Struct<string, null>; | ||
enabled: Struct<boolean, null>; | ||
name: Struct<string, null>; | ||
}>; | ||
lastSelected: Struct<number | import("../superstruct").ExactOptionalTag, null>; | ||
importTime: Struct<number, null>; | ||
keyring: Struct<{ | ||
type: string; | ||
}, { | ||
type: Struct<string, null>; | ||
}>; | ||
}>; | ||
}>; | ||
export declare const InternalBtcP2wpkhAccountStruct: Struct<{ | ||
type: "bip122:p2wpkh"; | ||
id: string; | ||
address: string; | ||
options: Record<string, import("@metamask/utils").Json>; | ||
methods: "btc_sendmany"[]; | ||
metadata: { | ||
name: string; | ||
importTime: number; | ||
keyring: { | ||
type: string; | ||
}; | ||
snap?: { | ||
id: string; | ||
name: string; | ||
enabled: boolean; | ||
}; | ||
lastSelected?: number; | ||
}; | ||
}, { | ||
type: Struct<"bip122:p2wpkh", "bip122:p2wpkh">; | ||
methods: Struct<"btc_sendmany"[], Struct<"btc_sendmany", { | ||
btc_sendmany: "btc_sendmany"; | ||
}>>; | ||
id: Struct<string, null>; | ||
address: Struct<string, null>; | ||
options: Struct<Record<string, import("@metamask/utils").Json>, null>; | ||
} & { | ||
metadata: Struct<{ | ||
name: string; | ||
importTime: number; | ||
keyring: { | ||
type: string; | ||
}; | ||
snap?: { | ||
id: string; | ||
name: string; | ||
enabled: boolean; | ||
}; | ||
lastSelected?: number; | ||
}, { | ||
name: Struct<string, null>; | ||
snap: Struct<import("../superstruct").ExactOptionalTag | { | ||
id: string; | ||
name: string; | ||
enabled: boolean; | ||
}, { | ||
id: Struct<string, null>; | ||
enabled: Struct<boolean, null>; | ||
name: Struct<string, null>; | ||
}>; | ||
lastSelected: Struct<number | import("../superstruct").ExactOptionalTag, null>; | ||
importTime: Struct<number, null>; | ||
keyring: Struct<{ | ||
type: string; | ||
}, { | ||
type: Struct<string, null>; | ||
}>; | ||
}>; | ||
}>; | ||
export declare type InternalEthEoaAccount = Infer<typeof InternalEthEoaAccountStruct>; | ||
export declare type InternalEthErc4337Account = Infer<typeof InternalEthErc4337AccountStruct>; | ||
export declare type InternalBtcP2wpkhAccount = Infer<typeof InternalBtcP2wpkhAccountStruct>; | ||
export declare const InternalAccountStructs: Record<string, Struct<InternalEthEoaAccount> | Struct<InternalEthErc4337Account> | Struct<InternalBtcP2wpkhAccount>>; | ||
export declare type InternalAccountTypes = InternalEthEoaAccount | InternalEthErc4337Account | InternalBtcP2wpkhAccount; | ||
export declare const InternalAccountStruct: Struct<InternalAccountTypes, null>; | ||
/** | ||
@@ -77,0 +255,0 @@ * Internal account representation. |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.InternalAccountStruct = void 0; | ||
exports.InternalAccountStruct = exports.InternalAccountStructs = exports.InternalBtcP2wpkhAccountStruct = exports.InternalEthErc4337AccountStruct = exports.InternalEthEoaAccountStruct = exports.InternalAccountMetadataStruct = void 0; | ||
const superstruct_1 = require("superstruct"); | ||
const api_1 = require("../api"); | ||
const types_1 = require("../btc/types"); | ||
const types_2 = require("../eth/types"); | ||
const superstruct_2 = require("../superstruct"); | ||
exports.InternalAccountStruct = (0, superstruct_2.object)({ | ||
...api_1.KeyringAccountStruct.schema, | ||
exports.InternalAccountMetadataStruct = (0, superstruct_2.object)({ | ||
metadata: (0, superstruct_2.object)({ | ||
@@ -23,2 +24,28 @@ name: (0, superstruct_1.string)(), | ||
}); | ||
/** | ||
* Creates an `InternalAccount` from an existing account `superstruct` object. | ||
* | ||
* @param accountStruct - An account `superstruct` object. | ||
* @returns The `InternalAccount` assocaited to `accountStruct`. | ||
*/ | ||
function asInternalAccountStruct(accountStruct) { | ||
return (0, superstruct_2.object)({ | ||
...accountStruct.schema, | ||
...exports.InternalAccountMetadataStruct.schema, | ||
}); | ||
} | ||
exports.InternalEthEoaAccountStruct = asInternalAccountStruct(types_2.EthEoaAccountStruct); | ||
exports.InternalEthErc4337AccountStruct = asInternalAccountStruct(types_2.EthErc4337AccountStruct); | ||
exports.InternalBtcP2wpkhAccountStruct = asInternalAccountStruct(types_1.BtcP2wpkhAccountStruct); | ||
exports.InternalAccountStructs = { | ||
[`${types_2.EthAccountType.Eoa}`]: exports.InternalEthEoaAccountStruct, | ||
[`${types_2.EthAccountType.Erc4337}`]: exports.InternalEthErc4337AccountStruct, | ||
[`${types_1.BtcAccountType.P2wpkh}`]: exports.InternalBtcP2wpkhAccountStruct, | ||
}; | ||
exports.InternalAccountStruct = (0, superstruct_1.define)('InternalAccount', (value) => { | ||
const account = (0, superstruct_1.mask)(value, api_1.BaseKeyringAccountStruct); | ||
// At this point, we know that `value.type` can be used as an index for `KeyringAccountStructs` | ||
const [error] = (0, superstruct_1.validate)(value, exports.InternalAccountStructs[account.type]); | ||
return error ?? true; | ||
}); | ||
//# sourceMappingURL=types.js.map |
{ | ||
"name": "@metamask/keyring-api", | ||
"version": "6.0.0", | ||
"version": "6.1.0", | ||
"description": "MetaMask Keyring API", | ||
@@ -44,2 +44,3 @@ "keywords": [ | ||
"@types/uuid": "^9.0.1", | ||
"bech32": "^2.0.0", | ||
"superstruct": "^1.0.3", | ||
@@ -46,0 +47,0 @@ "uuid": "^9.0.0" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
223241
81
2885
7
+ Addedbech32@^2.0.0
+ Addedbech32@2.0.0(transitive)