@metamask-previews/keyring-internal-api 0.0.1-672cc7b → 0.0.1-b85bfaa

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/dist/{internal/api.js → api.cjs} +2 -2
  2. package/dist/api.cjs.map +1 -0
  3. package/dist/{internal/api.d.ts → api.d.cts} +46 -41
  4. package/dist/api.d.cts.map +1 -0
  5. package/dist/api.d.mts +420 -0
  6. package/dist/api.d.mts.map +1 -0
  7. package/dist/api.mjs +135 -0
  8. package/dist/api.mjs.map +1 -0
  9. package/dist/btc/{index.js → index.cjs} +2 -2
  10. package/dist/btc/index.cjs.map +1 -0
  11. package/dist/btc/index.d.cts +2 -0
  12. package/dist/btc/index.d.cts.map +1 -0
  13. package/dist/btc/index.d.mts +2 -0
  14. package/dist/btc/index.d.mts.map +1 -0
  15. package/dist/btc/index.mjs +2 -0
  16. package/dist/btc/index.mjs.map +1 -0
  17. package/dist/btc/{types.js → types.cjs} +4 -4
  18. package/dist/btc/types.cjs.map +1 -0
  19. package/dist/btc/{types.d.ts → types.d.cts} +8 -7
  20. package/dist/btc/types.d.cts.map +1 -0
  21. package/dist/btc/types.d.mts +34 -0
  22. package/dist/btc/types.d.mts.map +1 -0
  23. package/dist/btc/types.mjs +37 -0
  24. package/dist/btc/types.mjs.map +1 -0
  25. package/dist/{internal/eth/EthKeyring.js → eth/EthKeyring.cjs} +1 -1
  26. package/dist/eth/EthKeyring.cjs.map +1 -0
  27. package/dist/{internal/eth/EthKeyring.d.ts → eth/EthKeyring.d.cts} +5 -4
  28. package/dist/eth/EthKeyring.d.cts.map +1 -0
  29. package/dist/eth/EthKeyring.d.mts +34 -0
  30. package/dist/eth/EthKeyring.d.mts.map +1 -0
  31. package/dist/eth/EthKeyring.mjs +2 -0
  32. package/dist/eth/EthKeyring.mjs.map +1 -0
  33. package/dist/eth/erc4337/{index.js → index.cjs} +2 -2
  34. package/dist/eth/erc4337/index.cjs.map +1 -0
  35. package/dist/eth/erc4337/index.d.cts +2 -0
  36. package/dist/eth/erc4337/index.d.cts.map +1 -0
  37. package/dist/eth/erc4337/index.d.mts +2 -0
  38. package/dist/eth/erc4337/index.d.mts.map +1 -0
  39. package/dist/eth/erc4337/index.mjs +2 -0
  40. package/dist/eth/erc4337/index.mjs.map +1 -0
  41. package/dist/eth/erc4337/{types.js → types.cjs} +2 -2
  42. package/dist/eth/erc4337/types.cjs.map +1 -0
  43. package/dist/eth/erc4337/{types.d.ts → types.d.cts} +7 -6
  44. package/dist/eth/erc4337/types.d.cts.map +1 -0
  45. package/dist/eth/erc4337/types.d.mts +98 -0
  46. package/dist/eth/erc4337/types.d.mts.map +1 -0
  47. package/dist/eth/erc4337/types.mjs +58 -0
  48. package/dist/eth/erc4337/types.mjs.map +1 -0
  49. package/dist/{index.js → eth/index.cjs} +4 -4
  50. package/dist/eth/index.cjs.map +1 -0
  51. package/dist/eth/index.d.cts +5 -0
  52. package/dist/eth/index.d.cts.map +1 -0
  53. package/dist/eth/index.d.mts +5 -0
  54. package/dist/eth/index.d.mts.map +1 -0
  55. package/dist/eth/index.mjs +4 -0
  56. package/dist/eth/index.mjs.map +1 -0
  57. package/dist/eth/{types.js → types.cjs} +2 -2
  58. package/dist/eth/types.cjs.map +1 -0
  59. package/dist/eth/{types.d.ts → types.d.cts} +6 -5
  60. package/dist/eth/types.d.cts.map +1 -0
  61. package/dist/eth/types.d.mts +81 -0
  62. package/dist/eth/types.d.mts.map +1 -0
  63. package/dist/eth/types.mjs +70 -0
  64. package/dist/eth/types.mjs.map +1 -0
  65. package/dist/eth/{utils.js → utils.cjs} +2 -3
  66. package/dist/eth/{utils.js.map → utils.cjs.map} +1 -1
  67. package/dist/eth/{utils.d.ts → utils.d.cts} +2 -1
  68. package/dist/eth/utils.d.cts.map +1 -0
  69. package/dist/eth/utils.d.mts +9 -0
  70. package/dist/eth/utils.d.mts.map +1 -0
  71. package/dist/eth/utils.mjs +11 -0
  72. package/dist/eth/utils.mjs.map +1 -0
  73. package/dist/{internal/events.js → events.cjs} +2 -2
  74. package/dist/events.cjs.map +1 -0
  75. package/dist/{internal/events.d.ts → events.d.cts} +11 -8
  76. package/dist/events.d.cts.map +1 -0
  77. package/dist/events.d.mts +172 -0
  78. package/dist/events.d.mts.map +1 -0
  79. package/dist/events.mjs +80 -0
  80. package/dist/events.mjs.map +1 -0
  81. package/dist/{eth/index.js → index.cjs} +8 -4
  82. package/dist/index.cjs.map +1 -0
  83. package/dist/index.d.cts +8 -0
  84. package/dist/index.d.cts.map +1 -0
  85. package/dist/index.d.mts +8 -0
  86. package/dist/index.d.mts.map +1 -0
  87. package/dist/index.mjs +8 -0
  88. package/dist/index.mjs.map +1 -0
  89. package/dist/{internal/rpc.js → rpc.cjs} +4 -4
  90. package/dist/rpc.cjs.map +1 -0
  91. package/dist/{internal/rpc.d.ts → rpc.d.cts} +1 -0
  92. package/dist/rpc.d.cts.map +1 -0
  93. package/dist/rpc.d.mts +26 -0
  94. package/dist/rpc.d.mts.map +1 -0
  95. package/dist/rpc.mjs +29 -0
  96. package/dist/rpc.mjs.map +1 -0
  97. package/dist/{internal/eth/index.js → sol/index.cjs} +2 -2
  98. package/dist/sol/index.cjs.map +1 -0
  99. package/dist/sol/index.d.cts +2 -0
  100. package/dist/sol/index.d.cts.map +1 -0
  101. package/dist/sol/index.d.mts +2 -0
  102. package/dist/sol/index.d.mts.map +1 -0
  103. package/dist/sol/index.mjs +2 -0
  104. package/dist/sol/index.mjs.map +1 -0
  105. package/dist/sol/types.cjs +36 -0
  106. package/dist/sol/types.cjs.map +1 -0
  107. package/dist/sol/types.d.cts +39 -0
  108. package/dist/sol/types.d.cts.map +1 -0
  109. package/dist/sol/types.d.mts +39 -0
  110. package/dist/sol/types.d.mts.map +1 -0
  111. package/dist/sol/types.mjs +33 -0
  112. package/dist/sol/types.mjs.map +1 -0
  113. package/dist/{internal/types.js → types.cjs} +26 -19
  114. package/dist/types.cjs.map +1 -0
  115. package/dist/{internal/types.d.ts → types.d.cts} +106 -44
  116. package/dist/types.d.cts.map +1 -0
  117. package/dist/types.d.mts +392 -0
  118. package/dist/types.d.mts.map +1 -0
  119. package/dist/types.mjs +53 -0
  120. package/dist/types.mjs.map +1 -0
  121. package/package.json +30 -18
  122. package/dist/btc/index.d.ts +0 -1
  123. package/dist/btc/index.js.map +0 -1
  124. package/dist/btc/types.js.map +0 -1
  125. package/dist/eth/erc4337/index.d.ts +0 -1
  126. package/dist/eth/erc4337/index.js.map +0 -1
  127. package/dist/eth/erc4337/types.js.map +0 -1
  128. package/dist/eth/index.d.ts +0 -3
  129. package/dist/eth/index.js.map +0 -1
  130. package/dist/eth/types.js.map +0 -1
  131. package/dist/index.d.ts +0 -3
  132. package/dist/index.js.map +0 -1
  133. package/dist/internal/api.js.map +0 -1
  134. package/dist/internal/eth/EthKeyring.js.map +0 -1
  135. package/dist/internal/eth/index.d.ts +0 -1
  136. package/dist/internal/eth/index.js.map +0 -1
  137. package/dist/internal/events.js.map +0 -1
  138. package/dist/internal/index.d.ts +0 -5
  139. package/dist/internal/index.js +0 -22
  140. package/dist/internal/index.js.map +0 -1
  141. package/dist/internal/rpc.js.map +0 -1
  142. package/dist/internal/types.js.map +0 -1
