@metamask/keyring-api
Advanced tools
+19
-2
@@ -10,6 +10,22 @@ # Changelog | ||
| ## [21.4.0] | ||
| ## [21.5.0] | ||
| ### Added | ||
| - Add `EthAddressStrictStruct` struct and `EthAddressStrict` types ([#465](https://github.com/MetaMask/accounts/pull/465)) | ||
| - This is a stricter variant of `EthAddressStruct` which uses `Hex` instead of `string` for its inferred type. | ||
| - Add `assertCreateAccountOptionIsSupported` helper ([#464](https://github.com/MetaMask/accounts/pull/464)) | ||
| - This helper can be used to implement `createAccounts` and narrow down the `options` to the supported types (based on the keyring capabilities). | ||
| ### Changed | ||
| - Re-use `string` for ERC4337 address-like fields ([#465](https://github.com/MetaMask/accounts/pull/465)) | ||
| - This change reverts that and keeps using `string` for all address-like types. | ||
| - Changes in [#405](https://github.com/MetaMask/accounts/pull/405) updated the associated type for `EthAddressStruct` from `string` to `Hex`, this was actually a small breaking change that went unnoticed and that would require some effort to adapt in upstream clients/controllers, for this reason, we are undoing this change for now. | ||
| - Version [21.4.0] is marked as **DEPRECATED**, consumers are expected to use version [21.5.0] instead, that reverts this breaking change. | ||
| ## [21.4.0] - 2026-02-09 [DEPRECATED] | ||
| ### Added | ||
| - Add `Keyring.createAccounts` optional method ([#448](https://github.com/MetaMask/accounts/pull/448)) | ||
@@ -688,3 +704,4 @@ - This method is part of the keyring v2 specification and set as optional for backwards compatibility. | ||
| [Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@21.4.0...HEAD | ||
| [Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@21.5.0...HEAD | ||
| [21.5.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@21.4.0...@metamask/keyring-api@21.5.0 | ||
| [21.4.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@21.3.0...@metamask/keyring-api@21.4.0 | ||
@@ -691,0 +708,0 @@ [21.3.0]: https://github.com/MetaMask/accounts/compare/@metamask/keyring-api@21.2.0...@metamask/keyring-api@21.3.0 |
@@ -18,2 +18,3 @@ "use strict"; | ||
| exports.CreateAccountOptionsStruct = exports.AccountCreationType = void 0; | ||
| exports.assertCreateAccountOptionIsSupported = assertCreateAccountOptionIsSupported; | ||
| const keyring_utils_1 = require("@metamask/keyring-utils"); | ||
@@ -94,2 +95,35 @@ const bip44_1 = require("./bip44.cjs"); | ||
| }); | ||
| /** | ||
| * Asserts that a given create account option type is supported by the keyring. | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * createAccounts(options: CreateAccountOptions) { | ||
| * assertCreateAccountOptionIsSupported(options, [ | ||
| * ${AccountCreationType.Bip44DeriveIndex}, | ||
| * ${AccountCreationType.Bip44DeriveIndexRange}, | ||
| * ] as const); | ||
| * | ||
| * // At this point, TypeScript knows that options.type is either Bip44DeriveIndex or Bip44DeriveIndexRange. | ||
| * if (options.type === AccountCreationType.Bip44DeriveIndex) { | ||
| * ... // Handle Bip44DeriveIndex case. | ||
| * } else { | ||
| * ... // Handle Bip44DeriveIndexRange case. | ||
| * } | ||
| * ... | ||
| * return accounts; | ||
| * } | ||
| * ``` | ||
| * | ||
| * @param options - The create account option object to check. | ||
| * @param supportedTypes - The list of supported create account option types for this keyring. | ||
| * @throws Will throw an error if the provided options are not supported. | ||
| */ | ||
| function assertCreateAccountOptionIsSupported(options, supportedTypes) { | ||
| const { type } = options; | ||
| const types = supportedTypes; | ||
| if (!types.includes(type)) { | ||
| throw new Error(`Unsupported create account option type: ${type}`); | ||
| } | ||
| } | ||
| //# sourceMappingURL=index.cjs.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../../src/api/v2/create-account/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2DAAyD;AAGzD,uCAKiB;AACjB,yCAA4D;AAC5D,mDAAqE;AAErE,8CAAwB;AACxB,+CAAyB;AACzB,oDAA8B;AAE9B;;GAEG;AACH,IAAY,mBA6CX;AA7CD,WAAY,mBAAmB;IAC7B;;OAEG;IACH,4DAAqC,CAAA;IAErC;;;;;;OAMG;IACH,8DAAuC,CAAA;IAEvC;;;;;;OAMG;IACH,yEAAkD,CAAA;IAElD;;;;;;OAMG;IACH,uDAAgC,CAAA;IAEhC;;OAEG;IACH,8DAAuC,CAAA;IAEvC;;;;;OAKG;IACH,wCAAiB,CAAA;AACnB,CAAC,EA7CW,mBAAmB,mCAAnB,mBAAmB,QA6C9B;AAED;;GAEG;AACU,QAAA,0BAA0B,GAAG,IAAA,8BAAc,EAAC,CAAC,KAAU,EAAE,EAAE;IACtE,MAAM,mBAAmB,GAAG,KAAK,EAAE,IAA2B,CAAC;IAC/D,QAAQ,mBAAmB,EAAE,CAAC;QAC5B,KAAK,mBAAmB,CAAC,eAAe;YACtC,OAAO,iDAAyC,CAAC;QACnD,KAAK,mBAAmB,CAAC,gBAAgB;YACvC,OAAO,kDAA0C,CAAC;QACpD,KAAK,mBAAmB,CAAC,qBAAqB;YAC5C,OAAO,uDAA+C,CAAC;QACzD,KAAK,mBAAmB,CAAC,aAAa;YACpC,OAAO,+CAAuC,CAAC;QACjD,KAAK,mBAAmB,CAAC,gBAAgB;YACvC,OAAO,kDAAoC,CAAC;QAC9C,KAAK,mBAAmB,CAAC,MAAM;YAC7B,OAAO,yCAAgC,CAAC;QAC1C;YACE,wGAAwG;YACxG,OAAO,iDAAyC,CAAC;IACrD,CAAC;AACH,CAAC,CAAC,CAAC","sourcesContent":["import { selectiveUnion } from '@metamask/keyring-utils';\nimport { type Infer } from '@metamask/superstruct';\n\nimport {\n CreateAccountBip44DiscoverOptionsStruct,\n CreateAccountBip44DeriveIndexOptionsStruct,\n CreateAccountBip44DeriveIndexRangeOptionsStruct,\n CreateAccountBip44DerivePathOptionsStruct,\n} from './bip44';\nimport { CreateAccountCustomOptionsStruct } from './custom';\nimport { CreateAccountPrivateKeyOptionsStruct } from './private-key';\n\nexport * from './bip44';\nexport * from './custom';\nexport * from './private-key';\n\n/**\n * Enum representing the different ways an account can be created.\n */\nexport enum AccountCreationType {\n /**\n * Represents an account created using a BIP-44 derivation path.\n */\n Bip44DerivePath = 'bip44:derive-path',\n\n /**\n * Represents accounts created using a BIP-44 account index.\n *\n * More than one account can be created, for example, the keyring can create\n * multiple account types (e.g., P2PKH, P2TR, P2WPKH) for the same account\n * index.\n */\n Bip44DeriveIndex = 'bip44:derive-index',\n\n /**\n * Represents accounts created by deriving a range of BIP-44 account indices.\n *\n * More than one account can be created per index, for example, the keyring\n * can create multiple account types (e.g., P2PKH, P2TR, P2WPKH) for each\n * account index in the range.\n */\n Bip44DeriveIndexRange = 'bip44:derive-index-range',\n\n /**\n * Represents accounts created through BIP-44 account discovery.\n *\n * More than one account can be created, for example, the keyring can create\n * multiple account types (e.g., P2PKH, P2TR, P2WPKH) for the same account\n * index.\n */\n Bip44Discover = 'bip44:discover',\n\n /**\n * Represents an account imported from a private key.\n */\n PrivateKeyImport = 'private-key:import',\n\n /**\n * Represents an account created using a custom, keyring-specific method.\n *\n * This is used by keyrings that have non-standard account creation flows\n * and declare `custom.createAccounts: true` in their capabilities.\n */\n Custom = 'custom',\n}\n\n/**\n * Struct for {@link CreateAccountOptions}.\n */\nexport const CreateAccountOptionsStruct = selectiveUnion((value: any) => {\n const accountCreationType = value?.type as AccountCreationType;\n switch (accountCreationType) {\n case AccountCreationType.Bip44DerivePath:\n return CreateAccountBip44DerivePathOptionsStruct;\n case AccountCreationType.Bip44DeriveIndex:\n return CreateAccountBip44DeriveIndexOptionsStruct;\n case AccountCreationType.Bip44DeriveIndexRange:\n return CreateAccountBip44DeriveIndexRangeOptionsStruct;\n case AccountCreationType.Bip44Discover:\n return CreateAccountBip44DiscoverOptionsStruct;\n case AccountCreationType.PrivateKeyImport:\n return CreateAccountPrivateKeyOptionsStruct;\n case AccountCreationType.Custom:\n return CreateAccountCustomOptionsStruct;\n default:\n // Return first struct as fallback - validation will fail with proper error indicating the type mismatch\n return CreateAccountBip44DerivePathOptionsStruct;\n }\n});\n\n/**\n * Represents the available options for creating a new account.\n */\nexport type CreateAccountOptions = Infer<typeof CreateAccountOptionsStruct>;\n"]} | ||
| {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../../src/api/v2/create-account/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAyHA,oFAeC;AAxID,2DAAyD;AAGzD,uCAKiB;AACjB,yCAA4D;AAC5D,mDAAqE;AAErE,8CAAwB;AACxB,+CAAyB;AACzB,oDAA8B;AAE9B;;GAEG;AACH,IAAY,mBA6CX;AA7CD,WAAY,mBAAmB;IAC7B;;OAEG;IACH,4DAAqC,CAAA;IAErC;;;;;;OAMG;IACH,8DAAuC,CAAA;IAEvC;;;;;;OAMG;IACH,yEAAkD,CAAA;IAElD;;;;;;OAMG;IACH,uDAAgC,CAAA;IAEhC;;OAEG;IACH,8DAAuC,CAAA;IAEvC;;;;;OAKG;IACH,wCAAiB,CAAA;AACnB,CAAC,EA7CW,mBAAmB,mCAAnB,mBAAmB,QA6C9B;AAED;;GAEG;AACU,QAAA,0BAA0B,GAAG,IAAA,8BAAc,EAAC,CAAC,KAAU,EAAE,EAAE;IACtE,MAAM,mBAAmB,GAAG,KAAK,EAAE,IAA2B,CAAC;IAC/D,QAAQ,mBAAmB,EAAE,CAAC;QAC5B,KAAK,mBAAmB,CAAC,eAAe;YACtC,OAAO,iDAAyC,CAAC;QACnD,KAAK,mBAAmB,CAAC,gBAAgB;YACvC,OAAO,kDAA0C,CAAC;QACpD,KAAK,mBAAmB,CAAC,qBAAqB;YAC5C,OAAO,uDAA+C,CAAC;QACzD,KAAK,mBAAmB,CAAC,aAAa;YACpC,OAAO,+CAAuC,CAAC;QACjD,KAAK,mBAAmB,CAAC,gBAAgB;YACvC,OAAO,kDAAoC,CAAC;QAC9C,KAAK,mBAAmB,CAAC,MAAM;YAC7B,OAAO,yCAAgC,CAAC;QAC1C;YACE,wGAAwG;YACxG,OAAO,iDAAyC,CAAC;IACrD,CAAC;AACH,CAAC,CAAC,CAAC;AAOH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,SAAgB,oCAAoC,CAKlD,OAAgB,EAChB,cAAoC;IAGpC,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;IACzB,MAAM,KAAK,GAA4C,cAAc,CAAC;IAEtE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,2CAA2C,IAAI,EAAE,CAAC,CAAC;IACrE,CAAC;AACH,CAAC","sourcesContent":["import { selectiveUnion } from '@metamask/keyring-utils';\nimport { type Infer } from '@metamask/superstruct';\n\nimport {\n CreateAccountBip44DiscoverOptionsStruct,\n CreateAccountBip44DeriveIndexOptionsStruct,\n CreateAccountBip44DeriveIndexRangeOptionsStruct,\n CreateAccountBip44DerivePathOptionsStruct,\n} from './bip44';\nimport { CreateAccountCustomOptionsStruct } from './custom';\nimport { CreateAccountPrivateKeyOptionsStruct } from './private-key';\n\nexport * from './bip44';\nexport * from './custom';\nexport * from './private-key';\n\n/**\n * Enum representing the different ways an account can be created.\n */\nexport enum AccountCreationType {\n /**\n * Represents an account created using a BIP-44 derivation path.\n */\n Bip44DerivePath = 'bip44:derive-path',\n\n /**\n * Represents accounts created using a BIP-44 account index.\n *\n * More than one account can be created, for example, the keyring can create\n * multiple account types (e.g., P2PKH, P2TR, P2WPKH) for the same account\n * index.\n */\n Bip44DeriveIndex = 'bip44:derive-index',\n\n /**\n * Represents accounts created by deriving a range of BIP-44 account indices.\n *\n * More than one account can be created per index, for example, the keyring\n * can create multiple account types (e.g., P2PKH, P2TR, P2WPKH) for each\n * account index in the range.\n */\n Bip44DeriveIndexRange = 'bip44:derive-index-range',\n\n /**\n * Represents accounts created through BIP-44 account discovery.\n *\n * More than one account can be created, for example, the keyring can create\n * multiple account types (e.g., P2PKH, P2TR, P2WPKH) for the same account\n * index.\n */\n Bip44Discover = 'bip44:discover',\n\n /**\n * Represents an account imported from a private key.\n */\n PrivateKeyImport = 'private-key:import',\n\n /**\n * Represents an account created using a custom, keyring-specific method.\n *\n * This is used by keyrings that have non-standard account creation flows\n * and declare `custom.createAccounts: true` in their capabilities.\n */\n Custom = 'custom',\n}\n\n/**\n * Struct for {@link CreateAccountOptions}.\n */\nexport const CreateAccountOptionsStruct = selectiveUnion((value: any) => {\n const accountCreationType = value?.type as AccountCreationType;\n switch (accountCreationType) {\n case AccountCreationType.Bip44DerivePath:\n return CreateAccountBip44DerivePathOptionsStruct;\n case AccountCreationType.Bip44DeriveIndex:\n return CreateAccountBip44DeriveIndexOptionsStruct;\n case AccountCreationType.Bip44DeriveIndexRange:\n return CreateAccountBip44DeriveIndexRangeOptionsStruct;\n case AccountCreationType.Bip44Discover:\n return CreateAccountBip44DiscoverOptionsStruct;\n case AccountCreationType.PrivateKeyImport:\n return CreateAccountPrivateKeyOptionsStruct;\n case AccountCreationType.Custom:\n return CreateAccountCustomOptionsStruct;\n default:\n // Return first struct as fallback - validation will fail with proper error indicating the type mismatch\n return CreateAccountBip44DerivePathOptionsStruct;\n }\n});\n\n/**\n * Represents the available options for creating a new account.\n */\nexport type CreateAccountOptions = Infer<typeof CreateAccountOptionsStruct>;\n\n/**\n * Asserts that a given create account option type is supported by the keyring.\n *\n * @example\n * ```ts\n * createAccounts(options: CreateAccountOptions) {\n * assertCreateAccountOptionIsSupported(options, [\n * ${AccountCreationType.Bip44DeriveIndex},\n * ${AccountCreationType.Bip44DeriveIndexRange},\n * ] as const);\n *\n * // At this point, TypeScript knows that options.type is either Bip44DeriveIndex or Bip44DeriveIndexRange.\n * if (options.type === AccountCreationType.Bip44DeriveIndex) {\n * ... // Handle Bip44DeriveIndex case.\n * } else {\n * ... // Handle Bip44DeriveIndexRange case.\n * }\n * ...\n * return accounts;\n * }\n * ```\n *\n * @param options - The create account option object to check.\n * @param supportedTypes - The list of supported create account option types for this keyring.\n * @throws Will throw an error if the provided options are not supported.\n */\nexport function assertCreateAccountOptionIsSupported<\n Options extends CreateAccountOptions,\n // We use template literal types to enforce string-literal over strict enum values.\n Type extends `${CreateAccountOptions['type']}`,\n>(\n options: Options,\n supportedTypes: readonly `${Type}`[],\n // Use intersection to avoid widening `type` beyond `Options['type']`.\n): asserts options is Options & { type: `${Type}` & `${Options['type']}` } {\n const { type } = options;\n const types: readonly CreateAccountOptions['type'][] = supportedTypes;\n\n if (!types.includes(type)) {\n throw new Error(`Unsupported create account option type: ${type}`);\n }\n}\n"]} |
@@ -83,2 +83,31 @@ import { type Infer } from "@metamask/superstruct"; | ||
| export type CreateAccountOptions = Infer<typeof CreateAccountOptionsStruct>; | ||
| /** | ||
| * Asserts that a given create account option type is supported by the keyring. | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * createAccounts(options: CreateAccountOptions) { | ||
| * assertCreateAccountOptionIsSupported(options, [ | ||
| * ${AccountCreationType.Bip44DeriveIndex}, | ||
| * ${AccountCreationType.Bip44DeriveIndexRange}, | ||
| * ] as const); | ||
| * | ||
| * // At this point, TypeScript knows that options.type is either Bip44DeriveIndex or Bip44DeriveIndexRange. | ||
| * if (options.type === AccountCreationType.Bip44DeriveIndex) { | ||
| * ... // Handle Bip44DeriveIndex case. | ||
| * } else { | ||
| * ... // Handle Bip44DeriveIndexRange case. | ||
| * } | ||
| * ... | ||
| * return accounts; | ||
| * } | ||
| * ``` | ||
| * | ||
| * @param options - The create account option object to check. | ||
| * @param supportedTypes - The list of supported create account option types for this keyring. | ||
| * @throws Will throw an error if the provided options are not supported. | ||
| */ | ||
| export declare function assertCreateAccountOptionIsSupported<Options extends CreateAccountOptions, Type extends `${CreateAccountOptions['type']}`>(options: Options, supportedTypes: readonly `${Type}`[]): asserts options is Options & { | ||
| type: `${Type}` & `${Options['type']}`; | ||
| }; | ||
| //# sourceMappingURL=index.d.cts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../../src/api/v2/create-account/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,KAAK,EAAE,8BAA8B;AAWnD,4BAAwB;AACxB,6BAAyB;AACzB,kCAA8B;AAE9B;;GAEG;AACH,oBAAY,mBAAmB;IAC7B;;OAEG;IACH,eAAe,sBAAsB;IAErC;;;;;;OAMG;IACH,gBAAgB,uBAAuB;IAEvC;;;;;;OAMG;IACH,qBAAqB,6BAA6B;IAElD;;;;;;OAMG;IACH,aAAa,mBAAmB;IAEhC;;OAEG;IACH,gBAAgB,uBAAuB;IAEvC;;;;;OAKG;IACH,MAAM,WAAW;CAClB;AAED;;GAEG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;QAmBrC,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC"} | ||
| {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../../src/api/v2/create-account/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,KAAK,EAAE,8BAA8B;AAWnD,4BAAwB;AACxB,6BAAyB;AACzB,kCAA8B;AAE9B;;GAEG;AACH,oBAAY,mBAAmB;IAC7B;;OAEG;IACH,eAAe,sBAAsB;IAErC;;;;;;OAMG;IACH,gBAAgB,uBAAuB;IAEvC;;;;;;OAMG;IACH,qBAAqB,6BAA6B;IAElD;;;;;;OAMG;IACH,aAAa,mBAAmB;IAEhC;;OAEG;IACH,gBAAgB,uBAAuB;IAEvC;;;;;OAKG;IACH,MAAM,WAAW;CAClB;AAED;;GAEG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;QAmBrC,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE5E;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,oCAAoC,CAClD,OAAO,SAAS,oBAAoB,EAEpC,IAAI,SAAS,GAAG,oBAAoB,CAAC,MAAM,CAAC,EAAE,EAE9C,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,SAAS,GAAG,IAAI,EAAE,EAAE,GAEnC,OAAO,CAAC,OAAO,IAAI,OAAO,GAAG;IAAE,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,EAAE,CAAA;CAAE,CAOzE"} |
@@ -83,2 +83,31 @@ import { type Infer } from "@metamask/superstruct"; | ||
| export type CreateAccountOptions = Infer<typeof CreateAccountOptionsStruct>; | ||
| /** | ||
| * Asserts that a given create account option type is supported by the keyring. | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * createAccounts(options: CreateAccountOptions) { | ||
| * assertCreateAccountOptionIsSupported(options, [ | ||
| * ${AccountCreationType.Bip44DeriveIndex}, | ||
| * ${AccountCreationType.Bip44DeriveIndexRange}, | ||
| * ] as const); | ||
| * | ||
| * // At this point, TypeScript knows that options.type is either Bip44DeriveIndex or Bip44DeriveIndexRange. | ||
| * if (options.type === AccountCreationType.Bip44DeriveIndex) { | ||
| * ... // Handle Bip44DeriveIndex case. | ||
| * } else { | ||
| * ... // Handle Bip44DeriveIndexRange case. | ||
| * } | ||
| * ... | ||
| * return accounts; | ||
| * } | ||
| * ``` | ||
| * | ||
| * @param options - The create account option object to check. | ||
| * @param supportedTypes - The list of supported create account option types for this keyring. | ||
| * @throws Will throw an error if the provided options are not supported. | ||
| */ | ||
| export declare function assertCreateAccountOptionIsSupported<Options extends CreateAccountOptions, Type extends `${CreateAccountOptions['type']}`>(options: Options, supportedTypes: readonly `${Type}`[]): asserts options is Options & { | ||
| type: `${Type}` & `${Options['type']}`; | ||
| }; | ||
| //# sourceMappingURL=index.d.mts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../../src/api/v2/create-account/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,KAAK,EAAE,8BAA8B;AAWnD,4BAAwB;AACxB,6BAAyB;AACzB,kCAA8B;AAE9B;;GAEG;AACH,oBAAY,mBAAmB;IAC7B;;OAEG;IACH,eAAe,sBAAsB;IAErC;;;;;;OAMG;IACH,gBAAgB,uBAAuB;IAEvC;;;;;;OAMG;IACH,qBAAqB,6BAA6B;IAElD;;;;;;OAMG;IACH,aAAa,mBAAmB;IAEhC;;OAEG;IACH,gBAAgB,uBAAuB;IAEvC;;;;;OAKG;IACH,MAAM,WAAW;CAClB;AAED;;GAEG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;QAmBrC,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC"} | ||
| {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../../src/api/v2/create-account/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,KAAK,EAAE,8BAA8B;AAWnD,4BAAwB;AACxB,6BAAyB;AACzB,kCAA8B;AAE9B;;GAEG;AACH,oBAAY,mBAAmB;IAC7B;;OAEG;IACH,eAAe,sBAAsB;IAErC;;;;;;OAMG;IACH,gBAAgB,uBAAuB;IAEvC;;;;;;OAMG;IACH,qBAAqB,6BAA6B;IAElD;;;;;;OAMG;IACH,aAAa,mBAAmB;IAEhC;;OAEG;IACH,gBAAgB,uBAAuB;IAEvC;;;;;OAKG;IACH,MAAM,WAAW;CAClB;AAED;;GAEG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;QAmBrC,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE5E;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,oCAAoC,CAClD,OAAO,SAAS,oBAAoB,EAEpC,IAAI,SAAS,GAAG,oBAAoB,CAAC,MAAM,CAAC,EAAE,EAE9C,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,SAAS,GAAG,IAAI,EAAE,EAAE,GAEnC,OAAO,CAAC,OAAO,IAAI,OAAO,GAAG;IAAE,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,EAAE,CAAA;CAAE,CAOzE"} |
@@ -76,2 +76,35 @@ import { selectiveUnion } from "@metamask/keyring-utils"; | ||
| }); | ||
| /** | ||
| * Asserts that a given create account option type is supported by the keyring. | ||
| * | ||
| * @example | ||
| * ```ts | ||
| * createAccounts(options: CreateAccountOptions) { | ||
| * assertCreateAccountOptionIsSupported(options, [ | ||
| * ${AccountCreationType.Bip44DeriveIndex}, | ||
| * ${AccountCreationType.Bip44DeriveIndexRange}, | ||
| * ] as const); | ||
| * | ||
| * // At this point, TypeScript knows that options.type is either Bip44DeriveIndex or Bip44DeriveIndexRange. | ||
| * if (options.type === AccountCreationType.Bip44DeriveIndex) { | ||
| * ... // Handle Bip44DeriveIndex case. | ||
| * } else { | ||
| * ... // Handle Bip44DeriveIndexRange case. | ||
| * } | ||
| * ... | ||
| * return accounts; | ||
| * } | ||
| * ``` | ||
| * | ||
| * @param options - The create account option object to check. | ||
| * @param supportedTypes - The list of supported create account option types for this keyring. | ||
| * @throws Will throw an error if the provided options are not supported. | ||
| */ | ||
| export function assertCreateAccountOptionIsSupported(options, supportedTypes) { | ||
| const { type } = options; | ||
| const types = supportedTypes; | ||
| if (!types.includes(type)) { | ||
| throw new Error(`Unsupported create account option type: ${type}`); | ||
| } | ||
| } | ||
| //# sourceMappingURL=index.mjs.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../../src/api/v2/create-account/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,gCAAgC;AAGzD,OAAO,EACL,uCAAuC,EACvC,0CAA0C,EAC1C,+CAA+C,EAC/C,yCAAyC,EAC1C,oBAAgB;AACjB,OAAO,EAAE,gCAAgC,EAAE,qBAAiB;AAC5D,OAAO,EAAE,oCAAoC,EAAE,0BAAsB;AAErE,4BAAwB;AACxB,6BAAyB;AACzB,kCAA8B;AAE9B;;GAEG;AACH,MAAM,CAAN,IAAY,mBA6CX;AA7CD,WAAY,mBAAmB;IAC7B;;OAEG;IACH,4DAAqC,CAAA;IAErC;;;;;;OAMG;IACH,8DAAuC,CAAA;IAEvC;;;;;;OAMG;IACH,yEAAkD,CAAA;IAElD;;;;;;OAMG;IACH,uDAAgC,CAAA;IAEhC;;OAEG;IACH,8DAAuC,CAAA;IAEvC;;;;;OAKG;IACH,wCAAiB,CAAA;AACnB,CAAC,EA7CW,mBAAmB,KAAnB,mBAAmB,QA6C9B;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,cAAc,CAAC,CAAC,KAAU,EAAE,EAAE;IACtE,MAAM,mBAAmB,GAAG,KAAK,EAAE,IAA2B,CAAC;IAC/D,QAAQ,mBAAmB,EAAE,CAAC;QAC5B,KAAK,mBAAmB,CAAC,eAAe;YACtC,OAAO,yCAAyC,CAAC;QACnD,KAAK,mBAAmB,CAAC,gBAAgB;YACvC,OAAO,0CAA0C,CAAC;QACpD,KAAK,mBAAmB,CAAC,qBAAqB;YAC5C,OAAO,+CAA+C,CAAC;QACzD,KAAK,mBAAmB,CAAC,aAAa;YACpC,OAAO,uCAAuC,CAAC;QACjD,KAAK,mBAAmB,CAAC,gBAAgB;YACvC,OAAO,oCAAoC,CAAC;QAC9C,KAAK,mBAAmB,CAAC,MAAM;YAC7B,OAAO,gCAAgC,CAAC;QAC1C;YACE,wGAAwG;YACxG,OAAO,yCAAyC,CAAC;IACrD,CAAC;AACH,CAAC,CAAC,CAAC","sourcesContent":["import { selectiveUnion } from '@metamask/keyring-utils';\nimport { type Infer } from '@metamask/superstruct';\n\nimport {\n CreateAccountBip44DiscoverOptionsStruct,\n CreateAccountBip44DeriveIndexOptionsStruct,\n CreateAccountBip44DeriveIndexRangeOptionsStruct,\n CreateAccountBip44DerivePathOptionsStruct,\n} from './bip44';\nimport { CreateAccountCustomOptionsStruct } from './custom';\nimport { CreateAccountPrivateKeyOptionsStruct } from './private-key';\n\nexport * from './bip44';\nexport * from './custom';\nexport * from './private-key';\n\n/**\n * Enum representing the different ways an account can be created.\n */\nexport enum AccountCreationType {\n /**\n * Represents an account created using a BIP-44 derivation path.\n */\n Bip44DerivePath = 'bip44:derive-path',\n\n /**\n * Represents accounts created using a BIP-44 account index.\n *\n * More than one account can be created, for example, the keyring can create\n * multiple account types (e.g., P2PKH, P2TR, P2WPKH) for the same account\n * index.\n */\n Bip44DeriveIndex = 'bip44:derive-index',\n\n /**\n * Represents accounts created by deriving a range of BIP-44 account indices.\n *\n * More than one account can be created per index, for example, the keyring\n * can create multiple account types (e.g., P2PKH, P2TR, P2WPKH) for each\n * account index in the range.\n */\n Bip44DeriveIndexRange = 'bip44:derive-index-range',\n\n /**\n * Represents accounts created through BIP-44 account discovery.\n *\n * More than one account can be created, for example, the keyring can create\n * multiple account types (e.g., P2PKH, P2TR, P2WPKH) for the same account\n * index.\n */\n Bip44Discover = 'bip44:discover',\n\n /**\n * Represents an account imported from a private key.\n */\n PrivateKeyImport = 'private-key:import',\n\n /**\n * Represents an account created using a custom, keyring-specific method.\n *\n * This is used by keyrings that have non-standard account creation flows\n * and declare `custom.createAccounts: true` in their capabilities.\n */\n Custom = 'custom',\n}\n\n/**\n * Struct for {@link CreateAccountOptions}.\n */\nexport const CreateAccountOptionsStruct = selectiveUnion((value: any) => {\n const accountCreationType = value?.type as AccountCreationType;\n switch (accountCreationType) {\n case AccountCreationType.Bip44DerivePath:\n return CreateAccountBip44DerivePathOptionsStruct;\n case AccountCreationType.Bip44DeriveIndex:\n return CreateAccountBip44DeriveIndexOptionsStruct;\n case AccountCreationType.Bip44DeriveIndexRange:\n return CreateAccountBip44DeriveIndexRangeOptionsStruct;\n case AccountCreationType.Bip44Discover:\n return CreateAccountBip44DiscoverOptionsStruct;\n case AccountCreationType.PrivateKeyImport:\n return CreateAccountPrivateKeyOptionsStruct;\n case AccountCreationType.Custom:\n return CreateAccountCustomOptionsStruct;\n default:\n // Return first struct as fallback - validation will fail with proper error indicating the type mismatch\n return CreateAccountBip44DerivePathOptionsStruct;\n }\n});\n\n/**\n * Represents the available options for creating a new account.\n */\nexport type CreateAccountOptions = Infer<typeof CreateAccountOptionsStruct>;\n"]} | ||
| {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../../src/api/v2/create-account/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,gCAAgC;AAGzD,OAAO,EACL,uCAAuC,EACvC,0CAA0C,EAC1C,+CAA+C,EAC/C,yCAAyC,EAC1C,oBAAgB;AACjB,OAAO,EAAE,gCAAgC,EAAE,qBAAiB;AAC5D,OAAO,EAAE,oCAAoC,EAAE,0BAAsB;AAErE,4BAAwB;AACxB,6BAAyB;AACzB,kCAA8B;AAE9B;;GAEG;AACH,MAAM,CAAN,IAAY,mBA6CX;AA7CD,WAAY,mBAAmB;IAC7B;;OAEG;IACH,4DAAqC,CAAA;IAErC;;;;;;OAMG;IACH,8DAAuC,CAAA;IAEvC;;;;;;OAMG;IACH,yEAAkD,CAAA;IAElD;;;;;;OAMG;IACH,uDAAgC,CAAA;IAEhC;;OAEG;IACH,8DAAuC,CAAA;IAEvC;;;;;OAKG;IACH,wCAAiB,CAAA;AACnB,CAAC,EA7CW,mBAAmB,KAAnB,mBAAmB,QA6C9B;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,cAAc,CAAC,CAAC,KAAU,EAAE,EAAE;IACtE,MAAM,mBAAmB,GAAG,KAAK,EAAE,IAA2B,CAAC;IAC/D,QAAQ,mBAAmB,EAAE,CAAC;QAC5B,KAAK,mBAAmB,CAAC,eAAe;YACtC,OAAO,yCAAyC,CAAC;QACnD,KAAK,mBAAmB,CAAC,gBAAgB;YACvC,OAAO,0CAA0C,CAAC;QACpD,KAAK,mBAAmB,CAAC,qBAAqB;YAC5C,OAAO,+CAA+C,CAAC;QACzD,KAAK,mBAAmB,CAAC,aAAa;YACpC,OAAO,uCAAuC,CAAC;QACjD,KAAK,mBAAmB,CAAC,gBAAgB;YACvC,OAAO,oCAAoC,CAAC;QAC9C,KAAK,mBAAmB,CAAC,MAAM;YAC7B,OAAO,gCAAgC,CAAC;QAC1C;YACE,wGAAwG;YACxG,OAAO,yCAAyC,CAAC;IACrD,CAAC;AACH,CAAC,CAAC,CAAC;AAOH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,oCAAoC,CAKlD,OAAgB,EAChB,cAAoC;IAGpC,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;IACzB,MAAM,KAAK,GAA4C,cAAc,CAAC;IAEtE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,2CAA2C,IAAI,EAAE,CAAC,CAAC;IACrE,CAAC;AACH,CAAC","sourcesContent":["import { selectiveUnion } from '@metamask/keyring-utils';\nimport { type Infer } from '@metamask/superstruct';\n\nimport {\n CreateAccountBip44DiscoverOptionsStruct,\n CreateAccountBip44DeriveIndexOptionsStruct,\n CreateAccountBip44DeriveIndexRangeOptionsStruct,\n CreateAccountBip44DerivePathOptionsStruct,\n} from './bip44';\nimport { CreateAccountCustomOptionsStruct } from './custom';\nimport { CreateAccountPrivateKeyOptionsStruct } from './private-key';\n\nexport * from './bip44';\nexport * from './custom';\nexport * from './private-key';\n\n/**\n * Enum representing the different ways an account can be created.\n */\nexport enum AccountCreationType {\n /**\n * Represents an account created using a BIP-44 derivation path.\n */\n Bip44DerivePath = 'bip44:derive-path',\n\n /**\n * Represents accounts created using a BIP-44 account index.\n *\n * More than one account can be created, for example, the keyring can create\n * multiple account types (e.g., P2PKH, P2TR, P2WPKH) for the same account\n * index.\n */\n Bip44DeriveIndex = 'bip44:derive-index',\n\n /**\n * Represents accounts created by deriving a range of BIP-44 account indices.\n *\n * More than one account can be created per index, for example, the keyring\n * can create multiple account types (e.g., P2PKH, P2TR, P2WPKH) for each\n * account index in the range.\n */\n Bip44DeriveIndexRange = 'bip44:derive-index-range',\n\n /**\n * Represents accounts created through BIP-44 account discovery.\n *\n * More than one account can be created, for example, the keyring can create\n * multiple account types (e.g., P2PKH, P2TR, P2WPKH) for the same account\n * index.\n */\n Bip44Discover = 'bip44:discover',\n\n /**\n * Represents an account imported from a private key.\n */\n PrivateKeyImport = 'private-key:import',\n\n /**\n * Represents an account created using a custom, keyring-specific method.\n *\n * This is used by keyrings that have non-standard account creation flows\n * and declare `custom.createAccounts: true` in their capabilities.\n */\n Custom = 'custom',\n}\n\n/**\n * Struct for {@link CreateAccountOptions}.\n */\nexport const CreateAccountOptionsStruct = selectiveUnion((value: any) => {\n const accountCreationType = value?.type as AccountCreationType;\n switch (accountCreationType) {\n case AccountCreationType.Bip44DerivePath:\n return CreateAccountBip44DerivePathOptionsStruct;\n case AccountCreationType.Bip44DeriveIndex:\n return CreateAccountBip44DeriveIndexOptionsStruct;\n case AccountCreationType.Bip44DeriveIndexRange:\n return CreateAccountBip44DeriveIndexRangeOptionsStruct;\n case AccountCreationType.Bip44Discover:\n return CreateAccountBip44DiscoverOptionsStruct;\n case AccountCreationType.PrivateKeyImport:\n return CreateAccountPrivateKeyOptionsStruct;\n case AccountCreationType.Custom:\n return CreateAccountCustomOptionsStruct;\n default:\n // Return first struct as fallback - validation will fail with proper error indicating the type mismatch\n return CreateAccountBip44DerivePathOptionsStruct;\n }\n});\n\n/**\n * Represents the available options for creating a new account.\n */\nexport type CreateAccountOptions = Infer<typeof CreateAccountOptionsStruct>;\n\n/**\n * Asserts that a given create account option type is supported by the keyring.\n *\n * @example\n * ```ts\n * createAccounts(options: CreateAccountOptions) {\n * assertCreateAccountOptionIsSupported(options, [\n * ${AccountCreationType.Bip44DeriveIndex},\n * ${AccountCreationType.Bip44DeriveIndexRange},\n * ] as const);\n *\n * // At this point, TypeScript knows that options.type is either Bip44DeriveIndex or Bip44DeriveIndexRange.\n * if (options.type === AccountCreationType.Bip44DeriveIndex) {\n * ... // Handle Bip44DeriveIndex case.\n * } else {\n * ... // Handle Bip44DeriveIndexRange case.\n * }\n * ...\n * return accounts;\n * }\n * ```\n *\n * @param options - The create account option object to check.\n * @param supportedTypes - The list of supported create account option types for this keyring.\n * @throws Will throw an error if the provided options are not supported.\n */\nexport function assertCreateAccountOptionIsSupported<\n Options extends CreateAccountOptions,\n // We use template literal types to enforce string-literal over strict enum values.\n Type extends `${CreateAccountOptions['type']}`,\n>(\n options: Options,\n supportedTypes: readonly `${Type}`[],\n // Use intersection to avoid widening `type` beyond `Options['type']`.\n): asserts options is Options & { type: `${Type}` & `${Options['type']}` } {\n const { type } = options;\n const types: readonly CreateAccountOptions['type'][] = supportedTypes;\n\n if (!types.includes(type)) {\n throw new Error(`Unsupported create account option type: ${type}`);\n }\n}\n"]} |
@@ -9,3 +9,3 @@ import { type Infer } from "@metamask/superstruct"; | ||
| nonce: string; | ||
| sender: `0x${string}`; | ||
| sender: string; | ||
| initCode: string; | ||
@@ -21,3 +21,3 @@ callData: string; | ||
| }, { | ||
| sender: import("@metamask/superstruct").Struct<`0x${string}`, null>; | ||
| sender: import("@metamask/superstruct").Struct<string, null>; | ||
| nonce: import("@metamask/superstruct").Struct<string, null>; | ||
@@ -42,3 +42,3 @@ initCode: import("@metamask/superstruct").Struct<string, null>; | ||
| data: string; | ||
| to: `0x${string}`; | ||
| to: string; | ||
| }, { | ||
@@ -48,3 +48,3 @@ /** | ||
| */ | ||
| to: import("@metamask/superstruct").Struct<`0x${string}`, null>; | ||
| to: import("@metamask/superstruct").Struct<string, null>; | ||
| /** | ||
@@ -51,0 +51,0 @@ * Amount of wei to transfer to the recipient. |
@@ -9,3 +9,3 @@ import { type Infer } from "@metamask/superstruct"; | ||
| nonce: string; | ||
| sender: `0x${string}`; | ||
| sender: string; | ||
| initCode: string; | ||
@@ -21,3 +21,3 @@ callData: string; | ||
| }, { | ||
| sender: import("@metamask/superstruct").Struct<`0x${string}`, null>; | ||
| sender: import("@metamask/superstruct").Struct<string, null>; | ||
| nonce: import("@metamask/superstruct").Struct<string, null>; | ||
@@ -42,3 +42,3 @@ initCode: import("@metamask/superstruct").Struct<string, null>; | ||
| data: string; | ||
| to: `0x${string}`; | ||
| to: string; | ||
| }, { | ||
@@ -48,3 +48,3 @@ /** | ||
| */ | ||
| to: import("@metamask/superstruct").Struct<`0x${string}`, null>; | ||
| to: import("@metamask/superstruct").Struct<string, null>; | ||
| /** | ||
@@ -51,0 +51,0 @@ * Amount of wei to transfer to the recipient. |
@@ -81,3 +81,3 @@ "use strict"; | ||
| (0, superstruct_1.number)(), // chainId | ||
| types_1.EthAddressStruct, // address (contract to delegate to) | ||
| types_1.EthAddressStrictStruct, // address (contract to delegate to) | ||
| (0, superstruct_1.number)(), // nonce | ||
@@ -84,0 +84,0 @@ ]); |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"params.cjs","sourceRoot":"","sources":["../../../src/eth/rpc/params.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,2DAAiD;AAEjD,uDAa+B;AAE/B,wCAA4D;AAE5D;;;;;;GAMG;AACU,QAAA,wBAAwB,GAAG,IAAA,kBAAI,EAAC;IAC3C,EAAE,EAAE,IAAA,sBAAQ,EAAC,IAAA,sBAAQ,EAAC,wBAAgB,CAAC,CAAC;IACxC,IAAI,EAAE,IAAA,sBAAQ,EAAC,wBAAgB,CAAC;IAChC,KAAK,EAAE,IAAA,sBAAQ,EAAC,IAAA,mBAAK,EAAC,CAAC,IAAA,oBAAM,GAAE,EAAE,IAAA,oBAAM,GAAE,CAAC,CAAC,CAAC;IAC5C,KAAK,EAAE,IAAA,sBAAQ,EAAC,IAAA,mBAAK,EAAC,CAAC,IAAA,oBAAM,GAAE,EAAE,IAAA,oBAAM,GAAE,CAAC,CAAC,CAAC;IAC5C,IAAI,EAAE,IAAA,sBAAQ,EAAC,sBAAc,CAAC;IAC9B,GAAG,EAAE,IAAA,sBAAQ,EAAC,IAAA,mBA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AC,CAAC;AAMhF;;GAEG;AACU,QAAA,mBAAmB,GAAG,IAAA,mBAAK,EAAC;IACvC,wBAAgB,EAAE,UAAU;IAC5B,sBAAc,EAAE,kCAAkC;CACnD,CAAC,CAAC;AAIH;;GAEG;AACU,QAAA,2BAA2B,GAAG,IAAA,mBAAK,EAAC;IAC/C,IAAA,mBAAK,EAAC,CAAC,sBAAc,CAAC,CAAC,EAAE,SAAS;IAClC,IAAA,mBAAK,EAAC,CAAC,sBAAc,EAAE,wBAAgB,CAAC,CAAC,EAAE,kBAAkB;CAC9D,CAAC,CAAC;AAIH;;GAEG;AACU,QAAA,8BAA8B,GAAG,IAAA,mBAAK,EAAC;IAClD,wBAAgB,EAAE,UAAU;IAC5B,4BAAoB,EAAE,mBAAmB;CAC1C,CAAC,CAAC;AAMH;;GAEG;AACU,QAAA,4BAA4B,GAAG,IAAA,mBAAK,EAAC;IAChD,wBAAgB,EAAE,UAAU;IAC5B,6BAAqB,EAAE,oBAAoB;CAC5C,CAAC,CAAC;AAIH;;GAEG;AACU,QAAA,sBAAsB,GAAG,IAAA,mBAAK,EAAC,CAAC,8BAAsB,CAAC,CAAC,CAAC;AAItE;;GAEG;AACU,QAAA,+BAA+B,GAAG,IAAA,mBAAK,EAAC;IACnD,IAAA,oBAAM,GAAE,EAAE,aAAa;CACxB,CAAC,CAAC;AAMH;;;;;;;GAOG;AACU,QAAA,uCAAuC,GAAG,IAAA,mBAAK,EAAC;IAC3D,qCAA6B;CAC9B,CAAC,CAAC;AAMH;;GAEG;AACU,QAAA,qCAAqC,GAAG,IAAA,mBAAK,EAAC;IACzD,wBAAgB,EAAE,UAAU;IAC5B,IAAA,sBAAQ,EAAC,8CAAsC,CAAC,EAAE,UAAU;CAC7D,CAAC,CAAC","sourcesContent":["/**\n * Superstruct validation schemas for Ethereum JSON-RPC method parameters.\n *\n * These structs provide runtime validation for the parameters passed to various\n * Ethereum RPC methods. They can be used by keyring implementations to validate\n * incoming requests before processing.\n */\n\nimport { object } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport {\n any,\n array,\n literal,\n nullable,\n number,\n optional,\n record,\n string,\n tuple,\n type,\n union,\n unknown,\n} from '@metamask/superstruct';\n\nimport { EthAddressStruct, EthBytesStruct } from '../types';\n\n/**\n * A struct for validating Ethereum transaction data.\n *\n * This uses `type()` instead of `object()` to allow extra properties,\n * since transaction formats can vary and include additional fields.\n * The actual transaction validation is performed by the transaction library.\n */\nexport const EthTransactionDataStruct = type({\n to: optional(nullable(EthAddressStruct)),\n from: optional(EthAddressStruct),\n nonce: optional(union([string(), number()])),\n value: optional(union([string(), number()])),\n data: optional(EthBytesStruct),\n gas: optional(union([string(), number()])),\n gasLimit: optional(union([string(), number()])),\n gasPrice: optional(union([string(), number()])),\n maxFeePerGas: optional(union([string(), number()])),\n maxPriorityFeePerGas: optional(union([string(), number()])),\n accessList: optional(\n array(\n type({\n address: EthAddressStruct,\n storageKeys: array(string()),\n }),\n ),\n ),\n type: optional(union([string(), number()])),\n chainId: optional(union([string(), number()])),\n});\n\nexport type EthTransactionData = Infer<typeof EthTransactionDataStruct>;\n\n/**\n * A struct for TypedDataV1 format (legacy typed data).\n * This is an array of { type, name, value } objects.\n */\nexport const EthTypedDataV1Struct = array(\n object({\n type: string(),\n name: string(),\n value: unknown(),\n }),\n);\n\nexport type EthTypedDataV1 = Infer<typeof EthTypedDataV1Struct>;\n\n/**\n * A struct for TypedData types definition.\n * Maps type names to arrays of { name, type } definitions.\n */\nexport const EthTypedDataTypesStruct = record(\n string(),\n array(\n object({\n name: string(),\n type: string(),\n }),\n ),\n);\n\nexport type EthTypedDataTypes = Infer<typeof EthTypedDataTypesStruct>;\n\n/**\n * A struct for TypedMessage format (EIP-712 V3/V4).\n * Contains types, domain, primaryType, and message.\n */\nexport const EthTypedMessageStruct = object({\n types: EthTypedDataTypesStruct,\n primaryType: string(),\n domain: record(string(), any()),\n message: record(string(), any()),\n});\n\nexport type EthTypedMessage = Infer<typeof EthTypedMessageStruct>;\n\n/**\n * A struct for EIP-1024 encrypted data format (x25519-xsalsa20-poly1305).\n */\nexport const EthEncryptedDataStruct = object({\n version: literal('x25519-xsalsa20-poly1305'),\n nonce: string(),\n ephemPublicKey: string(),\n ciphertext: string(),\n});\n\nexport type EthEncryptedData = Infer<typeof EthEncryptedDataStruct>;\n\n/**\n * A struct for EIP-7702 authorization tuple.\n * Format: [chainId, address, nonce]\n */\nexport const EthEip7702AuthorizationStruct = tuple([\n number(), // chainId\n EthAddressStruct, // address (contract to delegate to)\n number(), // nonce\n]);\n\nexport type EthEip7702Authorization = Infer<\n typeof EthEip7702AuthorizationStruct\n>;\n\n/**\n * A struct for getEncryptionPublicKey options.\n */\nexport const EthGetEncryptionPublicKeyOptionsStruct = record(\n string(),\n unknown(),\n);\n\n// ============================================================================\n// RPC Method Parameter Structs\n// ============================================================================\n\n/**\n * Parameters for `eth_signTransaction`.\n */\nexport const EthSignTransactionParamsStruct = tuple([EthTransactionDataStruct]);\n\nexport type EthSignTransactionParams = Infer<\n typeof EthSignTransactionParamsStruct\n>;\n\n/**\n * Parameters for `eth_sign`.\n */\nexport const EthSignParamsStruct = tuple([\n EthAddressStruct, // address\n EthBytesStruct, // data (hex-encoded message hash)\n]);\n\nexport type EthSignParams = Infer<typeof EthSignParamsStruct>;\n\n/**\n * Parameters for `personal_sign`.\n */\nexport const EthPersonalSignParamsStruct = union([\n tuple([EthBytesStruct]), // [data]\n tuple([EthBytesStruct, EthAddressStruct]), // [data, address]\n]);\n\nexport type EthPersonalSignParams = Infer<typeof EthPersonalSignParamsStruct>;\n\n/**\n * Parameters for `eth_signTypedData_v1`.\n */\nexport const EthSignTypedDataV1ParamsStruct = tuple([\n EthAddressStruct, // address\n EthTypedDataV1Struct, // typed data array\n]);\n\nexport type EthSignTypedDataV1Params = Infer<\n typeof EthSignTypedDataV1ParamsStruct\n>;\n\n/**\n * Parameters for `eth_signTypedData_v3` and `eth_signTypedData_v4`.\n */\nexport const EthSignTypedDataParamsStruct = tuple([\n EthAddressStruct, // address\n EthTypedMessageStruct, // typed data object\n]);\n\nexport type EthSignTypedDataParams = Infer<typeof EthSignTypedDataParamsStruct>;\n\n/**\n * Parameters for `eth_decrypt`.\n */\nexport const EthDecryptParamsStruct = tuple([EthEncryptedDataStruct]);\n\nexport type EthDecryptParams = Infer<typeof EthDecryptParamsStruct>;\n\n/**\n * Parameters for `eth_getAppKeyAddress`.\n */\nexport const EthGetAppKeyAddressParamsStruct = tuple([\n string(), // origin URL\n]);\n\nexport type EthGetAppKeyAddressParams = Infer<\n typeof EthGetAppKeyAddressParamsStruct\n>;\n\n/**\n * Parameters for `eth_signEip7702Authorization`.\n *\n * @example\n * ```ts\n * const params = [[1, '0xContractAddress', 0]];\n * ```\n */\nexport const EthSignEip7702AuthorizationParamsStruct = tuple([\n EthEip7702AuthorizationStruct,\n]);\n\nexport type EthSignEip7702AuthorizationParams = Infer<\n typeof EthSignEip7702AuthorizationParamsStruct\n>;\n\n/**\n * Parameters for `eth_getEncryptionPublicKey`.\n */\nexport const EthGetEncryptionPublicKeyParamsStruct = tuple([\n EthAddressStruct, // address\n optional(EthGetEncryptionPublicKeyOptionsStruct), // options\n]);\n"]} | ||
| {"version":3,"file":"params.cjs","sourceRoot":"","sources":["../../../src/eth/rpc/params.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,2DAAiD;AAEjD,uDAa+B;AAE/B,wCAIkB;AAElB;;;;;;GAMG;AACU,QAAA,wBAAwB,GAAG,IAAA,kBAAI,EAAC;IAC3C,EAAE,EAAE,IAAA,sBAAQ,EAAC,IAAA,sBAAQ,EAAC,wBAAgB,CAAC,CAAC;IACxC,IAAI,EAAE,IAAA,sBAAQ,EAAC,wBAAgB,CAAC;IAChC,KAAK,EAAE,IAAA,sBAAQ,EAAC,IAAA,mBAAK,EAAC,CAAC,IAAA,oBAAM,GAAE,EAAE,IAAA,oBAAM,GAAE,CAAC,CAAC,CAAC;IAC5C,KAAK,EAAE,IAAA,s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,sBAAQ,EAAC,8CAAsC,CAAC,EAAE,UAAU;CAC7D,CAAC,CAAC","sourcesContent":["/**\n * Superstruct validation schemas for Ethereum JSON-RPC method parameters.\n *\n * These structs provide runtime validation for the parameters passed to various\n * Ethereum RPC methods. They can be used by keyring implementations to validate\n * incoming requests before processing.\n */\n\nimport { object } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport {\n any,\n array,\n literal,\n nullable,\n number,\n optional,\n record,\n string,\n tuple,\n type,\n union,\n unknown,\n} from '@metamask/superstruct';\n\nimport {\n EthAddressStrictStruct,\n EthAddressStruct,\n EthBytesStruct,\n} from '../types';\n\n/**\n * A struct for validating Ethereum transaction data.\n *\n * This uses `type()` instead of `object()` to allow extra properties,\n * since transaction formats can vary and include additional fields.\n * The actual transaction validation is performed by the transaction library.\n */\nexport const EthTransactionDataStruct = type({\n to: optional(nullable(EthAddressStruct)),\n from: optional(EthAddressStruct),\n nonce: optional(union([string(), number()])),\n value: optional(union([string(), number()])),\n data: optional(EthBytesStruct),\n gas: optional(union([string(), number()])),\n gasLimit: optional(union([string(), number()])),\n gasPrice: optional(union([string(), number()])),\n maxFeePerGas: optional(union([string(), number()])),\n maxPriorityFeePerGas: optional(union([string(), number()])),\n accessList: optional(\n array(\n type({\n address: EthAddressStruct,\n storageKeys: array(string()),\n }),\n ),\n ),\n type: optional(union([string(), number()])),\n chainId: optional(union([string(), number()])),\n});\n\nexport type EthTransactionData = Infer<typeof EthTransactionDataStruct>;\n\n/**\n * A struct for TypedDataV1 format (legacy typed data).\n * This is an array of { type, name, value } objects.\n */\nexport const EthTypedDataV1Struct = array(\n object({\n type: string(),\n name: string(),\n value: unknown(),\n }),\n);\n\nexport type EthTypedDataV1 = Infer<typeof EthTypedDataV1Struct>;\n\n/**\n * A struct for TypedData types definition.\n * Maps type names to arrays of { name, type } definitions.\n */\nexport const EthTypedDataTypesStruct = record(\n string(),\n array(\n object({\n name: string(),\n type: string(),\n }),\n ),\n);\n\nexport type EthTypedDataTypes = Infer<typeof EthTypedDataTypesStruct>;\n\n/**\n * A struct for TypedMessage format (EIP-712 V3/V4).\n * Contains types, domain, primaryType, and message.\n */\nexport const EthTypedMessageStruct = object({\n types: EthTypedDataTypesStruct,\n primaryType: string(),\n domain: record(string(), any()),\n message: record(string(), any()),\n});\n\nexport type EthTypedMessage = Infer<typeof EthTypedMessageStruct>;\n\n/**\n * A struct for EIP-1024 encrypted data format (x25519-xsalsa20-poly1305).\n */\nexport const EthEncryptedDataStruct = object({\n version: literal('x25519-xsalsa20-poly1305'),\n nonce: string(),\n ephemPublicKey: string(),\n ciphertext: string(),\n});\n\nexport type EthEncryptedData = Infer<typeof EthEncryptedDataStruct>;\n\n/**\n * A struct for EIP-7702 authorization tuple.\n * Format: [chainId, address, nonce]\n */\nexport const EthEip7702AuthorizationStruct = tuple([\n number(), // chainId\n EthAddressStrictStruct, // address (contract to delegate to)\n number(), // nonce\n]);\n\nexport type EthEip7702Authorization = Infer<\n typeof EthEip7702AuthorizationStruct\n>;\n\n/**\n * A struct for getEncryptionPublicKey options.\n */\nexport const EthGetEncryptionPublicKeyOptionsStruct = record(\n string(),\n unknown(),\n);\n\n// ============================================================================\n// RPC Method Parameter Structs\n// ============================================================================\n\n/**\n * Parameters for `eth_signTransaction`.\n */\nexport const EthSignTransactionParamsStruct = tuple([EthTransactionDataStruct]);\n\nexport type EthSignTransactionParams = Infer<\n typeof EthSignTransactionParamsStruct\n>;\n\n/**\n * Parameters for `eth_sign`.\n */\nexport const EthSignParamsStruct = tuple([\n EthAddressStruct, // address\n EthBytesStruct, // data (hex-encoded message hash)\n]);\n\nexport type EthSignParams = Infer<typeof EthSignParamsStruct>;\n\n/**\n * Parameters for `personal_sign`.\n */\nexport const EthPersonalSignParamsStruct = union([\n tuple([EthBytesStruct]), // [data]\n tuple([EthBytesStruct, EthAddressStruct]), // [data, address]\n]);\n\nexport type EthPersonalSignParams = Infer<typeof EthPersonalSignParamsStruct>;\n\n/**\n * Parameters for `eth_signTypedData_v1`.\n */\nexport const EthSignTypedDataV1ParamsStruct = tuple([\n EthAddressStruct, // address\n EthTypedDataV1Struct, // typed data array\n]);\n\nexport type EthSignTypedDataV1Params = Infer<\n typeof EthSignTypedDataV1ParamsStruct\n>;\n\n/**\n * Parameters for `eth_signTypedData_v3` and `eth_signTypedData_v4`.\n */\nexport const EthSignTypedDataParamsStruct = tuple([\n EthAddressStruct, // address\n EthTypedMessageStruct, // typed data object\n]);\n\nexport type EthSignTypedDataParams = Infer<typeof EthSignTypedDataParamsStruct>;\n\n/**\n * Parameters for `eth_decrypt`.\n */\nexport const EthDecryptParamsStruct = tuple([EthEncryptedDataStruct]);\n\nexport type EthDecryptParams = Infer<typeof EthDecryptParamsStruct>;\n\n/**\n * Parameters for `eth_getAppKeyAddress`.\n */\nexport const EthGetAppKeyAddressParamsStruct = tuple([\n string(), // origin URL\n]);\n\nexport type EthGetAppKeyAddressParams = Infer<\n typeof EthGetAppKeyAddressParamsStruct\n>;\n\n/**\n * Parameters for `eth_signEip7702Authorization`.\n *\n * @example\n * ```ts\n * const params = [[1, '0xContractAddress', 0]];\n * ```\n */\nexport const EthSignEip7702AuthorizationParamsStruct = tuple([\n EthEip7702AuthorizationStruct,\n]);\n\nexport type EthSignEip7702AuthorizationParams = Infer<\n typeof EthSignEip7702AuthorizationParamsStruct\n>;\n\n/**\n * Parameters for `eth_getEncryptionPublicKey`.\n */\nexport const EthGetEncryptionPublicKeyParamsStruct = tuple([\n EthAddressStruct, // address\n optional(EthGetEncryptionPublicKeyOptionsStruct), // options\n]);\n"]} |
@@ -20,10 +20,10 @@ /** | ||
| data?: string | undefined; | ||
| from?: `0x${string}` | undefined; | ||
| from?: string | undefined; | ||
| chainId?: string | number | undefined; | ||
| accessList?: { | ||
| address: `0x${string}`; | ||
| address: string; | ||
| storageKeys: string[]; | ||
| }[] | undefined; | ||
| nonce?: string | number | undefined; | ||
| to?: `0x${string}` | null | undefined; | ||
| to?: string | null | undefined; | ||
| maxFeePerGas?: string | number | undefined; | ||
@@ -35,4 +35,4 @@ maxPriorityFeePerGas?: string | number | undefined; | ||
| }, { | ||
| to: import("@metamask/superstruct").Struct<`0x${string}` | null | undefined, null>; | ||
| from: import("@metamask/superstruct").Struct<`0x${string}` | undefined, null>; | ||
| to: import("@metamask/superstruct").Struct<string | null | undefined, null>; | ||
| from: import("@metamask/superstruct").Struct<string | undefined, null>; | ||
| nonce: import("@metamask/superstruct").Struct<string | number | undefined, null>; | ||
@@ -47,9 +47,9 @@ value: import("@metamask/superstruct").Struct<string | number | undefined, null>; | ||
| accessList: import("@metamask/superstruct").Struct<{ | ||
| address: `0x${string}`; | ||
| address: string; | ||
| storageKeys: string[]; | ||
| }[] | undefined, import("@metamask/superstruct").Struct<{ | ||
| address: `0x${string}`; | ||
| address: string; | ||
| storageKeys: string[]; | ||
| }, { | ||
| address: import("@metamask/superstruct").Struct<`0x${string}`, null>; | ||
| address: import("@metamask/superstruct").Struct<string, null>; | ||
| storageKeys: import("@metamask/superstruct").Struct<string[], import("@metamask/superstruct").Struct<string, null>>; | ||
@@ -142,10 +142,10 @@ }>>; | ||
| data?: string | undefined; | ||
| from?: `0x${string}` | undefined; | ||
| from?: string | undefined; | ||
| chainId?: string | number | undefined; | ||
| accessList?: { | ||
| address: `0x${string}`; | ||
| address: string; | ||
| storageKeys: string[]; | ||
| }[] | undefined; | ||
| nonce?: string | number | undefined; | ||
| to?: `0x${string}` | null | undefined; | ||
| to?: string | null | undefined; | ||
| maxFeePerGas?: string | number | undefined; | ||
@@ -161,3 +161,3 @@ maxPriorityFeePerGas?: string | number | undefined; | ||
| */ | ||
| export declare const EthSignParamsStruct: import("@metamask/superstruct").Struct<[`0x${string}`, string], null>; | ||
| export declare const EthSignParamsStruct: import("@metamask/superstruct").Struct<[string, string], null>; | ||
| export type EthSignParams = Infer<typeof EthSignParamsStruct>; | ||
@@ -167,3 +167,3 @@ /** | ||
| */ | ||
| export declare const EthPersonalSignParamsStruct: import("@metamask/superstruct").Struct<[string] | [string, `0x${string}`], null>; | ||
| export declare const EthPersonalSignParamsStruct: import("@metamask/superstruct").Struct<[string, string] | [string], null>; | ||
| export type EthPersonalSignParams = Infer<typeof EthPersonalSignParamsStruct>; | ||
@@ -173,3 +173,3 @@ /** | ||
| */ | ||
| export declare const EthSignTypedDataV1ParamsStruct: import("@metamask/superstruct").Struct<[`0x${string}`, { | ||
| export declare const EthSignTypedDataV1ParamsStruct: import("@metamask/superstruct").Struct<[string, { | ||
| name: string; | ||
@@ -183,3 +183,3 @@ value: unknown; | ||
| */ | ||
| export declare const EthSignTypedDataParamsStruct: import("@metamask/superstruct").Struct<[`0x${string}`, { | ||
| export declare const EthSignTypedDataParamsStruct: import("@metamask/superstruct").Struct<[string, { | ||
| message: Record<string, any>; | ||
@@ -222,3 +222,3 @@ domain: Record<string, any>; | ||
| */ | ||
| export declare const EthGetEncryptionPublicKeyParamsStruct: import("@metamask/superstruct").Struct<[`0x${string}`, Record<string, unknown> | undefined], null>; | ||
| export declare const EthGetEncryptionPublicKeyParamsStruct: import("@metamask/superstruct").Struct<[string, Record<string, unknown> | undefined], null>; | ||
| //# sourceMappingURL=params.d.cts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"params.d.cts","sourceRoot":"","sources":["../../../src/eth/rpc/params.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAkBnD;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqBnC,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAExE;;;GAGG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;GAMhC,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAEhE;;;GAGG;AACH,eAAO,MAAM,uB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AC/C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qCAAqC,6FAGhD,CAAC"} |
@@ -20,10 +20,10 @@ /** | ||
| data?: string | undefined; | ||
| from?: `0x${string}` | undefined; | ||
| from?: string | undefined; | ||
| chainId?: string | number | undefined; | ||
| accessList?: { | ||
| address: `0x${string}`; | ||
| address: string; | ||
| storageKeys: string[]; | ||
| }[] | undefined; | ||
| nonce?: string | number | undefined; | ||
| to?: `0x${string}` | null | undefined; | ||
| to?: string | null | undefined; | ||
| maxFeePerGas?: string | number | undefined; | ||
@@ -35,4 +35,4 @@ maxPriorityFeePerGas?: string | number | undefined; | ||
| }, { | ||
| to: import("@metamask/superstruct").Struct<`0x${string}` | null | undefined, null>; | ||
| from: import("@metamask/superstruct").Struct<`0x${string}` | undefined, null>; | ||
| to: import("@metamask/superstruct").Struct<string | null | undefined, null>; | ||
| from: import("@metamask/superstruct").Struct<string | undefined, null>; | ||
| nonce: import("@metamask/superstruct").Struct<string | number | undefined, null>; | ||
@@ -47,9 +47,9 @@ value: import("@metamask/superstruct").Struct<string | number | undefined, null>; | ||
| accessList: import("@metamask/superstruct").Struct<{ | ||
| address: `0x${string}`; | ||
| address: string; | ||
| storageKeys: string[]; | ||
| }[] | undefined, import("@metamask/superstruct").Struct<{ | ||
| address: `0x${string}`; | ||
| address: string; | ||
| storageKeys: string[]; | ||
| }, { | ||
| address: import("@metamask/superstruct").Struct<`0x${string}`, null>; | ||
| address: import("@metamask/superstruct").Struct<string, null>; | ||
| storageKeys: import("@metamask/superstruct").Struct<string[], import("@metamask/superstruct").Struct<string, null>>; | ||
@@ -142,10 +142,10 @@ }>>; | ||
| data?: string | undefined; | ||
| from?: `0x${string}` | undefined; | ||
| from?: string | undefined; | ||
| chainId?: string | number | undefined; | ||
| accessList?: { | ||
| address: `0x${string}`; | ||
| address: string; | ||
| storageKeys: string[]; | ||
| }[] | undefined; | ||
| nonce?: string | number | undefined; | ||
| to?: `0x${string}` | null | undefined; | ||
| to?: string | null | undefined; | ||
| maxFeePerGas?: string | number | undefined; | ||
@@ -161,3 +161,3 @@ maxPriorityFeePerGas?: string | number | undefined; | ||
| */ | ||
| export declare const EthSignParamsStruct: import("@metamask/superstruct").Struct<[`0x${string}`, string], null>; | ||
| export declare const EthSignParamsStruct: import("@metamask/superstruct").Struct<[string, string], null>; | ||
| export type EthSignParams = Infer<typeof EthSignParamsStruct>; | ||
@@ -167,3 +167,3 @@ /** | ||
| */ | ||
| export declare const EthPersonalSignParamsStruct: import("@metamask/superstruct").Struct<[string] | [string, `0x${string}`], null>; | ||
| export declare const EthPersonalSignParamsStruct: import("@metamask/superstruct").Struct<[string, string] | [string], null>; | ||
| export type EthPersonalSignParams = Infer<typeof EthPersonalSignParamsStruct>; | ||
@@ -173,3 +173,3 @@ /** | ||
| */ | ||
| export declare const EthSignTypedDataV1ParamsStruct: import("@metamask/superstruct").Struct<[`0x${string}`, { | ||
| export declare const EthSignTypedDataV1ParamsStruct: import("@metamask/superstruct").Struct<[string, { | ||
| name: string; | ||
@@ -183,3 +183,3 @@ value: unknown; | ||
| */ | ||
| export declare const EthSignTypedDataParamsStruct: import("@metamask/superstruct").Struct<[`0x${string}`, { | ||
| export declare const EthSignTypedDataParamsStruct: import("@metamask/superstruct").Struct<[string, { | ||
| message: Record<string, any>; | ||
@@ -222,3 +222,3 @@ domain: Record<string, any>; | ||
| */ | ||
| export declare const EthGetEncryptionPublicKeyParamsStruct: import("@metamask/superstruct").Struct<[`0x${string}`, Record<string, unknown> | undefined], null>; | ||
| export declare const EthGetEncryptionPublicKeyParamsStruct: import("@metamask/superstruct").Struct<[string, Record<string, unknown> | undefined], null>; | ||
| //# sourceMappingURL=params.d.mts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"params.d.mts","sourceRoot":"","sources":["../../../src/eth/rpc/params.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAkBnD;;;;;;GAMG;AACH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,CAAC;AAEtE,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEpE;;GAEG;AACH,eAAO,MAAM,+BAA+B,wDAE1C,CAAC;AAEH,MAAM,MAAM,yBAAyB,GAAG,KAAK,CAC3C,OAAO,+BAA+B,CACvC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,uCAAuC,iFAElD,CAAC;AAEH,MAAM,MAAM,iCAAiC,GAAG,KAAK,CACnD,OAAO,uCAAuC,CAC/C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qCAAqC,6FAGhD,CAAC"} |
@@ -10,3 +10,3 @@ /** | ||
| import { any, array, literal, nullable, number, optional, record, string, tuple, type, union, unknown } from "@metamask/superstruct"; | ||
| import { EthAddressStruct, EthBytesStruct } from "../types.mjs"; | ||
| import { EthAddressStrictStruct, EthAddressStruct, EthBytesStruct } from "../types.mjs"; | ||
| /** | ||
@@ -79,3 +79,3 @@ * A struct for validating Ethereum transaction data. | ||
| number(), // chainId | ||
| EthAddressStruct, // address (contract to delegate to) | ||
| EthAddressStrictStruct, // address (contract to delegate to) | ||
| number(), // nonce | ||
@@ -82,0 +82,0 @@ ]); |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"params.mjs","sourceRoot":"","sources":["../../../src/eth/rpc/params.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,MAAM,EAAE,gCAAgC;AAEjD,OAAO,EACL,GAAG,EACH,KAAK,EACL,OAAO,EACP,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,MAAM,EACN,MAAM,EACN,KAAK,EACL,IAAI,EACJ,KAAK,EACL,OAAO,EACR,8BAA8B;AAE/B,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,qBAAiB;AAE5D;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,IAAI,CAAC;IAC3C,EAAE,EAAE,QAAQ,CAAC,QAAQ,CAAC,g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;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAC;IACvC,gBAAgB,EAAE,UAAU;IAC5B,cAAc,EAAE,kCAAkC;CACnD,CAAC,CAAC;AAIH;;GAEG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,KAAK,CAAC;IAC/C,KAAK,CAAC,CAAC,cAAc,CAAC,CAAC,EAAE,SAAS;IAClC,KAAK,CAAC,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC,EAAE,kBAAkB;CAC9D,CAAC,CAAC;AAIH;;GAEG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,KAAK,CAAC;IAClD,gBAAgB,EAAE,UAAU;IAC5B,oBAAoB,EAAE,mBAAmB;CAC1C,CAAC,CAAC;AAMH;;GAEG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,KAAK,CAAC;IAChD,gBAAgB,EAAE,UAAU;IAC5B,qBAAqB,EAAE,oBAAoB;CAC5C,CAAC,CAAC;AAIH;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC;AAItE;;GAEG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,KAAK,CAAC;IACnD,MAAM,EAAE,EAAE,aAAa;CACxB,CAAC,CAAC;AAMH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,uCAAuC,GAAG,KAAK,CAAC;IAC3D,6BAA6B;CAC9B,CAAC,CAAC;AAMH;;GAEG;AACH,MAAM,CAAC,MAAM,qCAAqC,GAAG,KAAK,CAAC;IACzD,gBAAgB,EAAE,UAAU;IAC5B,QAAQ,CAAC,sCAAsC,CAAC,EAAE,UAAU;CAC7D,CAAC,CAAC","sourcesContent":["/**\n * Superstruct validation schemas for Ethereum JSON-RPC method parameters.\n *\n * These structs provide runtime validation for the parameters passed to various\n * Ethereum RPC methods. They can be used by keyring implementations to validate\n * incoming requests before processing.\n */\n\nimport { object } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport {\n any,\n array,\n literal,\n nullable,\n number,\n optional,\n record,\n string,\n tuple,\n type,\n union,\n unknown,\n} from '@metamask/superstruct';\n\nimport { EthAddressStruct, EthBytesStruct } from '../types';\n\n/**\n * A struct for validating Ethereum transaction data.\n *\n * This uses `type()` instead of `object()` to allow extra properties,\n * since transaction formats can vary and include additional fields.\n * The actual transaction validation is performed by the transaction library.\n */\nexport const EthTransactionDataStruct = type({\n to: optional(nullable(EthAddressStruct)),\n from: optional(EthAddressStruct),\n nonce: optional(union([string(), number()])),\n value: optional(union([string(), number()])),\n data: optional(EthBytesStruct),\n gas: optional(union([string(), number()])),\n gasLimit: optional(union([string(), number()])),\n gasPrice: optional(union([string(), number()])),\n maxFeePerGas: optional(union([string(), number()])),\n maxPriorityFeePerGas: optional(union([string(), number()])),\n accessList: optional(\n array(\n type({\n address: EthAddressStruct,\n storageKeys: array(string()),\n }),\n ),\n ),\n type: optional(union([string(), number()])),\n chainId: optional(union([string(), number()])),\n});\n\nexport type EthTransactionData = Infer<typeof EthTransactionDataStruct>;\n\n/**\n * A struct for TypedDataV1 format (legacy typed data).\n * This is an array of { type, name, value } objects.\n */\nexport const EthTypedDataV1Struct = array(\n object({\n type: string(),\n name: string(),\n value: unknown(),\n }),\n);\n\nexport type EthTypedDataV1 = Infer<typeof EthTypedDataV1Struct>;\n\n/**\n * A struct for TypedData types definition.\n * Maps type names to arrays of { name, type } definitions.\n */\nexport const EthTypedDataTypesStruct = record(\n string(),\n array(\n object({\n name: string(),\n type: string(),\n }),\n ),\n);\n\nexport type EthTypedDataTypes = Infer<typeof EthTypedDataTypesStruct>;\n\n/**\n * A struct for TypedMessage format (EIP-712 V3/V4).\n * Contains types, domain, primaryType, and message.\n */\nexport const EthTypedMessageStruct = object({\n types: EthTypedDataTypesStruct,\n primaryType: string(),\n domain: record(string(), any()),\n message: record(string(), any()),\n});\n\nexport type EthTypedMessage = Infer<typeof EthTypedMessageStruct>;\n\n/**\n * A struct for EIP-1024 encrypted data format (x25519-xsalsa20-poly1305).\n */\nexport const EthEncryptedDataStruct = object({\n version: literal('x25519-xsalsa20-poly1305'),\n nonce: string(),\n ephemPublicKey: string(),\n ciphertext: string(),\n});\n\nexport type EthEncryptedData = Infer<typeof EthEncryptedDataStruct>;\n\n/**\n * A struct for EIP-7702 authorization tuple.\n * Format: [chainId, address, nonce]\n */\nexport const EthEip7702AuthorizationStruct = tuple([\n number(), // chainId\n EthAddressStruct, // address (contract to delegate to)\n number(), // nonce\n]);\n\nexport type EthEip7702Authorization = Infer<\n typeof EthEip7702AuthorizationStruct\n>;\n\n/**\n * A struct for getEncryptionPublicKey options.\n */\nexport const EthGetEncryptionPublicKeyOptionsStruct = record(\n string(),\n unknown(),\n);\n\n// ============================================================================\n// RPC Method Parameter Structs\n// ============================================================================\n\n/**\n * Parameters for `eth_signTransaction`.\n */\nexport const EthSignTransactionParamsStruct = tuple([EthTransactionDataStruct]);\n\nexport type EthSignTransactionParams = Infer<\n typeof EthSignTransactionParamsStruct\n>;\n\n/**\n * Parameters for `eth_sign`.\n */\nexport const EthSignParamsStruct = tuple([\n EthAddressStruct, // address\n EthBytesStruct, // data (hex-encoded message hash)\n]);\n\nexport type EthSignParams = Infer<typeof EthSignParamsStruct>;\n\n/**\n * Parameters for `personal_sign`.\n */\nexport const EthPersonalSignParamsStruct = union([\n tuple([EthBytesStruct]), // [data]\n tuple([EthBytesStruct, EthAddressStruct]), // [data, address]\n]);\n\nexport type EthPersonalSignParams = Infer<typeof EthPersonalSignParamsStruct>;\n\n/**\n * Parameters for `eth_signTypedData_v1`.\n */\nexport const EthSignTypedDataV1ParamsStruct = tuple([\n EthAddressStruct, // address\n EthTypedDataV1Struct, // typed data array\n]);\n\nexport type EthSignTypedDataV1Params = Infer<\n typeof EthSignTypedDataV1ParamsStruct\n>;\n\n/**\n * Parameters for `eth_signTypedData_v3` and `eth_signTypedData_v4`.\n */\nexport const EthSignTypedDataParamsStruct = tuple([\n EthAddressStruct, // address\n EthTypedMessageStruct, // typed data object\n]);\n\nexport type EthSignTypedDataParams = Infer<typeof EthSignTypedDataParamsStruct>;\n\n/**\n * Parameters for `eth_decrypt`.\n */\nexport const EthDecryptParamsStruct = tuple([EthEncryptedDataStruct]);\n\nexport type EthDecryptParams = Infer<typeof EthDecryptParamsStruct>;\n\n/**\n * Parameters for `eth_getAppKeyAddress`.\n */\nexport const EthGetAppKeyAddressParamsStruct = tuple([\n string(), // origin URL\n]);\n\nexport type EthGetAppKeyAddressParams = Infer<\n typeof EthGetAppKeyAddressParamsStruct\n>;\n\n/**\n * Parameters for `eth_signEip7702Authorization`.\n *\n * @example\n * ```ts\n * const params = [[1, '0xContractAddress', 0]];\n * ```\n */\nexport const EthSignEip7702AuthorizationParamsStruct = tuple([\n EthEip7702AuthorizationStruct,\n]);\n\nexport type EthSignEip7702AuthorizationParams = Infer<\n typeof EthSignEip7702AuthorizationParamsStruct\n>;\n\n/**\n * Parameters for `eth_getEncryptionPublicKey`.\n */\nexport const EthGetEncryptionPublicKeyParamsStruct = tuple([\n EthAddressStruct, // address\n optional(EthGetEncryptionPublicKeyOptionsStruct), // options\n]);\n"]} | ||
| {"version":3,"file":"params.mjs","sourceRoot":"","sources":["../../../src/eth/rpc/params.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,MAAM,EAAE,gCAAgC;AAEjD,OAAO,EACL,GAAG,EACH,KAAK,EACL,OAAO,EACP,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,MAAM,EACN,MAAM,EACN,KAAK,EACL,IAAI,EACJ,KAAK,EACL,OAAO,EACR,8BAA8B;AAE/B,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,cAAc,EACf,qBAAiB;AAElB;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,IAAI,CAAC;IAC3C,EAAE,EAAE,QAAQ,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;IACxC,IAAI,EAA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AAG,KAAK,CAAC;IACvC,gBAAgB,EAAE,UAAU;IAC5B,cAAc,EAAE,kCAAkC;CACnD,CAAC,CAAC;AAIH;;GAEG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,KAAK,CAAC;IAC/C,KAAK,CAAC,CAAC,cAAc,CAAC,CAAC,EAAE,SAAS;IAClC,KAAK,CAAC,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC,EAAE,kBAAkB;CAC9D,CAAC,CAAC;AAIH;;GAEG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,KAAK,CAAC;IAClD,gBAAgB,EAAE,UAAU;IAC5B,oBAAoB,EAAE,mBAAmB;CAC1C,CAAC,CAAC;AAMH;;GAEG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,KAAK,CAAC;IAChD,gBAAgB,EAAE,UAAU;IAC5B,qBAAqB,EAAE,oBAAoB;CAC5C,CAAC,CAAC;AAIH;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC;AAItE;;GAEG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,KAAK,CAAC;IACnD,MAAM,EAAE,EAAE,aAAa;CACxB,CAAC,CAAC;AAMH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,uCAAuC,GAAG,KAAK,CAAC;IAC3D,6BAA6B;CAC9B,CAAC,CAAC;AAMH;;GAEG;AACH,MAAM,CAAC,MAAM,qCAAqC,GAAG,KAAK,CAAC;IACzD,gBAAgB,EAAE,UAAU;IAC5B,QAAQ,CAAC,sCAAsC,CAAC,EAAE,UAAU;CAC7D,CAAC,CAAC","sourcesContent":["/**\n * Superstruct validation schemas for Ethereum JSON-RPC method parameters.\n *\n * These structs provide runtime validation for the parameters passed to various\n * Ethereum RPC methods. They can be used by keyring implementations to validate\n * incoming requests before processing.\n */\n\nimport { object } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport {\n any,\n array,\n literal,\n nullable,\n number,\n optional,\n record,\n string,\n tuple,\n type,\n union,\n unknown,\n} from '@metamask/superstruct';\n\nimport {\n EthAddressStrictStruct,\n EthAddressStruct,\n EthBytesStruct,\n} from '../types';\n\n/**\n * A struct for validating Ethereum transaction data.\n *\n * This uses `type()` instead of `object()` to allow extra properties,\n * since transaction formats can vary and include additional fields.\n * The actual transaction validation is performed by the transaction library.\n */\nexport const EthTransactionDataStruct = type({\n to: optional(nullable(EthAddressStruct)),\n from: optional(EthAddressStruct),\n nonce: optional(union([string(), number()])),\n value: optional(union([string(), number()])),\n data: optional(EthBytesStruct),\n gas: optional(union([string(), number()])),\n gasLimit: optional(union([string(), number()])),\n gasPrice: optional(union([string(), number()])),\n maxFeePerGas: optional(union([string(), number()])),\n maxPriorityFeePerGas: optional(union([string(), number()])),\n accessList: optional(\n array(\n type({\n address: EthAddressStruct,\n storageKeys: array(string()),\n }),\n ),\n ),\n type: optional(union([string(), number()])),\n chainId: optional(union([string(), number()])),\n});\n\nexport type EthTransactionData = Infer<typeof EthTransactionDataStruct>;\n\n/**\n * A struct for TypedDataV1 format (legacy typed data).\n * This is an array of { type, name, value } objects.\n */\nexport const EthTypedDataV1Struct = array(\n object({\n type: string(),\n name: string(),\n value: unknown(),\n }),\n);\n\nexport type EthTypedDataV1 = Infer<typeof EthTypedDataV1Struct>;\n\n/**\n * A struct for TypedData types definition.\n * Maps type names to arrays of { name, type } definitions.\n */\nexport const EthTypedDataTypesStruct = record(\n string(),\n array(\n object({\n name: string(),\n type: string(),\n }),\n ),\n);\n\nexport type EthTypedDataTypes = Infer<typeof EthTypedDataTypesStruct>;\n\n/**\n * A struct for TypedMessage format (EIP-712 V3/V4).\n * Contains types, domain, primaryType, and message.\n */\nexport const EthTypedMessageStruct = object({\n types: EthTypedDataTypesStruct,\n primaryType: string(),\n domain: record(string(), any()),\n message: record(string(), any()),\n});\n\nexport type EthTypedMessage = Infer<typeof EthTypedMessageStruct>;\n\n/**\n * A struct for EIP-1024 encrypted data format (x25519-xsalsa20-poly1305).\n */\nexport const EthEncryptedDataStruct = object({\n version: literal('x25519-xsalsa20-poly1305'),\n nonce: string(),\n ephemPublicKey: string(),\n ciphertext: string(),\n});\n\nexport type EthEncryptedData = Infer<typeof EthEncryptedDataStruct>;\n\n/**\n * A struct for EIP-7702 authorization tuple.\n * Format: [chainId, address, nonce]\n */\nexport const EthEip7702AuthorizationStruct = tuple([\n number(), // chainId\n EthAddressStrictStruct, // address (contract to delegate to)\n number(), // nonce\n]);\n\nexport type EthEip7702Authorization = Infer<\n typeof EthEip7702AuthorizationStruct\n>;\n\n/**\n * A struct for getEncryptionPublicKey options.\n */\nexport const EthGetEncryptionPublicKeyOptionsStruct = record(\n string(),\n unknown(),\n);\n\n// ============================================================================\n// RPC Method Parameter Structs\n// ============================================================================\n\n/**\n * Parameters for `eth_signTransaction`.\n */\nexport const EthSignTransactionParamsStruct = tuple([EthTransactionDataStruct]);\n\nexport type EthSignTransactionParams = Infer<\n typeof EthSignTransactionParamsStruct\n>;\n\n/**\n * Parameters for `eth_sign`.\n */\nexport const EthSignParamsStruct = tuple([\n EthAddressStruct, // address\n EthBytesStruct, // data (hex-encoded message hash)\n]);\n\nexport type EthSignParams = Infer<typeof EthSignParamsStruct>;\n\n/**\n * Parameters for `personal_sign`.\n */\nexport const EthPersonalSignParamsStruct = union([\n tuple([EthBytesStruct]), // [data]\n tuple([EthBytesStruct, EthAddressStruct]), // [data, address]\n]);\n\nexport type EthPersonalSignParams = Infer<typeof EthPersonalSignParamsStruct>;\n\n/**\n * Parameters for `eth_signTypedData_v1`.\n */\nexport const EthSignTypedDataV1ParamsStruct = tuple([\n EthAddressStruct, // address\n EthTypedDataV1Struct, // typed data array\n]);\n\nexport type EthSignTypedDataV1Params = Infer<\n typeof EthSignTypedDataV1ParamsStruct\n>;\n\n/**\n * Parameters for `eth_signTypedData_v3` and `eth_signTypedData_v4`.\n */\nexport const EthSignTypedDataParamsStruct = tuple([\n EthAddressStruct, // address\n EthTypedMessageStruct, // typed data object\n]);\n\nexport type EthSignTypedDataParams = Infer<typeof EthSignTypedDataParamsStruct>;\n\n/**\n * Parameters for `eth_decrypt`.\n */\nexport const EthDecryptParamsStruct = tuple([EthEncryptedDataStruct]);\n\nexport type EthDecryptParams = Infer<typeof EthDecryptParamsStruct>;\n\n/**\n * Parameters for `eth_getAppKeyAddress`.\n */\nexport const EthGetAppKeyAddressParamsStruct = tuple([\n string(), // origin URL\n]);\n\nexport type EthGetAppKeyAddressParams = Infer<\n typeof EthGetAppKeyAddressParamsStruct\n>;\n\n/**\n * Parameters for `eth_signEip7702Authorization`.\n *\n * @example\n * ```ts\n * const params = [[1, '0xContractAddress', 0]];\n * ```\n */\nexport const EthSignEip7702AuthorizationParamsStruct = tuple([\n EthEip7702AuthorizationStruct,\n]);\n\nexport type EthSignEip7702AuthorizationParams = Infer<\n typeof EthSignEip7702AuthorizationParamsStruct\n>;\n\n/**\n * Parameters for `eth_getEncryptionPublicKey`.\n */\nexport const EthGetEncryptionPublicKeyParamsStruct = tuple([\n EthAddressStruct, // address\n optional(EthGetEncryptionPublicKeyOptionsStruct), // options\n]);\n"]} |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.EthErc4337AccountStruct = exports.EthEoaAccountStruct = exports.EthMethod = exports.EthUint256Struct = exports.EthAddressStruct = exports.EthBytesStruct = void 0; | ||
| exports.EthErc4337AccountStruct = exports.EthEoaAccountStruct = exports.EthMethod = exports.EthUint256Struct = exports.EthAddressStrictStruct = exports.EthAddressStruct = exports.EthBytesStruct = void 0; | ||
| const keyring_utils_1 = require("@metamask/keyring-utils"); | ||
@@ -10,3 +10,6 @@ const superstruct_1 = require("@metamask/superstruct"); | ||
| 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); | ||
| const ETH_ADDRESS_REGEX = /^0x[0-9a-f]{40}$/iu; | ||
| exports.EthAddressStruct = (0, utils_1.definePattern)('EthAddress', ETH_ADDRESS_REGEX); | ||
| // Stricter struct that uses `Hex` as final type. | ||
| exports.EthAddressStrictStruct = (0, utils_1.definePattern)('EthAddressStrict', ETH_ADDRESS_REGEX); | ||
| exports.EthUint256Struct = (0, utils_1.definePattern)('EthUint256', /^0x([1-9a-f][0-9a-f]*|0)$/iu); | ||
@@ -13,0 +16,0 @@ /** |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../src/eth/types.ts"],"names":[],"mappings":";;;AAAA,2DAAiD;AAEjD,uDAAwE;AACxE,2CAA0D;AAE1D,kCAA6B;AAC7B,0CAIgB;AAEH,QAAA,cAAc,GAAG,IAAA,qBAAa,EAAC,UAAU,EAAE,iBAAiB,CAAC,CAAC;AAE9D,QAAA,gBAAgB,GAAG,IAAA,qBAAa,EAC3C,YAAY,EACZ,oBAAoB,CACrB,CAAC;AAEW,QAAA,gBAAgB,GAAG,IAAA,qBAAa,EAC3C,YAAY,EACZ,6BAA6B,CAC9B,CAAC;AAEF;;GAEG;AACH,IAAY,SAYX;AAZD,WAAY,SAAS;IACnB,0BAA0B;IAC1B,2CAA8B,CAAA;IAC9B,8BAAiB,CAAA;IACjB,oDAAuC,CAAA;IACvC,qDAAwC,CAAA;IACxC,qDAAwC,CAAA;IACxC,qDAAwC,CAAA;IACxC,mBAAmB;IACnB,8DAAiD,CAAA;IACjD,0DAA6C,CAAA;IAC7C,wDAA2C,CAAA;AAC7C,CAAC,EAZW,SAAS,yBAAT,SAAS,QAYpB;AAEY,QAAA,mBAAmB,GAAG,IAAA,sBAAM,EAAC;IACxC,GAAG,0BAAoB,CAAC,MAAM;IAE9B;;OAEG;IACH,OAAO,EAAE,wBAAgB;IAEzB;;OAEG;IACH,IAAI,EAAE,IAAA,qBAAO,EAAC,GAAG,oBAAc,CAAC,GAAG,EAAE,CAAC;IAEtC;;OAEG;IACH,MAAM,EAAE,IAAA,sBAAQ,EAAC,IAAA,mBAAK,EAAC,IAAA,qBAAO,EAAC,WAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;IAE9C;;OAEG;IACH,OAAO,EAAE,IAAA,mBAAK,EACZ,IAAA,mBAAK,EAAC;QACJ,GAAG,SAAS,CAAC,YAAY,EAAE;QAC3B,GAAG,SAAS,CAAC,IAAI,EAAE;QACnB,GAAG,SAAS,CAAC,eAAe,EAAE;QAC9B,GAAG,SAAS,CAAC,eAAe,EAAE;QAC9B,GAAG,SAAS,CAAC,eAAe,EAAE;QAC9B,GAAG,SAAS,CAAC,eAAe,EAAE;KAC/B,CAAC,CACH;CACF,CAAC,CAAC;AAIU,QAAA,uBAAuB,GAAG,IAAA,sBAAM,EAAC;IAC5C,GAAG,0BAAoB,CAAC,MAAM;IAE9B;;OAEG;IACH,OAAO,EAAE,wBAAgB;IAEzB;;OAEG;IACH,IAAI,EAAE,IAAA,qBAAO,EAAC,GAAG,oBAAc,CAAC,OAAO,EAAE,CAAC;IAE1C;;OAEG;IACH,MAAM,EAAE,IAAA,sBAAQ,EAAC,IAAA,mBAAK,EAAC,uBAAiB,CAAC,CAAC;IAE1C;;OAEG;IACH,OAAO,EAAE,IAAA,mBAAK,EACZ,IAAA,mBAAK,EAAC;QACJ,GAAG,SAAS,CAAC,YAAY,EAAE;QAC3B,GAAG,SAAS,CAAC,IAAI,EAAE;QACnB,GAAG,SAAS,CAAC,eAAe,EAAE;QAC9B,GAAG,SAAS,CAAC,eAAe,EAAE;QAC9B,GAAG,SAAS,CAAC,eAAe,EAAE;QAC9B,GAAG,SAAS,CAAC,oBAAoB,EAAE;QACnC,GAAG,SAAS,CAAC,kBAAkB,EAAE;QACjC,GAAG,SAAS,CAAC,iBAAiB,EAAE;KACjC,CAAC,CACH;CACF,CAAC,CAAC","sourcesContent":["import { object } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport { nonempty, array, enums, literal } from '@metamask/superstruct';\nimport { definePattern, type Hex } from '@metamask/utils';\n\nimport { EthScope } from '.';\nimport {\n CaipChainIdStruct,\n EthAccountType,\n KeyringAccountStruct,\n} from '../api';\n\nexport const EthBytesStruct = definePattern('EthBytes', /^0x[0-9a-f]*$/iu);\n\nexport const EthAddressStruct = definePattern<Hex>(\n 'EthAddress',\n /^0x[0-9a-f]{40}$/iu,\n);\n\nexport const EthUint256Struct = definePattern(\n 'EthUint256',\n /^0x([1-9a-f][0-9a-f]*|0)$/iu,\n);\n\n/**\n * Supported Ethereum methods.\n */\nexport enum EthMethod {\n // General signing methods\n PersonalSign = 'personal_sign',\n Sign = 'eth_sign',\n SignTransaction = 'eth_signTransaction',\n SignTypedDataV1 = 'eth_signTypedData_v1',\n SignTypedDataV3 = 'eth_signTypedData_v3',\n SignTypedDataV4 = 'eth_signTypedData_v4',\n // ERC-4337 methods\n PrepareUserOperation = 'eth_prepareUserOperation',\n PatchUserOperation = 'eth_patchUserOperation',\n SignUserOperation = 'eth_signUserOperation',\n}\n\nexport const EthEoaAccountStruct = object({\n ...KeyringAccountStruct.schema,\n\n /**\n * Account address.\n */\n address: EthAddressStruct,\n\n /**\n * Account type.\n */\n type: literal(`${EthAccountType.Eoa}`),\n\n /**\n * Account scopes (must be ['eip155:0']).\n */\n scopes: nonempty(array(literal(EthScope.Eoa))),\n\n /**\n * Account supported methods.\n */\n methods: array(\n enums([\n `${EthMethod.PersonalSign}`,\n `${EthMethod.Sign}`,\n `${EthMethod.SignTransaction}`,\n `${EthMethod.SignTypedDataV1}`,\n `${EthMethod.SignTypedDataV3}`,\n `${EthMethod.SignTypedDataV4}`,\n ]),\n ),\n});\n\nexport type EthEoaAccount = Infer<typeof EthEoaAccountStruct>;\n\nexport const EthErc4337AccountStruct = object({\n ...KeyringAccountStruct.schema,\n\n /**\n * Account address.\n */\n address: EthAddressStruct,\n\n /**\n * Account type.\n */\n type: literal(`${EthAccountType.Erc4337}`),\n\n /**\n * Account supported scopes (CAIP-2 chain IDs).\n */\n scopes: nonempty(array(CaipChainIdStruct)),\n\n /**\n * Account supported methods.\n */\n methods: array(\n enums([\n `${EthMethod.PersonalSign}`,\n `${EthMethod.Sign}`,\n `${EthMethod.SignTypedDataV1}`,\n `${EthMethod.SignTypedDataV3}`,\n `${EthMethod.SignTypedDataV4}`,\n `${EthMethod.PrepareUserOperation}`,\n `${EthMethod.PatchUserOperation}`,\n `${EthMethod.SignUserOperation}`,\n ]),\n ),\n});\n\nexport type EthErc4337Account = Infer<typeof EthErc4337AccountStruct>;\n"]} | ||
| {"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../src/eth/types.ts"],"names":[],"mappings":";;;AAAA,2DAAiD;AAEjD,uDAAwE;AACxE,2CAA0D;AAE1D,kCAA6B;AAC7B,0CAIgB;AAEH,QAAA,cAAc,GAAG,IAAA,qBAAa,EAAC,UAAU,EAAE,iBAAiB,CAAC,CAAC;AAE3E,MAAM,iBAAiB,GAAG,oBAAoB,CAAC;AAClC,QAAA,gBAAgB,GAAG,IAAA,qBAAa,EAAC,YAAY,EAAE,iBAAiB,CAAC,CAAC;AAC/E,iDAAiD;AACpC,QAAA,sBAAsB,GAAG,IAAA,qBAAa,EACjD,kBAAkB,EAClB,iBAAiB,CAClB,CAAC;AAEW,QAAA,gBAAgB,GAAG,IAAA,qBAAa,EAC3C,YAAY,EACZ,6BAA6B,CAC9B,CAAC;AAEF;;GAEG;AACH,IAAY,SAYX;AAZD,WAAY,SAAS;IACnB,0BAA0B;IAC1B,2CAA8B,CAAA;IAC9B,8BAAiB,CAAA;IACjB,oDAAuC,CAAA;IACvC,qDAAwC,CAAA;IACxC,qDAAwC,CAAA;IACxC,qDAAwC,CAAA;IACxC,mBAAmB;IACnB,8DAAiD,CAAA;IACjD,0DAA6C,CAAA;IAC7C,wDAA2C,CAAA;AAC7C,CAAC,EAZW,SAAS,yBAAT,SAAS,QAYpB;AAEY,QAAA,mBAAmB,GAAG,IAAA,sBAAM,EAAC;IACxC,GAAG,0BAAo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GAAG,SAAS,CAAC,iBAAiB,EAAE;KACjC,CAAC,CACH;CACF,CAAC,CAAC","sourcesContent":["import { object } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport { nonempty, array, enums, literal } from '@metamask/superstruct';\nimport { definePattern, type Hex } from '@metamask/utils';\n\nimport { EthScope } from '.';\nimport {\n CaipChainIdStruct,\n EthAccountType,\n KeyringAccountStruct,\n} from '../api';\n\nexport const EthBytesStruct = definePattern('EthBytes', /^0x[0-9a-f]*$/iu);\n\nconst ETH_ADDRESS_REGEX = /^0x[0-9a-f]{40}$/iu;\nexport const EthAddressStruct = definePattern('EthAddress', ETH_ADDRESS_REGEX);\n// Stricter struct that uses `Hex` as final type.\nexport const EthAddressStrictStruct = definePattern<Hex>(\n 'EthAddressStrict',\n ETH_ADDRESS_REGEX,\n);\n\nexport const EthUint256Struct = definePattern(\n 'EthUint256',\n /^0x([1-9a-f][0-9a-f]*|0)$/iu,\n);\n\n/**\n * Supported Ethereum methods.\n */\nexport enum EthMethod {\n // General signing methods\n PersonalSign = 'personal_sign',\n Sign = 'eth_sign',\n SignTransaction = 'eth_signTransaction',\n SignTypedDataV1 = 'eth_signTypedData_v1',\n SignTypedDataV3 = 'eth_signTypedData_v3',\n SignTypedDataV4 = 'eth_signTypedData_v4',\n // ERC-4337 methods\n PrepareUserOperation = 'eth_prepareUserOperation',\n PatchUserOperation = 'eth_patchUserOperation',\n SignUserOperation = 'eth_signUserOperation',\n}\n\nexport const EthEoaAccountStruct = object({\n ...KeyringAccountStruct.schema,\n\n /**\n * Account address.\n */\n address: EthAddressStruct,\n\n /**\n * Account type.\n */\n type: literal(`${EthAccountType.Eoa}`),\n\n /**\n * Account scopes (must be ['eip155:0']).\n */\n scopes: nonempty(array(literal(EthScope.Eoa))),\n\n /**\n * Account supported methods.\n */\n methods: array(\n enums([\n `${EthMethod.PersonalSign}`,\n `${EthMethod.Sign}`,\n `${EthMethod.SignTransaction}`,\n `${EthMethod.SignTypedDataV1}`,\n `${EthMethod.SignTypedDataV3}`,\n `${EthMethod.SignTypedDataV4}`,\n ]),\n ),\n});\n\nexport type EthEoaAccount = Infer<typeof EthEoaAccountStruct>;\n\nexport const EthErc4337AccountStruct = object({\n ...KeyringAccountStruct.schema,\n\n /**\n * Account address.\n */\n address: EthAddressStruct,\n\n /**\n * Account type.\n */\n type: literal(`${EthAccountType.Erc4337}`),\n\n /**\n * Account supported scopes (CAIP-2 chain IDs).\n */\n scopes: nonempty(array(CaipChainIdStruct)),\n\n /**\n * Account supported methods.\n */\n methods: array(\n enums([\n `${EthMethod.PersonalSign}`,\n `${EthMethod.Sign}`,\n `${EthMethod.SignTypedDataV1}`,\n `${EthMethod.SignTypedDataV3}`,\n `${EthMethod.SignTypedDataV4}`,\n `${EthMethod.PrepareUserOperation}`,\n `${EthMethod.PatchUserOperation}`,\n `${EthMethod.SignUserOperation}`,\n ]),\n ),\n});\n\nexport type EthErc4337Account = Infer<typeof EthErc4337AccountStruct>;\n"]} |
| import type { Infer } from "@metamask/superstruct"; | ||
| import { EthScope } from "./index.cjs"; | ||
| export declare const EthBytesStruct: import("@metamask/superstruct").Struct<string, null>; | ||
| export declare const EthAddressStruct: import("@metamask/superstruct").Struct<`0x${string}`, null>; | ||
| export declare const EthAddressStruct: import("@metamask/superstruct").Struct<string, null>; | ||
| export declare const EthAddressStrictStruct: import("@metamask/superstruct").Struct<`0x${string}`, null>; | ||
| export declare const EthUint256Struct: import("@metamask/superstruct").Struct<string, null>; | ||
@@ -36,3 +37,3 @@ /** | ||
| }; | ||
| address: `0x${string}`; | ||
| address: string; | ||
| scopes: EthScope.Eoa[]; | ||
@@ -44,3 +45,3 @@ methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4")[]; | ||
| */ | ||
| address: import("@metamask/superstruct").Struct<`0x${string}`, null>; | ||
| address: import("@metamask/superstruct").Struct<string, null>; | ||
| /** | ||
@@ -97,3 +98,3 @@ * Account type. | ||
| }; | ||
| address: `0x${string}`; | ||
| address: string; | ||
| scopes: `${string}:${string}`[]; | ||
@@ -105,3 +106,3 @@ methods: ("personal_sign" | "eth_sign" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[]; | ||
| */ | ||
| address: import("@metamask/superstruct").Struct<`0x${string}`, null>; | ||
| address: import("@metamask/superstruct").Struct<string, null>; | ||
| /** | ||
@@ -108,0 +109,0 @@ * Account type. |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../src/eth/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAInD,OAAO,EAAE,QAAQ,EAAE,oBAAU;AAO7B,eAAO,MAAM,cAAc,sDAA+C,CAAC;AAE3E,eAAO,MAAM,gBAAgB,6DAG5B,CAAC;AAEF,eAAO,MAAM,gBAAgB,sDAG5B,CAAC;AAEF;;GAEG;AACH,oBAAY,SAAS;IAEnB,YAAY,kBAAkB;IAC9B,IAAI,aAAa;IACjB,eAAe,wBAAwB;IACvC,eAAe,yBAAyB;IACxC,eAAe,yBAAyB;IACxC,eAAe,yBAAyB;IAExC,oBAAoB,6BAA6B;IACjD,kBAAkB,2BAA2B;IAC7C,iBAAiB,0BAA0B;CAC5C;AAED,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;IAG9B;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;;;;;;;;;;;;;;;;;;;;;;EAWH,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAE9D,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;IAGlC;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;;;;;;;;;;;;;;;;;;;;;;;;EAaH,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC"} | ||
| {"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../src/eth/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAInD,OAAO,EAAE,QAAQ,EAAE,oBAAU;AAO7B,eAAO,MAAM,cAAc,sDAA+C,CAAC;AAG3E,eAAO,MAAM,gBAAgB,sDAAiD,CAAC;AAE/E,eAAO,MAAM,sBAAsB,6DAGlC,CAAC;AAEF,eAAO,MAAM,gBAAgB,sDAG5B,CAAC;AAEF;;GAEG;AACH,oBAAY,SAAS;IAEnB,YAAY,kBAAkB;IAC9B,IAAI,aAAa;IACjB,eAAe,wBAAwB;IACvC,eAAe,yBAAyB;IACxC,eAAe,yBAAyB;IACxC,eAAe,yBAAyB;IAExC,oBAAoB,6BAA6B;IACjD,kBAAkB,2BAA2B;IAC7C,iBAAiB,0BAA0B;CAC5C;AAED,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;IAG9B;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;;;;;;;;;;;;;;;;;;;;;;EAWH,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAE9D,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;IAGlC;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;;;;;;;;;;;;;;;;;;;;;;;;EAaH,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC"} |
| import type { Infer } from "@metamask/superstruct"; | ||
| import { EthScope } from "./index.mjs"; | ||
| export declare const EthBytesStruct: import("@metamask/superstruct").Struct<string, null>; | ||
| export declare const EthAddressStruct: import("@metamask/superstruct").Struct<`0x${string}`, null>; | ||
| export declare const EthAddressStruct: import("@metamask/superstruct").Struct<string, null>; | ||
| export declare const EthAddressStrictStruct: import("@metamask/superstruct").Struct<`0x${string}`, null>; | ||
| export declare const EthUint256Struct: import("@metamask/superstruct").Struct<string, null>; | ||
@@ -36,3 +37,3 @@ /** | ||
| }; | ||
| address: `0x${string}`; | ||
| address: string; | ||
| scopes: EthScope.Eoa[]; | ||
@@ -44,3 +45,3 @@ methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4")[]; | ||
| */ | ||
| address: import("@metamask/superstruct").Struct<`0x${string}`, null>; | ||
| address: import("@metamask/superstruct").Struct<string, null>; | ||
| /** | ||
@@ -97,3 +98,3 @@ * Account type. | ||
| }; | ||
| address: `0x${string}`; | ||
| address: string; | ||
| scopes: `${string}:${string}`[]; | ||
@@ -105,3 +106,3 @@ methods: ("personal_sign" | "eth_sign" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[]; | ||
| */ | ||
| address: import("@metamask/superstruct").Struct<`0x${string}`, null>; | ||
| address: import("@metamask/superstruct").Struct<string, null>; | ||
| /** | ||
@@ -108,0 +109,0 @@ * Account type. |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../src/eth/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAInD,OAAO,EAAE,QAAQ,EAAE,oBAAU;AAO7B,eAAO,MAAM,cAAc,sDAA+C,CAAC;AAE3E,eAAO,MAAM,gBAAgB,6DAG5B,CAAC;AAEF,eAAO,MAAM,gBAAgB,sDAG5B,CAAC;AAEF;;GAEG;AACH,oBAAY,SAAS;IAEnB,YAAY,kBAAkB;IAC9B,IAAI,aAAa;IACjB,eAAe,wBAAwB;IACvC,eAAe,yBAAyB;IACxC,eAAe,yBAAyB;IACxC,eA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M,aAAa,GAAG,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAE9D,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;IAGlC;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;;;;;;;;;;;;;;;;;;;;;;;;EAaH,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC"} |
@@ -7,3 +7,6 @@ import { object } from "@metamask/keyring-utils"; | ||
| export const EthBytesStruct = definePattern('EthBytes', /^0x[0-9a-f]*$/iu); | ||
| export const EthAddressStruct = definePattern('EthAddress', /^0x[0-9a-f]{40}$/iu); | ||
| const ETH_ADDRESS_REGEX = /^0x[0-9a-f]{40}$/iu; | ||
| export const EthAddressStruct = definePattern('EthAddress', ETH_ADDRESS_REGEX); | ||
| // Stricter struct that uses `Hex` as final type. | ||
| export const EthAddressStrictStruct = definePattern('EthAddressStrict', ETH_ADDRESS_REGEX); | ||
| export const EthUint256Struct = definePattern('EthUint256', /^0x([1-9a-f][0-9a-f]*|0)$/iu); | ||
@@ -10,0 +13,0 @@ /** |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../src/eth/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,gCAAgC;AAEjD,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,8BAA8B;AACxE,OAAO,EAAE,aAAa,EAAY,wBAAwB;AAE1D,OAAO,EAAE,QAAQ,EAAE,oBAAU;AAC7B,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,oBAAoB,EACrB,yBAAe;AAEhB,MAAM,CAAC,MAAM,cAAc,GAAG,aAAa,CAAC,UAAU,EAAE,iBAAiB,CAAC,CAAC;AAE3E,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAa,CAC3C,YAAY,EACZ,oBAAoB,CACrB,CAAC;AA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;;OAEG;IACH,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAE1C;;OAEG;IACH,OAAO,EAAE,KAAK,CACZ,KAAK,CAAC;QACJ,GAAG,SAAS,CAAC,YAAY,EAAE;QAC3B,GAAG,SAAS,CAAC,IAAI,EAAE;QACnB,GAAG,SAAS,CAAC,eAAe,EAAE;QAC9B,GAAG,SAAS,CAAC,eAAe,EAAE;QAC9B,GAAG,SAAS,CAAC,eAAe,EAAE;QAC9B,GAAG,SAAS,CAAC,oBAAoB,EAAE;QACnC,GAAG,SAAS,CAAC,kBAAkB,EAAE;QACjC,GAAG,SAAS,CAAC,iBAAiB,EAAE;KACjC,CAAC,CACH;CACF,CAAC,CAAC","sourcesContent":["import { object } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport { nonempty, array, enums, literal } from '@metamask/superstruct';\nimport { definePattern, type Hex } from '@metamask/utils';\n\nimport { EthScope } from '.';\nimport {\n CaipChainIdStruct,\n EthAccountType,\n KeyringAccountStruct,\n} from '../api';\n\nexport const EthBytesStruct = definePattern('EthBytes', /^0x[0-9a-f]*$/iu);\n\nexport const EthAddressStruct = definePattern<Hex>(\n 'EthAddress',\n /^0x[0-9a-f]{40}$/iu,\n);\n\nexport const EthUint256Struct = definePattern(\n 'EthUint256',\n /^0x([1-9a-f][0-9a-f]*|0)$/iu,\n);\n\n/**\n * Supported Ethereum methods.\n */\nexport enum EthMethod {\n // General signing methods\n PersonalSign = 'personal_sign',\n Sign = 'eth_sign',\n SignTransaction = 'eth_signTransaction',\n SignTypedDataV1 = 'eth_signTypedData_v1',\n SignTypedDataV3 = 'eth_signTypedData_v3',\n SignTypedDataV4 = 'eth_signTypedData_v4',\n // ERC-4337 methods\n PrepareUserOperation = 'eth_prepareUserOperation',\n PatchUserOperation = 'eth_patchUserOperation',\n SignUserOperation = 'eth_signUserOperation',\n}\n\nexport const EthEoaAccountStruct = object({\n ...KeyringAccountStruct.schema,\n\n /**\n * Account address.\n */\n address: EthAddressStruct,\n\n /**\n * Account type.\n */\n type: literal(`${EthAccountType.Eoa}`),\n\n /**\n * Account scopes (must be ['eip155:0']).\n */\n scopes: nonempty(array(literal(EthScope.Eoa))),\n\n /**\n * Account supported methods.\n */\n methods: array(\n enums([\n `${EthMethod.PersonalSign}`,\n `${EthMethod.Sign}`,\n `${EthMethod.SignTransaction}`,\n `${EthMethod.SignTypedDataV1}`,\n `${EthMethod.SignTypedDataV3}`,\n `${EthMethod.SignTypedDataV4}`,\n ]),\n ),\n});\n\nexport type EthEoaAccount = Infer<typeof EthEoaAccountStruct>;\n\nexport const EthErc4337AccountStruct = object({\n ...KeyringAccountStruct.schema,\n\n /**\n * Account address.\n */\n address: EthAddressStruct,\n\n /**\n * Account type.\n */\n type: literal(`${EthAccountType.Erc4337}`),\n\n /**\n * Account supported scopes (CAIP-2 chain IDs).\n */\n scopes: nonempty(array(CaipChainIdStruct)),\n\n /**\n * Account supported methods.\n */\n methods: array(\n enums([\n `${EthMethod.PersonalSign}`,\n `${EthMethod.Sign}`,\n `${EthMethod.SignTypedDataV1}`,\n `${EthMethod.SignTypedDataV3}`,\n `${EthMethod.SignTypedDataV4}`,\n `${EthMethod.PrepareUserOperation}`,\n `${EthMethod.PatchUserOperation}`,\n `${EthMethod.SignUserOperation}`,\n ]),\n ),\n});\n\nexport type EthErc4337Account = Infer<typeof EthErc4337AccountStruct>;\n"]} | ||
| {"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../src/eth/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,gCAAgC;AAEjD,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,8BAA8B;AACxE,OAAO,EAAE,aAAa,EAAY,wBAAwB;AAE1D,OAAO,EAAE,QAAQ,EAAE,oBAAU;AAC7B,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,oBAAoB,EACrB,yBAAe;AAEhB,MAAM,CAAC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eAAe,EAAE;QAC9B,GAAG,SAAS,CAAC,eAAe,EAAE;KAC/B,CAAC,CACH;CACF,CAAC,CAAC;AAIH,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC;IAC5C,GAAG,oBAAoB,CAAC,MAAM;IAE9B;;OAEG;IACH,OAAO,EAAE,gBAAgB;IAEzB;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC,GAAG,cAAc,CAAC,OAAO,EAAE,CAAC;IAE1C;;OAEG;IACH,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAE1C;;OAEG;IACH,OAAO,EAAE,KAAK,CACZ,KAAK,CAAC;QACJ,GAAG,SAAS,CAAC,YAAY,EAAE;QAC3B,GAAG,SAAS,CAAC,IAAI,EAAE;QACnB,GAAG,SAAS,CAAC,eAAe,EAAE;QAC9B,GAAG,SAAS,CAAC,eAAe,EAAE;QAC9B,GAAG,SAAS,CAAC,eAAe,EAAE;QAC9B,GAAG,SAAS,CAAC,oBAAoB,EAAE;QACnC,GAAG,SAAS,CAAC,kBAAkB,EAAE;QACjC,GAAG,SAAS,CAAC,iBAAiB,EAAE;KACjC,CAAC,CACH;CACF,CAAC,CAAC","sourcesContent":["import { object } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport { nonempty, array, enums, literal } from '@metamask/superstruct';\nimport { definePattern, type Hex } from '@metamask/utils';\n\nimport { EthScope } from '.';\nimport {\n CaipChainIdStruct,\n EthAccountType,\n KeyringAccountStruct,\n} from '../api';\n\nexport const EthBytesStruct = definePattern('EthBytes', /^0x[0-9a-f]*$/iu);\n\nconst ETH_ADDRESS_REGEX = /^0x[0-9a-f]{40}$/iu;\nexport const EthAddressStruct = definePattern('EthAddress', ETH_ADDRESS_REGEX);\n// Stricter struct that uses `Hex` as final type.\nexport const EthAddressStrictStruct = definePattern<Hex>(\n 'EthAddressStrict',\n ETH_ADDRESS_REGEX,\n);\n\nexport const EthUint256Struct = definePattern(\n 'EthUint256',\n /^0x([1-9a-f][0-9a-f]*|0)$/iu,\n);\n\n/**\n * Supported Ethereum methods.\n */\nexport enum EthMethod {\n // General signing methods\n PersonalSign = 'personal_sign',\n Sign = 'eth_sign',\n SignTransaction = 'eth_signTransaction',\n SignTypedDataV1 = 'eth_signTypedData_v1',\n SignTypedDataV3 = 'eth_signTypedData_v3',\n SignTypedDataV4 = 'eth_signTypedData_v4',\n // ERC-4337 methods\n PrepareUserOperation = 'eth_prepareUserOperation',\n PatchUserOperation = 'eth_patchUserOperation',\n SignUserOperation = 'eth_signUserOperation',\n}\n\nexport const EthEoaAccountStruct = object({\n ...KeyringAccountStruct.schema,\n\n /**\n * Account address.\n */\n address: EthAddressStruct,\n\n /**\n * Account type.\n */\n type: literal(`${EthAccountType.Eoa}`),\n\n /**\n * Account scopes (must be ['eip155:0']).\n */\n scopes: nonempty(array(literal(EthScope.Eoa))),\n\n /**\n * Account supported methods.\n */\n methods: array(\n enums([\n `${EthMethod.PersonalSign}`,\n `${EthMethod.Sign}`,\n `${EthMethod.SignTransaction}`,\n `${EthMethod.SignTypedDataV1}`,\n `${EthMethod.SignTypedDataV3}`,\n `${EthMethod.SignTypedDataV4}`,\n ]),\n ),\n});\n\nexport type EthEoaAccount = Infer<typeof EthEoaAccountStruct>;\n\nexport const EthErc4337AccountStruct = object({\n ...KeyringAccountStruct.schema,\n\n /**\n * Account address.\n */\n address: EthAddressStruct,\n\n /**\n * Account type.\n */\n type: literal(`${EthAccountType.Erc4337}`),\n\n /**\n * Account supported scopes (CAIP-2 chain IDs).\n */\n scopes: nonempty(array(CaipChainIdStruct)),\n\n /**\n * Account supported methods.\n */\n methods: array(\n enums([\n `${EthMethod.PersonalSign}`,\n `${EthMethod.Sign}`,\n `${EthMethod.SignTypedDataV1}`,\n `${EthMethod.SignTypedDataV3}`,\n `${EthMethod.SignTypedDataV4}`,\n `${EthMethod.PrepareUserOperation}`,\n `${EthMethod.PatchUserOperation}`,\n `${EthMethod.SignUserOperation}`,\n ]),\n ),\n});\n\nexport type EthErc4337Account = Infer<typeof EthErc4337AccountStruct>;\n"]} |
+1
-1
| { | ||
| "name": "@metamask/keyring-api", | ||
| "version": "21.4.0", | ||
| "version": "21.5.0", | ||
| "description": "MetaMask Keyring API", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
1111202
1.06%5678
1.3%