@@ -1,17 +1,17 @@
1
- import type { Infer } from '@metamask/superstruct';
1
+ import type { Infer } from "@metamask/superstruct";
2
2
  export declare const BtcP2wpkhAddressStruct: import("@metamask/superstruct").Struct<string, null>;
3
3
  /**
4
4
  * Supported Bitcoin methods.
5
5
  */
6
6
  export declare enum BtcMethod {
7
- SendMany = "btc_sendmany"
7
+ SendBitcoin = "sendBitcoin"
8
8
  }
9
9
  export declare const BtcP2wpkhAccountStruct: import("@metamask/superstruct").Struct<{
10
10
  id: string;
11
11
  options: Record<string, import("@metamask/utils").Json>;
12
- address: string;
13
12
  type: "bip122:p2wpkh";
14
- methods: "btc_sendmany"[];
13
+ address: string;
14
+ methods: "sendBitcoin"[];
15
15
  }, {
16
16
  /**
17
17
  * Account address.
@@ -24,10 +24,11 @@ export declare const BtcP2wpkhAccountStruct: import("@metamask/superstruct").Str
24
24
  /**
25
25
  * Account supported methods.
26
26
  */
27
- methods: import("@metamask/superstruct").Struct<"btc_sendmany"[], import("@metamask/superstruct").Struct<"btc_sendmany", {
28
- btc_sendmany: "btc_sendmany";
27
+ methods: import("@metamask/superstruct").Struct<"sendBitcoin"[], import("@metamask/superstruct").Struct<"sendBitcoin", {
28
+ sendBitcoin: "sendBitcoin";
29
29
  }>>;
30
30
  id: import("@metamask/superstruct").Struct<string, null>;
31
31
  options: import("@metamask/superstruct").Struct<Record<string, import("@metamask/utils").Json>, null>;
32
32
  }>;
33
- export declare type BtcP2wpkhAccount = Infer<typeof BtcP2wpkhAccountStruct>;
33
+ export type BtcP2wpkhAccount = Infer<typeof BtcP2wpkhAccountStruct>;
34
+ //# sourceMappingURL=types.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../src/btc/types.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAInD,eAAO,MAAM,sBAAsB,sDAalC,CAAC;AAEF;;GAEG;AACH,oBAAY,SAAS;IAEnB,WAAW,gBAAgB;CAC5B;AAED,eAAO,MAAM,sBAAsB;;;;;;;IAGjC;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;;;;;EAEH,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC"}
@@ -0,0 +1,34 @@
1
+ import type { Infer } from "@metamask/superstruct";
2
+ export declare const BtcP2wpkhAddressStruct: import("@metamask/superstruct").Struct<string, null>;
3
+ /**
4
+ * Supported Bitcoin methods.
5
+ */
6
+ export declare enum BtcMethod {
7
+ SendBitcoin = "sendBitcoin"
8
+ }
9
+ export declare const BtcP2wpkhAccountStruct: import("@metamask/superstruct").Struct<{
10
+ id: string;
11
+ options: Record<string, import("@metamask/utils").Json>;
12
+ type: "bip122:p2wpkh";
13
+ address: string;
14
+ methods: "sendBitcoin"[];
15
+ }, {
16
+ /**
17
+ * Account address.
18
+ */
19
+ address: import("@metamask/superstruct").Struct<string, null>;
20
+ /**
21
+ * Account type.
22
+ */
23
+ type: import("@metamask/superstruct").Struct<"bip122:p2wpkh", "bip122:p2wpkh">;
24
+ /**
25
+ * Account supported methods.
26
+ */
27
+ methods: import("@metamask/superstruct").Struct<"sendBitcoin"[], import("@metamask/superstruct").Struct<"sendBitcoin", {
28
+ sendBitcoin: "sendBitcoin";
29
+ }>>;
30
+ id: import("@metamask/superstruct").Struct<string, null>;
31
+ options: import("@metamask/superstruct").Struct<Record<string, import("@metamask/utils").Json>, null>;
32
+ }>;
33
+ export type BtcP2wpkhAccount = Infer<typeof BtcP2wpkhAccountStruct>;
34
+ //# sourceMappingURL=types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../src/btc/types.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAInD,eAAO,MAAM,sBAAsB,sDAalC,CAAC;AAEF;;GAEG;AACH,oBAAY,SAAS;IAEnB,WAAW,gBAAgB;CAC5B;AAED,eAAO,MAAM,sBAAsB;;;;;;;IAGjC;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;;;;;EAEH,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC"}
@@ -0,0 +1,37 @@
1
+ import { KeyringAccountStruct, BtcAccountType } from "@metamask/keyring-api";
2
+ import { object } from "@metamask/keyring-utils";
3
+ import { string, array, enums, refine, literal } from "@metamask/superstruct";
4
+ import { bech32 } from "bech32";
5
+ export const BtcP2wpkhAddressStruct = refine(string(), 'BtcP2wpkhAddressStruct', (address) => {
6
+ try {
7
+ bech32.decode(address);
8
+ }
9
+ catch (error) {
10
+ return new Error(`Could not decode P2WPKH address: ${error.message}`);
11
+ }
12
+ return true;
13
+ });
14
+ /**
15
+ * Supported Bitcoin methods.
16
+ */
17
+ export var BtcMethod;
18
+ (function (BtcMethod) {
19
+ // General transaction methods
20
+ BtcMethod["SendBitcoin"] = "sendBitcoin";
21
+ })(BtcMethod || (BtcMethod = {}));
22
+ export const BtcP2wpkhAccountStruct = object({
23
+ ...KeyringAccountStruct.schema,
24
+ /**
25
+ * Account address.
26
+ */
27
+ address: BtcP2wpkhAddressStruct,
28
+ /**
29
+ * Account type.
30
+ */
31
+ type: literal(`${BtcAccountType.P2wpkh}`),
32
+ /**
33
+ * Account supported methods.
34
+ */
35
+ methods: array(enums([`${BtcMethod.SendBitcoin}`])),
36
+ });
37
+ //# sourceMappingURL=types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../src/btc/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,8BAA8B;AAC7E,OAAO,EAAE,MAAM,EAAE,gCAAgC;AAEjD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,8BAA8B;AAC9E,OAAO,EAAE,MAAM,EAAE,eAAe;AAEhC,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAC1C,MAAM,EAAE,EACR,wBAAwB,EACxB,CAAC,OAAe,EAAE,EAAE;IAClB,IAAI,CAAC;QACH,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,IAAI,KAAK,CACd,oCAAqC,KAAe,CAAC,OAAO,EAAE,CAC/D,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CACF,CAAC;AAEF;;GAEG;AACH,MAAM,CAAN,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,8BAA8B;IAC9B,wCAA2B,CAAA;AAC7B,CAAC,EAHW,SAAS,KAAT,SAAS,QAGpB;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC;IAC3C,GAAG,oBAAoB,CAAC,MAAM;IAE9B;;OAEG;IACH,OAAO,EAAE,sBAAsB;IAE/B;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC,GAAG,cAAc,CAAC,MAAM,EAAE,CAAC;IAEzC;;OAEG;IACH,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;CACpD,CAAC,CAAC","sourcesContent":["import { KeyringAccountStruct, BtcAccountType } from '@metamask/keyring-api';\nimport { object } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport { string, array, enums, refine, literal } from '@metamask/superstruct';\nimport { bech32 } from 'bech32';\n\nexport const BtcP2wpkhAddressStruct = refine(\n string(),\n 'BtcP2wpkhAddressStruct',\n (address: string) => {\n try {\n bech32.decode(address);\n } catch (error) {\n return new Error(\n `Could not decode P2WPKH address: ${(error as Error).message}`,\n );\n }\n return true;\n },\n);\n\n/**\n * Supported Bitcoin methods.\n */\nexport enum BtcMethod {\n // General transaction methods\n SendBitcoin = 'sendBitcoin',\n}\n\nexport const BtcP2wpkhAccountStruct = object({\n ...KeyringAccountStruct.schema,\n\n /**\n * Account address.\n */\n address: BtcP2wpkhAddressStruct,\n\n /**\n * Account type.\n */\n type: literal(`${BtcAccountType.P2wpkh}`),\n\n /**\n * Account supported methods.\n */\n methods: array(enums([`${BtcMethod.SendBitcoin}`])),\n});\n\nexport type BtcP2wpkhAccount = Infer<typeof BtcP2wpkhAccountStruct>;\n"]}
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=EthKeyring.js.map
3
+ //# sourceMappingURL=EthKeyring.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EthKeyring.cjs","sourceRoot":"","sources":["../../src/eth/EthKeyring.ts"],"names":[],"mappings":"","sourcesContent":["import type { KeyringExecutionContext } from '@metamask/keyring-api';\nimport type { Json, Keyring } from '@metamask/utils';\n\nimport type {\n EthBaseTransaction,\n EthBaseUserOperation,\n EthUserOperation,\n EthUserOperationPatch,\n} from '.';\n\nexport type EthKeyring<State extends Json> = Keyring<State> & {\n /**\n * Convert a base transaction to a base UserOperation.\n *\n * @param address - Address of the sender.\n * @param transactions - Base transactions to include in the UserOperation.\n * @param context - Keyring execution context.\n * @returns A pseudo-UserOperation that can be used to construct a real.\n */\n prepareUserOperation?(\n address: string,\n transactions: EthBaseTransaction[],\n context: KeyringExecutionContext,\n ): Promise<EthBaseUserOperation>;\n\n /**\n * Patches properties of a UserOperation. Currently, only the\n * `paymasterAndData` can be patched.\n *\n * @param address - Address of the sender.\n * @param userOp - UserOperation to patch.\n * @param context - Keyring execution context.\n * @returns A patch to apply to the UserOperation.\n */\n patchUserOperation?(\n address: string,\n userOp: EthUserOperation,\n context: KeyringExecutionContext,\n ): Promise<EthUserOperationPatch>;\n\n /**\n * Signs an UserOperation.\n *\n * @param address - Address of the sender.\n * @param userOp - UserOperation to sign.\n * @param context - Keyring execution context.\n * @returns The signature of the UserOperation.\n */\n signUserOperation?(\n address: string,\n userOp: EthUserOperation,\n context: KeyringExecutionContext,\n ): Promise<string>;\n};\n"]}
@@ -1,7 +1,7 @@
1
- import type { KeyringExecutionContext } from '@metamask/keyring-api';
2
- import type { Json, Keyring } from '@metamask/utils';
3
- import type { EthBaseTransaction, EthBaseUserOperation, EthUserOperation, EthUserOperationPatch } from '../../eth';
4
- export declare type EthKeyring<State extends Json> = Keyring<State> & {
1
+ import type { KeyringExecutionContext } from "@metamask/keyring-api";
2
+ import type { Json, Keyring } from "@metamask/utils";
3
+ import type { EthBaseTransaction, EthBaseUserOperation, EthUserOperation, EthUserOperationPatch } from "./index.cjs";
4
+ export type EthKeyring<State extends Json> = Keyring<State> & {
5
5
  /**
6
6
  * Convert a base transaction to a base UserOperation.
7
7
  *
@@ -31,3 +31,4 @@ export declare type EthKeyring<State extends Json> = Keyring<State> & {
31
31
  */
32
32
  signUserOperation?(address: string, userOp: EthUserOperation, context: KeyringExecutionContext): Promise<string>;
33
33
  };
34
+ //# sourceMappingURL=EthKeyring.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EthKeyring.d.cts","sourceRoot":"","sources":["../../src/eth/EthKeyring.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,8BAA8B;AACrE,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,wBAAwB;AAErD,OAAO,KAAK,EACV,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EAChB,qBAAqB,EACtB,oBAAU;AAEX,MAAM,MAAM,UAAU,CAAC,KAAK,SAAS,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,GAAG;IAC5D;;;;;;;OAOG;IACH,oBAAoB,CAAC,CACnB,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,kBAAkB,EAAE,EAClC,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAEjC;;;;;;;;OAQG;IACH,kBAAkB,CAAC,CACjB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,gBAAgB,EACxB,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAElC;;;;;;;OAOG;IACH,iBAAiB,CAAC,CAChB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,gBAAgB,EACxB,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,MAAM,CAAC,CAAC;CACpB,CAAC"}
@@ -0,0 +1,34 @@
1
+ import type { KeyringExecutionContext } from "@metamask/keyring-api";
2
+ import type { Json, Keyring } from "@metamask/utils";
3
+ import type { EthBaseTransaction, EthBaseUserOperation, EthUserOperation, EthUserOperationPatch } from "./index.mjs";
4
+ export type EthKeyring<State extends Json> = Keyring<State> & {
5
+ /**
6
+ * Convert a base transaction to a base UserOperation.
7
+ *
8
+ * @param address - Address of the sender.
9
+ * @param transactions - Base transactions to include in the UserOperation.
10
+ * @param context - Keyring execution context.
11
+ * @returns A pseudo-UserOperation that can be used to construct a real.
12
+ */
13
+ prepareUserOperation?(address: string, transactions: EthBaseTransaction[], context: KeyringExecutionContext): Promise<EthBaseUserOperation>;
14
+ /**
15
+ * Patches properties of a UserOperation. Currently, only the
16
+ * `paymasterAndData` can be patched.
17
+ *
18
+ * @param address - Address of the sender.
19
+ * @param userOp - UserOperation to patch.
20
+ * @param context - Keyring execution context.
21
+ * @returns A patch to apply to the UserOperation.
22
+ */
23
+ patchUserOperation?(address: string, userOp: EthUserOperation, context: KeyringExecutionContext): Promise<EthUserOperationPatch>;
24
+ /**
25
+ * Signs an UserOperation.
26
+ *
27
+ * @param address - Address of the sender.
28
+ * @param userOp - UserOperation to sign.
29
+ * @param context - Keyring execution context.
30
+ * @returns The signature of the UserOperation.
31
+ */
32
+ signUserOperation?(address: string, userOp: EthUserOperation, context: KeyringExecutionContext): Promise<string>;
33
+ };
34
+ //# sourceMappingURL=EthKeyring.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EthKeyring.d.mts","sourceRoot":"","sources":["../../src/eth/EthKeyring.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,8BAA8B;AACrE,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,wBAAwB;AAErD,OAAO,KAAK,EACV,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EAChB,qBAAqB,EACtB,oBAAU;AAEX,MAAM,MAAM,UAAU,CAAC,KAAK,SAAS,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,GAAG;IAC5D;;;;;;;OAOG;IACH,oBAAoB,CAAC,CACnB,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,kBAAkB,EAAE,EAClC,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAEjC;;;;;;;;OAQG;IACH,kBAAkB,CAAC,CACjB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,gBAAgB,EACxB,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAElC;;;;;;;OAOG;IACH,iBAAiB,CAAC,CAChB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,gBAAgB,EACxB,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,MAAM,CAAC,CAAC;CACpB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=EthKeyring.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EthKeyring.mjs","sourceRoot":"","sources":["../../src/eth/EthKeyring.ts"],"names":[],"mappings":"","sourcesContent":["import type { KeyringExecutionContext } from '@metamask/keyring-api';\nimport type { Json, Keyring } from '@metamask/utils';\n\nimport type {\n EthBaseTransaction,\n EthBaseUserOperation,\n EthUserOperation,\n EthUserOperationPatch,\n} from '.';\n\nexport type EthKeyring<State extends Json> = Keyring<State> & {\n /**\n * Convert a base transaction to a base UserOperation.\n *\n * @param address - Address of the sender.\n * @param transactions - Base transactions to include in the UserOperation.\n * @param context - Keyring execution context.\n * @returns A pseudo-UserOperation that can be used to construct a real.\n */\n prepareUserOperation?(\n address: string,\n transactions: EthBaseTransaction[],\n context: KeyringExecutionContext,\n ): Promise<EthBaseUserOperation>;\n\n /**\n * Patches properties of a UserOperation. Currently, only the\n * `paymasterAndData` can be patched.\n *\n * @param address - Address of the sender.\n * @param userOp - UserOperation to patch.\n * @param context - Keyring execution context.\n * @returns A patch to apply to the UserOperation.\n */\n patchUserOperation?(\n address: string,\n userOp: EthUserOperation,\n context: KeyringExecutionContext,\n ): Promise<EthUserOperationPatch>;\n\n /**\n * Signs an UserOperation.\n *\n * @param address - Address of the sender.\n * @param userOp - UserOperation to sign.\n * @param context - Keyring execution context.\n * @returns The signature of the UserOperation.\n */\n signUserOperation?(\n address: string,\n userOp: EthUserOperation,\n context: KeyringExecutionContext,\n ): Promise<string>;\n};\n"]}
@@ -14,5 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./types"), exports);
18
- //# sourceMappingURL=index.js.map
17
+ __exportStar(require("./types.cjs"), exports);
18
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/eth/erc4337/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAAwB","sourcesContent":["export * from './types';\n"]}
@@ -0,0 +1,2 @@
1
+ export * from "./types.cjs";
2
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/eth/erc4337/index.ts"],"names":[],"mappings":"AAAA,4BAAwB"}
@@ -0,0 +1,2 @@
1
+ export * from "./types.mjs";
2
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/eth/erc4337/index.ts"],"names":[],"mappings":"AAAA,4BAAwB"}
@@ -0,0 +1,2 @@
1
+ export * from "./types.mjs";
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/eth/erc4337/index.ts"],"names":[],"mappings":"AAAA,4BAAwB","sourcesContent":["export * from './types';\n"]}
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EthUserOperationPatchStruct = exports.EthBaseUserOperationStruct = exports.EthBaseTransactionStruct = exports.EthUserOperationStruct = void 0;
4
4
  const keyring_utils_1 = require("@metamask/keyring-utils");
5
- const types_1 = require("../types");
5
+ const types_1 = require("../types.cjs");
6
6
  /**
7
7
  * Struct of a UserOperation as defined by ERC-4337.
8
8
  *
@@ -58,4 +58,4 @@ exports.EthUserOperationPatchStruct = (0, keyring_utils_1.object)({
58
58
  verificationGasLimit: (0, keyring_utils_1.exactOptional)(types_1.EthUint256Struct),
59
59
  preVerificationGas: (0, keyring_utils_1.exactOptional)(types_1.EthUint256Struct),
60
60
  });
61
- //# sourceMappingURL=types.js.map
61
+ //# sourceMappingURL=types.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../../src/eth/erc4337/types.ts"],"names":[],"mappings":";;;AAAA,2DAA2E;AAG3E,wCAA8E;AAE9E;;;;GAIG;AACU,QAAA,sBAAsB,GAAG,IAAA,sBAAM,EAAC;IAC3C,MAAM,EAAE,wBAAgB;IACxB,KAAK,EAAE,wBAAgB;IACvB,QAAQ,EAAE,sBAAc;IACxB,QAAQ,EAAE,sBAAc;IACxB,YAAY,EAAE,wBAAgB;IAC9B,oBAAoB,EAAE,wBAAgB;IACtC,kBAAkB,EAAE,wBAAgB;IACpC,YAAY,EAAE,wBAAgB;IAC9B,oBAAoB,EAAE,wBAAgB;IACtC,gBAAgB,EAAE,sBAAc;IAChC,SAAS,EAAE,sBAAc;CAC1B,CAAC,CAAC;AAIH;;;GAGG;AACU,QAAA,wBAAwB,GAAG,IAAA,sBAAM,EAAC;IAC7C;;OAEG;IACH,EAAE,EAAE,wBAAgB;IAEpB;;OAEG;IACH,KAAK,EAAE,wBAAgB;IAEvB;;OAEG;IACH,IAAI,EAAE,sBAAc;CACrB,CAAC,CAAC;AAIU,QAAA,0BAA0B,GAAG,IAAA,sBAAM,EAAC;IAC/C,KAAK,EAAE,wBAAgB;IACvB,QAAQ,EAAE,sBAAc;IACxB,QAAQ,EAAE,sBAAc;IACxB,SAAS,EAAE,IAAA,6BAAa,EACtB,IAAA,sBAAM,EAAC;QACL,YAAY,EAAE,wBAAgB;QAC9B,oBAAoB,EAAE,wBAAgB;QACtC,kBAAkB,EAAE,wBAAgB;KACrC,CAAC,CACH;IACD,qBAAqB,EAAE,sBAAc;IACrC,cAAc,EAAE,sBAAc;IAC9B,UAAU,EAAE,yBAAS;CACtB,CAAC,CAAC;AAIU,QAAA,2BAA2B,GAAG,IAAA,sBAAM,EAAC;IAChD,gBAAgB,EAAE,sBAAc;IAChC,YAAY,EAAE,IAAA,6BAAa,EAAC,wBAAgB,CAAC;IAC7C,oBAAoB,EAAE,IAAA,6BAAa,EAAC,wBAAgB,CAAC;IACrD,kBAAkB,EAAE,IAAA,6BAAa,EAAC,wBAAgB,CAAC;CACpD,CAAC,CAAC","sourcesContent":["import { exactOptional, object, UrlStruct } from '@metamask/keyring-utils';\nimport { type Infer } from '@metamask/superstruct';\n\nimport { EthAddressStruct, EthBytesStruct, EthUint256Struct } from '../types';\n\n/**\n * Struct of a UserOperation as defined by ERC-4337.\n *\n * @see https://eips.ethereum.org/EIPS/eip-4337#definitions\n */\nexport const EthUserOperationStruct = object({\n sender: EthAddressStruct,\n nonce: EthUint256Struct,\n initCode: EthBytesStruct,\n callData: EthBytesStruct,\n callGasLimit: EthUint256Struct,\n verificationGasLimit: EthUint256Struct,\n preVerificationGas: EthUint256Struct,\n maxFeePerGas: EthUint256Struct,\n maxPriorityFeePerGas: EthUint256Struct,\n paymasterAndData: EthBytesStruct,\n signature: EthBytesStruct,\n});\n\nexport type EthUserOperation = Infer<typeof EthUserOperationStruct>;\n\n/**\n * Struct containing the most basic transaction information required to\n * construct a UserOperation.\n */\nexport const EthBaseTransactionStruct = object({\n /**\n * Address of the transaction recipient.\n */\n to: EthAddressStruct,\n\n /**\n * Amount of wei to transfer to the recipient.\n */\n value: EthUint256Struct,\n\n /**\n * Data to pass to the recipient.\n */\n data: EthBytesStruct,\n});\n\nexport type EthBaseTransaction = Infer<typeof EthBaseTransactionStruct>;\n\nexport const EthBaseUserOperationStruct = object({\n nonce: EthUint256Struct,\n initCode: EthBytesStruct,\n callData: EthBytesStruct,\n gasLimits: exactOptional(\n object({\n callGasLimit: EthUint256Struct,\n verificationGasLimit: EthUint256Struct,\n preVerificationGas: EthUint256Struct,\n }),\n ),\n dummyPaymasterAndData: EthBytesStruct,\n dummySignature: EthBytesStruct,\n bundlerUrl: UrlStruct,\n});\n\nexport type EthBaseUserOperation = Infer<typeof EthBaseUserOperationStruct>;\n\nexport const EthUserOperationPatchStruct = object({\n paymasterAndData: EthBytesStruct,\n callGasLimit: exactOptional(EthUint256Struct),\n verificationGasLimit: exactOptional(EthUint256Struct),\n preVerificationGas: exactOptional(EthUint256Struct),\n});\n\nexport type EthUserOperationPatch = Infer<typeof EthUserOperationPatchStruct>;\n"]}
@@ -1,4 +1,4 @@
1
- import { type Infer } from '@metamask/superstruct';
1
+ import { type Infer } from "@metamask/superstruct";
2
2
  /**
3
3
  * Struct of a UserOperation as defined by ERC-4337.
4
4
  *
@@ -29,15 +29,15 @@ export declare const EthUserOperationStruct: import("@metamask/superstruct").Str
29
29
  paymasterAndData: import("@metamask/superstruct").Struct<string, null>;
30
30
  signature: import("@metamask/superstruct").Struct<string, null>;
31
31
  }>;
32
- export declare type EthUserOperation = Infer<typeof EthUserOperationStruct>;
32
+ export type EthUserOperation = Infer<typeof EthUserOperationStruct>;
33
33
  /**
34
34
  * Struct containing the most basic transaction information required to
35
35
  * construct a UserOperation.
36
36
  */
37
37
  export declare const EthBaseTransactionStruct: import("@metamask/superstruct").Struct<{
38
38
  data: string;
39
- to: string;
40
39
  value: string;
40
+ to: string;
41
41
  }, {
42
42
  /**
43
43
  * Address of the transaction recipient.
@@ -52,7 +52,7 @@ export declare const EthBaseTransactionStruct: import("@metamask/superstruct").S
52
52
  */
53
53
  data: import("@metamask/superstruct").Struct<string, null>;
54
54
  }>;
55
- export declare type EthBaseTransaction = Infer<typeof EthBaseTransactionStruct>;
55
+ export type EthBaseTransaction = Infer<typeof EthBaseTransactionStruct>;
56
56
  export declare const EthBaseUserOperationStruct: import("@metamask/superstruct").Struct<{
57
57
  nonce: string;
58
58
  initCode: string;
@@ -82,7 +82,7 @@ export declare const EthBaseUserOperationStruct: import("@metamask/superstruct")
82
82
  dummySignature: import("@metamask/superstruct").Struct<string, null>;
83
83
  bundlerUrl: import("@metamask/superstruct").Struct<string, null>;
84
84
  }>;
85
- export declare type EthBaseUserOperation = Infer<typeof EthBaseUserOperationStruct>;
85
+ export type EthBaseUserOperation = Infer<typeof EthBaseUserOperationStruct>;
86
86
  export declare const EthUserOperationPatchStruct: import("@metamask/superstruct").Struct<{
87
87
  paymasterAndData: string;
88
88
  callGasLimit?: string;
@@ -94,4 +94,5 @@ export declare const EthUserOperationPatchStruct: import("@metamask/superstruct"
94
94
  verificationGasLimit: import("@metamask/superstruct").Struct<string | import("@metamask/keyring-utils").ExactOptionalTag, null>;
95
95
  preVerificationGas: import("@metamask/superstruct").Struct<string | import("@metamask/keyring-utils").ExactOptionalTag, null>;
96
96
  }>;
97
- export declare type EthUserOperationPatch = Infer<typeof EthUserOperationPatchStruct>;
97
+ export type EthUserOperationPatch = Infer<typeof EthUserOperationPatchStruct>;
98
+ //# sourceMappingURL=types.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../../src/eth/erc4337/types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,KAAK,EAAE,8BAA8B;AAInD;;;;GAIG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;EAYjC,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEpE;;;GAGG;AACH,eAAO,MAAM,wBAAwB;;;;;IACnC;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;EAEH,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAExE,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAcrC,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE5E,eAAO,MAAM,2BAA2B;;;;;;;;;;EAKtC,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC"}
@@ -0,0 +1,98 @@
1
+ import { type Infer } from "@metamask/superstruct";
2
+ /**
3
+ * Struct of a UserOperation as defined by ERC-4337.
4
+ *
5
+ * @see https://eips.ethereum.org/EIPS/eip-4337#definitions
6
+ */
7
+ export declare const EthUserOperationStruct: import("@metamask/superstruct").Struct<{
8
+ sender: string;
9
+ nonce: string;
10
+ initCode: string;
11
+ callData: string;
12
+ callGasLimit: string;
13
+ verificationGasLimit: string;
14
+ preVerificationGas: string;
15
+ maxFeePerGas: string;
16
+ maxPriorityFeePerGas: string;
17
+ paymasterAndData: string;
18
+ signature: string;
19
+ }, {
20
+ sender: import("@metamask/superstruct").Struct<string, null>;
21
+ nonce: import("@metamask/superstruct").Struct<string, null>;
22
+ initCode: import("@metamask/superstruct").Struct<string, null>;
23
+ callData: import("@metamask/superstruct").Struct<string, null>;
24
+ callGasLimit: import("@metamask/superstruct").Struct<string, null>;
25
+ verificationGasLimit: import("@metamask/superstruct").Struct<string, null>;
26
+ preVerificationGas: import("@metamask/superstruct").Struct<string, null>;
27
+ maxFeePerGas: import("@metamask/superstruct").Struct<string, null>;
28
+ maxPriorityFeePerGas: import("@metamask/superstruct").Struct<string, null>;
29
+ paymasterAndData: import("@metamask/superstruct").Struct<string, null>;
30
+ signature: import("@metamask/superstruct").Struct<string, null>;
31
+ }>;
32
+ export type EthUserOperation = Infer<typeof EthUserOperationStruct>;
33
+ /**
34
+ * Struct containing the most basic transaction information required to
35
+ * construct a UserOperation.
36
+ */
37
+ export declare const EthBaseTransactionStruct: import("@metamask/superstruct").Struct<{
38
+ data: string;
39
+ value: string;
40
+ to: string;
41
+ }, {
42
+ /**
43
+ * Address of the transaction recipient.
44
+ */
45
+ to: import("@metamask/superstruct").Struct<string, null>;
46
+ /**
47
+ * Amount of wei to transfer to the recipient.
48
+ */
49
+ value: import("@metamask/superstruct").Struct<string, null>;
50
+ /**
51
+ * Data to pass to the recipient.
52
+ */
53
+ data: import("@metamask/superstruct").Struct<string, null>;
54
+ }>;
55
+ export type EthBaseTransaction = Infer<typeof EthBaseTransactionStruct>;
56
+ export declare const EthBaseUserOperationStruct: import("@metamask/superstruct").Struct<{
57
+ nonce: string;
58
+ initCode: string;
59
+ callData: string;
60
+ dummyPaymasterAndData: string;
61
+ dummySignature: string;
62
+ bundlerUrl: string;
63
+ gasLimits?: {
64
+ callGasLimit: string;
65
+ verificationGasLimit: string;
66
+ preVerificationGas: string;
67
+ };
68
+ }, {
69
+ nonce: import("@metamask/superstruct").Struct<string, null>;
70
+ initCode: import("@metamask/superstruct").Struct<string, null>;
71
+ callData: import("@metamask/superstruct").Struct<string, null>;
72
+ gasLimits: import("@metamask/superstruct").Struct<import("@metamask/keyring-utils").ExactOptionalTag | {
73
+ callGasLimit: string;
74
+ verificationGasLimit: string;
75
+ preVerificationGas: string;
76
+ }, {
77
+ callGasLimit: import("@metamask/superstruct").Struct<string, null>;
78
+ verificationGasLimit: import("@metamask/superstruct").Struct<string, null>;
79
+ preVerificationGas: import("@metamask/superstruct").Struct<string, null>;
80
+ }>;
81
+ dummyPaymasterAndData: import("@metamask/superstruct").Struct<string, null>;
82
+ dummySignature: import("@metamask/superstruct").Struct<string, null>;
83
+ bundlerUrl: import("@metamask/superstruct").Struct<string, null>;
84
+ }>;
85
+ export type EthBaseUserOperation = Infer<typeof EthBaseUserOperationStruct>;
86
+ export declare const EthUserOperationPatchStruct: import("@metamask/superstruct").Struct<{
87
+ paymasterAndData: string;
88
+ callGasLimit?: string;
89
+ verificationGasLimit?: string;
90
+ preVerificationGas?: string;
91
+ }, {
92
+ paymasterAndData: import("@metamask/superstruct").Struct<string, null>;
93
+ callGasLimit: import("@metamask/superstruct").Struct<string | import("@metamask/keyring-utils").ExactOptionalTag, null>;
94
+ verificationGasLimit: import("@metamask/superstruct").Struct<string | import("@metamask/keyring-utils").ExactOptionalTag, null>;
95
+ preVerificationGas: import("@metamask/superstruct").Struct<string | import("@metamask/keyring-utils").ExactOptionalTag, null>;
96
+ }>;
97
+ export type EthUserOperationPatch = Infer<typeof EthUserOperationPatchStruct>;
98
+ //# sourceMappingURL=types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../../src/eth/erc4337/types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,KAAK,EAAE,8BAA8B;AAInD;;;;GAIG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;EAYjC,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEpE;;;GAGG;AACH,eAAO,MAAM,wBAAwB;;;;;IACnC;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;EAEH,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAExE,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAcrC,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE5E,eAAO,MAAM,2BAA2B;;;;;;;;;;EAKtC,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC"}
@@ -0,0 +1,58 @@
1
+ import { exactOptional, object, UrlStruct } from "@metamask/keyring-utils";
2
+ import { EthAddressStruct, EthBytesStruct, EthUint256Struct } from "../types.mjs";
3
+ /**
4
+ * Struct of a UserOperation as defined by ERC-4337.
5
+ *
6
+ * @see https://eips.ethereum.org/EIPS/eip-4337#definitions
7
+ */
8
+ export const EthUserOperationStruct = object({
9
+ sender: EthAddressStruct,
10
+ nonce: EthUint256Struct,
11
+ initCode: EthBytesStruct,
12
+ callData: EthBytesStruct,
13
+ callGasLimit: EthUint256Struct,
14
+ verificationGasLimit: EthUint256Struct,
15
+ preVerificationGas: EthUint256Struct,
16
+ maxFeePerGas: EthUint256Struct,
17
+ maxPriorityFeePerGas: EthUint256Struct,
18
+ paymasterAndData: EthBytesStruct,
19
+ signature: EthBytesStruct,
20
+ });
21
+ /**
22
+ * Struct containing the most basic transaction information required to
23
+ * construct a UserOperation.
24
+ */
25
+ export const EthBaseTransactionStruct = object({
26
+ /**
27
+ * Address of the transaction recipient.
28
+ */
29
+ to: EthAddressStruct,
30
+ /**
31
+ * Amount of wei to transfer to the recipient.
32
+ */
33
+ value: EthUint256Struct,
34
+ /**
35
+ * Data to pass to the recipient.
36
+ */
37
+ data: EthBytesStruct,
38
+ });
39
+ export const EthBaseUserOperationStruct = object({
40
+ nonce: EthUint256Struct,
41
+ initCode: EthBytesStruct,
42
+ callData: EthBytesStruct,
43
+ gasLimits: exactOptional(object({
44
+ callGasLimit: EthUint256Struct,
45
+ verificationGasLimit: EthUint256Struct,
46
+ preVerificationGas: EthUint256Struct,
47
+ })),
48
+ dummyPaymasterAndData: EthBytesStruct,
49
+ dummySignature: EthBytesStruct,
50
+ bundlerUrl: UrlStruct,
51
+ });
52
+ export const EthUserOperationPatchStruct = object({
53
+ paymasterAndData: EthBytesStruct,
54
+ callGasLimit: exactOptional(EthUint256Struct),
55
+ verificationGasLimit: exactOptional(EthUint256Struct),
56
+ preVerificationGas: exactOptional(EthUint256Struct),
57
+ });
58
+ //# sourceMappingURL=types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../../src/eth/erc4337/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,SAAS,EAAE,gCAAgC;AAG3E,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,gBAAgB,EAAE,qBAAiB;AAE9E;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC;IAC3C,MAAM,EAAE,gBAAgB;IACxB,KAAK,EAAE,gBAAgB;IACvB,QAAQ,EAAE,cAAc;IACxB,QAAQ,EAAE,cAAc;IACxB,YAAY,EAAE,gBAAgB;IAC9B,oBAAoB,EAAE,gBAAgB;IACtC,kBAAkB,EAAE,gBAAgB;IACpC,YAAY,EAAE,gBAAgB;IAC9B,oBAAoB,EAAE,gBAAgB;IACtC,gBAAgB,EAAE,cAAc;IAChC,SAAS,EAAE,cAAc;CAC1B,CAAC,CAAC;AAIH;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC;IAC7C;;OAEG;IACH,EAAE,EAAE,gBAAgB;IAEpB;;OAEG;IACH,KAAK,EAAE,gBAAgB;IAEvB;;OAEG;IACH,IAAI,EAAE,cAAc;CACrB,CAAC,CAAC;AAIH,MAAM,CAAC,MAAM,0BAA0B,GAAG,MAAM,CAAC;IAC/C,KAAK,EAAE,gBAAgB;IACvB,QAAQ,EAAE,cAAc;IACxB,QAAQ,EAAE,cAAc;IACxB,SAAS,EAAE,aAAa,CACtB,MAAM,CAAC;QACL,YAAY,EAAE,gBAAgB;QAC9B,oBAAoB,EAAE,gBAAgB;QACtC,kBAAkB,EAAE,gBAAgB;KACrC,CAAC,CACH;IACD,qBAAqB,EAAE,cAAc;IACrC,cAAc,EAAE,cAAc;IAC9B,UAAU,EAAE,SAAS;CACtB,CAAC,CAAC;AAIH,MAAM,CAAC,MAAM,2BAA2B,GAAG,MAAM,CAAC;IAChD,gBAAgB,EAAE,cAAc;IAChC,YAAY,EAAE,aAAa,CAAC,gBAAgB,CAAC;IAC7C,oBAAoB,EAAE,aAAa,CAAC,gBAAgB,CAAC;IACrD,kBAAkB,EAAE,aAAa,CAAC,gBAAgB,CAAC;CACpD,CAAC,CAAC","sourcesContent":["import { exactOptional, object, UrlStruct } from '@metamask/keyring-utils';\nimport { type Infer } from '@metamask/superstruct';\n\nimport { EthAddressStruct, EthBytesStruct, EthUint256Struct } from '../types';\n\n/**\n * Struct of a UserOperation as defined by ERC-4337.\n *\n * @see https://eips.ethereum.org/EIPS/eip-4337#definitions\n */\nexport const EthUserOperationStruct = object({\n sender: EthAddressStruct,\n nonce: EthUint256Struct,\n initCode: EthBytesStruct,\n callData: EthBytesStruct,\n callGasLimit: EthUint256Struct,\n verificationGasLimit: EthUint256Struct,\n preVerificationGas: EthUint256Struct,\n maxFeePerGas: EthUint256Struct,\n maxPriorityFeePerGas: EthUint256Struct,\n paymasterAndData: EthBytesStruct,\n signature: EthBytesStruct,\n});\n\nexport type EthUserOperation = Infer<typeof EthUserOperationStruct>;\n\n/**\n * Struct containing the most basic transaction information required to\n * construct a UserOperation.\n */\nexport const EthBaseTransactionStruct = object({\n /**\n * Address of the transaction recipient.\n */\n to: EthAddressStruct,\n\n /**\n * Amount of wei to transfer to the recipient.\n */\n value: EthUint256Struct,\n\n /**\n * Data to pass to the recipient.\n */\n data: EthBytesStruct,\n});\n\nexport type EthBaseTransaction = Infer<typeof EthBaseTransactionStruct>;\n\nexport const EthBaseUserOperationStruct = object({\n nonce: EthUint256Struct,\n initCode: EthBytesStruct,\n callData: EthBytesStruct,\n gasLimits: exactOptional(\n object({\n callGasLimit: EthUint256Struct,\n verificationGasLimit: EthUint256Struct,\n preVerificationGas: EthUint256Struct,\n }),\n ),\n dummyPaymasterAndData: EthBytesStruct,\n dummySignature: EthBytesStruct,\n bundlerUrl: UrlStruct,\n});\n\nexport type EthBaseUserOperation = Infer<typeof EthBaseUserOperationStruct>;\n\nexport const EthUserOperationPatchStruct = object({\n paymasterAndData: EthBytesStruct,\n callGasLimit: exactOptional(EthUint256Struct),\n verificationGasLimit: exactOptional(EthUint256Struct),\n preVerificationGas: exactOptional(EthUint256Struct),\n});\n\nexport type EthUserOperationPatch = Infer<typeof EthUserOperationPatchStruct>;\n"]}
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./internal"), exports);
18
- __exportStar(require("./btc"), exports);
19
- __exportStar(require("./eth"), exports);
20
- //# sourceMappingURL=index.js.map
17
+ __exportStar(require("./erc4337/index.cjs"), exports);
18
+ __exportStar(require("./types.cjs"), exports);
19
+ __exportStar(require("./utils.cjs"), exports);
20
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../src/eth/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAA0B;AAC1B,8CAAwB;AACxB,8CAAwB","sourcesContent":["export * from './erc4337';\nexport * from './types';\nexport * from './utils';\nexport type * from './EthKeyring';\n"]}
@@ -0,0 +1,5 @@
1
+ export * from "./erc4337/index.cjs";
2
+ export * from "./types.cjs";
3
+ export * from "./utils.cjs";
4
+ export type * from "./EthKeyring.cjs";
5
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../src/eth/index.ts"],"names":[],"mappings":"AAAA,oCAA0B;AAC1B,4BAAwB;AACxB,4BAAwB;AACxB,sCAAkC"}
@@ -0,0 +1,5 @@
1
+ export * from "./erc4337/index.mjs";
2
+ export * from "./types.mjs";
3
+ export * from "./utils.mjs";
4
+ export type * from "./EthKeyring.mjs";
5
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/eth/index.ts"],"names":[],"mappings":"AAAA,oCAA0B;AAC1B,4BAAwB;AACxB,4BAAwB;AACxB,sCAAkC"}
@@ -0,0 +1,4 @@
1
+ export * from "./erc4337/index.mjs";
2
+ export * from "./types.mjs";
3
+ export * from "./utils.mjs";
4
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/eth/index.ts"],"names":[],"mappings":"AAAA,oCAA0B;AAC1B,4BAAwB;AACxB,4BAAwB","sourcesContent":["export * from './erc4337';\nexport * from './types';\nexport * from './utils';\nexport type * from './EthKeyring';\n"]}
@@ -23,7 +23,7 @@ var EthMethod;
23
23
  EthMethod["PrepareUserOperation"] = "eth_prepareUserOperation";
24
24
  EthMethod["PatchUserOperation"] = "eth_patchUserOperation";
25
25
  EthMethod["SignUserOperation"] = "eth_signUserOperation";
26
- })(EthMethod = exports.EthMethod || (exports.EthMethod = {}));
26
+ })(EthMethod || (exports.EthMethod = EthMethod = {}));
27
27
  exports.EthEoaAccountStruct = (0, keyring_utils_1.object)({
28
28
  ...keyring_api_1.KeyringAccountStruct.schema,
29
29
  /**
@@ -70,4 +70,4 @@ exports.EthErc4337AccountStruct = (0, keyring_utils_1.object)({
70
70
  `${EthMethod.SignUserOperation}`,
71
71
  ])),
72
72
  });
73
- //# sourceMappingURL=types.js.map
73
+ //# sourceMappingURL=types.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.cjs","sourceRoot":"","sources":["../../src/eth/types.ts"],"names":[],"mappings":";;;AAAA,uDAA6E;AAC7E,2DAAgE;AAEhE,uDAA8D;AAEjD,QAAA,cAAc,GAAG,IAAA,6BAAa,EAAC,UAAU,EAAE,iBAAiB,CAAC,CAAC;AAE9D,QAAA,gBAAgB,GAAG,IAAA,6BAAa,EAC3C,YAAY,EACZ,oBAAoB,CACrB,CAAC;AAEW,QAAA,gBAAgB,GAAG,IAAA,6BAAa,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,kCAAoB,CAAC,MAAM;IAE9B;;OAEG;IACH,OAAO,EAAE,wBAAgB;IAEzB;;OAEG;IACH,IAAI,EAAE,IAAA,qBAAO,EAAC,GAAG,4BAAc,CAAC,GAAG,EAAE,CAAC;IAEtC;;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,kCAAoB,CAAC,MAAM;IAE9B;;OAEG;IACH,OAAO,EAAE,wBAAgB;IAEzB;;OAEG;IACH,IAAI,EAAE,IAAA,qBAAO,EAAC,GAAG,4BAAc,CAAC,OAAO,EAAE,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 { EthAccountType, KeyringAccountStruct } from '@metamask/keyring-api';\nimport { object, definePattern } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport { array, enums, literal } from '@metamask/superstruct';\n\nexport const EthBytesStruct = definePattern('EthBytes', /^0x[0-9a-f]*$/iu);\n\nexport const EthAddressStruct = definePattern(\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 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 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,4 +1,4 @@
1
- import type { Infer } from '@metamask/superstruct';
1
+ import type { Infer } from "@metamask/superstruct";
2
2
  export declare const EthBytesStruct: import("@metamask/superstruct").Struct<string, null>;
3
3
  export declare const EthAddressStruct: import("@metamask/superstruct").Struct<string, null>;
4
4
  export declare const EthUint256Struct: import("@metamask/superstruct").Struct<string, null>;
@@ -19,8 +19,8 @@ export declare enum EthMethod {
19
19
  export declare const EthEoaAccountStruct: import("@metamask/superstruct").Struct<{
20
20
  id: string;
21
21
  options: Record<string, import("@metamask/utils").Json>;
22
- address: string;
23
22
  type: "eip155:eoa";
23
+ address: string;
24
24
  methods: ("personal_sign" | "eth_sign" | "eth_signTransaction" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4")[];
25
25
  }, {
26
26
  /**
@@ -45,12 +45,12 @@ export declare const EthEoaAccountStruct: import("@metamask/superstruct").Struct
45
45
  id: import("@metamask/superstruct").Struct<string, null>;
46
46
  options: import("@metamask/superstruct").Struct<Record<string, import("@metamask/utils").Json>, null>;
47
47
  }>;
48
- export declare type EthEoaAccount = Infer<typeof EthEoaAccountStruct>;
48
+ export type EthEoaAccount = Infer<typeof EthEoaAccountStruct>;
49
49
  export declare const EthErc4337AccountStruct: import("@metamask/superstruct").Struct<{
50
50
  id: string;
51
51
  options: Record<string, import("@metamask/utils").Json>;
52
- address: string;
53
52
  type: "eip155:erc4337";
53
+ address: string;
54
54
  methods: ("personal_sign" | "eth_sign" | "eth_signTypedData_v1" | "eth_signTypedData_v3" | "eth_signTypedData_v4" | "eth_prepareUserOperation" | "eth_patchUserOperation" | "eth_signUserOperation")[];
55
55
  }, {
56
56
  /**
@@ -77,4 +77,5 @@ export declare const EthErc4337AccountStruct: import("@metamask/superstruct").St
77
77
  id: import("@metamask/superstruct").Struct<string, null>;
78
78
  options: import("@metamask/superstruct").Struct<Record<string, import("@metamask/utils").Json>, null>;
79
79
  }>;
80
- export declare type EthErc4337Account = Infer<typeof EthErc4337AccountStruct>;
80
+ export type EthErc4337Account = Infer<typeof EthErc4337AccountStruct>;
81
+ //# sourceMappingURL=types.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../src/eth/types.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAGnD,eAAO,MAAM,cAAc,sDAA+C,CAAC;AAE3E,eAAO,MAAM,gBAAgB,sDAG5B,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;;;;;;;;;;;EAWH,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAE9D,eAAO,MAAM,uBAAuB;;;;;;;IAGlC;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;;;;;;;;;;;;EAaH,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC"}