@alchemy/smart-accounts 0.0.0-alpha.2 → 0.0.0-alpha.21

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 (147) hide show
  1. package/dist/esm/index.d.ts +4 -3
  2. package/dist/esm/index.js +3 -3
  3. package/dist/esm/index.js.map +1 -1
  4. package/dist/esm/light-account/accounts/account.d.ts +9 -4
  5. package/dist/esm/light-account/accounts/account.js +29 -18
  6. package/dist/esm/light-account/accounts/account.js.map +1 -1
  7. package/dist/esm/light-account/accounts/base.d.ts +4 -4
  8. package/dist/esm/light-account/accounts/base.js +51 -24
  9. package/dist/esm/light-account/accounts/base.js.map +1 -1
  10. package/dist/esm/light-account/accounts/multi-owner-account.d.ts +9 -4
  11. package/dist/esm/light-account/accounts/multi-owner-account.js +23 -14
  12. package/dist/esm/light-account/accounts/multi-owner-account.js.map +1 -1
  13. package/dist/esm/light-account/decorators/multiOwner.js +2 -1
  14. package/dist/esm/light-account/decorators/multiOwner.js.map +1 -1
  15. package/dist/esm/light-account/decorators/singleOwner.js +1 -1
  16. package/dist/esm/light-account/decorators/singleOwner.js.map +1 -1
  17. package/dist/esm/light-account/lightAccountStaticImpl.d.ts +3 -1
  18. package/dist/esm/light-account/lightAccountStaticImpl.js +57 -7
  19. package/dist/esm/light-account/lightAccountStaticImpl.js.map +1 -1
  20. package/dist/esm/light-account/predictAddress.d.ts +40 -2
  21. package/dist/esm/light-account/predictAddress.js +83 -3
  22. package/dist/esm/light-account/predictAddress.js.map +1 -1
  23. package/dist/esm/light-account/registry.d.ts +3411 -1
  24. package/dist/esm/light-account/registry.js +33 -1
  25. package/dist/esm/light-account/registry.js.map +1 -1
  26. package/dist/esm/light-account/utils.js +1 -1
  27. package/dist/esm/light-account/utils.js.map +1 -1
  28. package/dist/esm/ma-v1/accounts/base.d.ts +4 -4
  29. package/dist/esm/ma-v1/accounts/base.js +1 -1
  30. package/dist/esm/ma-v1/accounts/base.js.map +1 -1
  31. package/dist/esm/ma-v1/accounts/multi-owner-account.d.ts +9 -4
  32. package/dist/esm/ma-v1/accounts/multi-owner-account.js +26 -14
  33. package/dist/esm/ma-v1/accounts/multi-owner-account.js.map +1 -1
  34. package/dist/esm/ma-v1/decorators/multiOwner.js +2 -1
  35. package/dist/esm/ma-v1/decorators/multiOwner.js.map +1 -1
  36. package/dist/esm/ma-v1/predictAddress.d.ts +20 -1
  37. package/dist/esm/ma-v1/predictAddress.js +37 -1
  38. package/dist/esm/ma-v1/predictAddress.js.map +1 -1
  39. package/dist/esm/ma-v2/accounts/account.d.ts +10 -7
  40. package/dist/esm/ma-v2/accounts/account.js +24 -43
  41. package/dist/esm/ma-v2/accounts/account.js.map +1 -1
  42. package/dist/esm/ma-v2/accounts/base.d.ts +5 -5
  43. package/dist/esm/ma-v2/accounts/base.js +18 -60
  44. package/dist/esm/ma-v2/accounts/base.js.map +1 -1
  45. package/dist/esm/ma-v2/mav2StaticImpl.d.ts +1 -15
  46. package/dist/esm/ma-v2/mav2StaticImpl.js +0 -33
  47. package/dist/esm/ma-v2/mav2StaticImpl.js.map +1 -1
  48. package/dist/esm/ma-v2/predictAddress.d.ts +22 -6
  49. package/dist/esm/ma-v2/predictAddress.js +46 -12
  50. package/dist/esm/ma-v2/predictAddress.js.map +1 -1
  51. package/dist/esm/ma-v2/utils/account.d.ts +0 -3
  52. package/dist/esm/ma-v2/utils/account.js +2 -4
  53. package/dist/esm/ma-v2/utils/account.js.map +1 -1
  54. package/dist/esm/ma-v2/utils/signature.d.ts +1 -12
  55. package/dist/esm/ma-v2/utils/signature.js +1 -34
  56. package/dist/esm/ma-v2/utils/signature.js.map +1 -1
  57. package/dist/esm/types.d.ts +8 -1
  58. package/dist/esm/types.js.map +1 -1
  59. package/dist/esm/utils.d.ts +32 -2
  60. package/dist/esm/utils.js +75 -5
  61. package/dist/esm/utils.js.map +1 -1
  62. package/dist/esm/version.d.ts +1 -1
  63. package/dist/esm/version.js +1 -1
  64. package/dist/esm/version.js.map +1 -1
  65. package/dist/types/index.d.ts +4 -3
  66. package/dist/types/index.d.ts.map +1 -1
  67. package/dist/types/light-account/accounts/account.d.ts +9 -4
  68. package/dist/types/light-account/accounts/account.d.ts.map +1 -1
  69. package/dist/types/light-account/accounts/base.d.ts +4 -4
  70. package/dist/types/light-account/accounts/base.d.ts.map +1 -1
  71. package/dist/types/light-account/accounts/multi-owner-account.d.ts +9 -4
  72. package/dist/types/light-account/accounts/multi-owner-account.d.ts.map +1 -1
  73. package/dist/types/light-account/decorators/multiOwner.d.ts.map +1 -1
  74. package/dist/types/light-account/decorators/singleOwner.d.ts.map +1 -1
  75. package/dist/types/light-account/lightAccountStaticImpl.d.ts +3 -1
  76. package/dist/types/light-account/lightAccountStaticImpl.d.ts.map +1 -1
  77. package/dist/types/light-account/predictAddress.d.ts +40 -2
  78. package/dist/types/light-account/predictAddress.d.ts.map +1 -1
  79. package/dist/types/light-account/registry.d.ts +3411 -1
  80. package/dist/types/light-account/registry.d.ts.map +1 -1
  81. package/dist/types/ma-v1/accounts/base.d.ts +4 -4
  82. package/dist/types/ma-v1/accounts/base.d.ts.map +1 -1
  83. package/dist/types/ma-v1/accounts/multi-owner-account.d.ts +9 -4
  84. package/dist/types/ma-v1/accounts/multi-owner-account.d.ts.map +1 -1
  85. package/dist/types/ma-v1/decorators/multiOwner.d.ts.map +1 -1
  86. package/dist/types/ma-v1/predictAddress.d.ts +20 -1
  87. package/dist/types/ma-v1/predictAddress.d.ts.map +1 -1
  88. package/dist/types/ma-v2/accounts/account.d.ts +10 -7
  89. package/dist/types/ma-v2/accounts/account.d.ts.map +1 -1
  90. package/dist/types/ma-v2/accounts/base.d.ts +5 -5
  91. package/dist/types/ma-v2/accounts/base.d.ts.map +1 -1
  92. package/dist/types/ma-v2/mav2StaticImpl.d.ts +1 -15
  93. package/dist/types/ma-v2/mav2StaticImpl.d.ts.map +1 -1
  94. package/dist/types/ma-v2/predictAddress.d.ts +22 -6
  95. package/dist/types/ma-v2/predictAddress.d.ts.map +1 -1
  96. package/dist/types/ma-v2/utils/account.d.ts +0 -3
  97. package/dist/types/ma-v2/utils/account.d.ts.map +1 -1
  98. package/dist/types/ma-v2/utils/signature.d.ts +1 -12
  99. package/dist/types/ma-v2/utils/signature.d.ts.map +1 -1
  100. package/dist/types/types.d.ts +8 -1
  101. package/dist/types/types.d.ts.map +1 -1
  102. package/dist/types/utils.d.ts +32 -2
  103. package/dist/types/utils.d.ts.map +1 -1
  104. package/dist/types/version.d.ts +1 -1
  105. package/dist/types/version.d.ts.map +1 -1
  106. package/package.json +5 -6
  107. package/src/index.ts +4 -3
  108. package/src/light-account/accounts/account.ts +42 -26
  109. package/src/light-account/accounts/base.ts +66 -27
  110. package/src/light-account/accounts/multi-owner-account.ts +33 -16
  111. package/src/light-account/decorators/multiOwner.ts +4 -1
  112. package/src/light-account/decorators/singleOwner.ts +3 -1
  113. package/src/light-account/lightAccountStaticImpl.ts +84 -11
  114. package/src/light-account/predictAddress.ts +124 -3
  115. package/src/light-account/registry.ts +47 -1
  116. package/src/light-account/utils.ts +1 -1
  117. package/src/ma-v1/accounts/base.ts +8 -5
  118. package/src/ma-v1/accounts/multi-owner-account.ts +37 -18
  119. package/src/ma-v1/decorators/multiOwner.ts +4 -1
  120. package/src/ma-v1/predictAddress.ts +59 -2
  121. package/src/ma-v2/accounts/account.ts +42 -55
  122. package/src/ma-v2/accounts/base.ts +24 -88
  123. package/src/ma-v2/mav2StaticImpl.ts +1 -52
  124. package/src/ma-v2/predictAddress.ts +68 -30
  125. package/src/ma-v2/utils/account.ts +4 -4
  126. package/src/ma-v2/utils/signature.ts +2 -51
  127. package/src/types.ts +15 -1
  128. package/src/utils.ts +119 -6
  129. package/src/version.ts +1 -1
  130. package/dist/esm/ma-v2/abis/webAuthnFactoryAbi.d.ts +0 -330
  131. package/dist/esm/ma-v2/abis/webAuthnFactoryAbi.js +0 -260
  132. package/dist/esm/ma-v2/abis/webAuthnFactoryAbi.js.map +0 -1
  133. package/dist/esm/ma-v2/modules/webauthn-validation/abis/webauthnValidationAbi.d.ts +0 -287
  134. package/dist/esm/ma-v2/modules/webauthn-validation/abis/webauthnValidationAbi.js +0 -374
  135. package/dist/esm/ma-v2/modules/webauthn-validation/abis/webauthnValidationAbi.js.map +0 -1
  136. package/dist/esm/ma-v2/modules/webauthn-validation/module.d.ts +0 -11
  137. package/dist/esm/ma-v2/modules/webauthn-validation/module.js +0 -16
  138. package/dist/esm/ma-v2/modules/webauthn-validation/module.js.map +0 -1
  139. package/dist/types/ma-v2/abis/webAuthnFactoryAbi.d.ts +0 -331
  140. package/dist/types/ma-v2/abis/webAuthnFactoryAbi.d.ts.map +0 -1
  141. package/dist/types/ma-v2/modules/webauthn-validation/abis/webauthnValidationAbi.d.ts +0 -288
  142. package/dist/types/ma-v2/modules/webauthn-validation/abis/webauthnValidationAbi.d.ts.map +0 -1
  143. package/dist/types/ma-v2/modules/webauthn-validation/module.d.ts +0 -12
  144. package/dist/types/ma-v2/modules/webauthn-validation/module.d.ts.map +0 -1
  145. package/src/ma-v2/abis/webAuthnFactoryAbi.ts +0 -259
  146. package/src/ma-v2/modules/webauthn-validation/abis/webauthnValidationAbi.ts +0 -373
  147. package/src/ma-v2/modules/webauthn-validation/module.ts +0 -28
@@ -1,8 +1,11 @@
1
1
  import { assertNever } from "@alchemy/common";
2
- import { concatHex, encodePacked, getContractAddress, keccak256, } from "viem";
3
- import { parsePublicKey } from "webauthn-p256";
2
+ import { concatHex, decodeFunctionData, encodePacked, getContractAddress, isAddressEqual, keccak256, } from "viem";
3
+ import { entryPoint07Address, } from "viem/account-abstraction";
4
+ import { accountFactoryAbi } from "./abis/accountFactoryAbi.js";
5
+ import { DefaultAddress } from "./utils/account.js";
6
+ import { getSenderFromFactoryData } from "../utils.js";
4
7
  /**
5
- * Predicts the address of a modular account V2 based on the provided parameters, which include factory address, salt, and implementation address. This function supports different types of accounts including "SMA", "MA", and "WebAuthn".
8
+ * Predicts the address of a modular account V2 based on the provided parameters, which include factory address, salt, and implementation address. This function supports different types of accounts including "SMA" and "MA".
6
9
  *
7
10
  * @example
8
11
  * ```ts
@@ -37,12 +40,6 @@ export function predictModularAccountV2Address(params) {
37
40
  combinedSalt: getCombinedSaltK1(params.ownerAddress, salt, params.entityId),
38
41
  initcode: getProxyBytecode(implementationAddress),
39
42
  };
40
- case "WebAuthn":
41
- const { x, y } = parsePublicKey(params.ownerPublicKey);
42
- return {
43
- combinedSalt: getCombinedSaltWebAuthn({ x, y }, salt, params.entityId),
44
- initcode: getProxyBytecode(implementationAddress),
45
- };
46
43
  default:
47
44
  return assertNever(params, "Unexpected MAv2 type");
48
45
  }
@@ -57,9 +54,6 @@ export function predictModularAccountV2Address(params) {
57
54
  function getCombinedSaltK1(ownerAddress, salt, entityId) {
58
55
  return keccak256(encodePacked(["address", "uint256", "uint32"], [ownerAddress, salt, entityId]));
59
56
  }
60
- function getCombinedSaltWebAuthn(ownerPublicKey, salt, entityId) {
61
- return keccak256(encodePacked(["uint256", "uint256", "uint256", "uint32"], [ownerPublicKey.x, ownerPublicKey.y, salt, entityId]));
62
- }
63
57
  function getProxyBytecode(implementationAddress) {
64
58
  return concatHex([
65
59
  "0x603d3d8160223d3973",
@@ -70,4 +64,44 @@ function getProxyBytecode(implementationAddress) {
70
64
  function getProxyBytecodeWithImmutableArgs(implementationAddress, immutableArgs) {
71
65
  return `0x6100513d8160233d3973${implementationAddress.slice(2)}60095155f3363d3d373d3d363d7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc545af43d6000803e6038573d6000fd5b3d6000f3${immutableArgs.slice(2)}`;
72
66
  }
67
+ /**
68
+ * Gets the modular account v2 address from factory data.
69
+ * If the factory is a known default (SMA), decodes the args and predicts without RPC.
70
+ * Otherwise falls back to calling the entry point's getSenderAddress.
71
+ *
72
+ * @param {GetModularAccountV2AddressFromFactoryDataParams} params - The parameters
73
+ * @returns {Promise<Address>} The account address
74
+ */
75
+ export async function getModularAccountV2AddressFromFactoryData({ client, factoryAddress, factoryData, implementationAddress, entryPoint = {
76
+ version: "0.7",
77
+ address: entryPoint07Address,
78
+ }, }) {
79
+ // Try SMA factory
80
+ if (isAddressEqual(factoryAddress, DefaultAddress.MAV2_FACTORY)) {
81
+ try {
82
+ const decoded = decodeFunctionData({
83
+ abi: accountFactoryAbi,
84
+ data: factoryData,
85
+ });
86
+ if (decoded.functionName === "createSemiModularAccount") {
87
+ const [decodedOwner, decodedSalt] = decoded.args;
88
+ return predictModularAccountV2Address({
89
+ factoryAddress,
90
+ implementationAddress,
91
+ salt: decodedSalt,
92
+ type: "SMA",
93
+ ownerAddress: decodedOwner,
94
+ });
95
+ }
96
+ }
97
+ catch {
98
+ // Decode failed, fall through to RPC
99
+ }
100
+ }
101
+ return getSenderFromFactoryData(client, {
102
+ factory: factoryAddress,
103
+ factoryData,
104
+ entryPoint,
105
+ });
106
+ }
73
107
  //# sourceMappingURL=predictAddress.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"predictAddress.js","sourceRoot":"","sources":["../../../src/ma-v2/predictAddress.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EACL,SAAS,EACT,YAAY,EACZ,kBAAkB,EAClB,SAAS,GAGV,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAuB/C;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,8BAA8B,CAC5C,MAA4C;IAE5C,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,qBAAqB,EAAE,GAAG,MAAM,CAAC;IAE/D,yGAAyG;IACzG,6JAA6J;IAC7J,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,GAAG,CAAC,GAAG,EAAE;QACvC,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;YACpB,KAAK,KAAK;gBACR,gDAAgD;gBAChD,OAAO;oBACL,YAAY,EAAE,iBAAiB,CAC7B,MAAM,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C,cAAc,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,CACrD,CACF,CAAC;AACJ,CAAC;AAED,SAAS,gBAAgB,CAAC,qBAA8B;IACtD,OAAO,SAAS,CAAC;QACf,sBAAsB;QACtB,qBAAqB;QACrB,wIAAwI;KACzI,CAAC,CAAC;AACL,CAAC;AAED,SAAS,iCAAiC,CACxC,qBAA8B,EAC9B,aAAkB;IAElB,OAAO,yBAAyB,qBAAqB,CAAC,KAAK,CACzD,CAAC,CACF,uIAAuI,aAAa,CAAC,KAAK,CACzJ,CAAC,CACF,EAAE,CAAC;AACN,CAAC","sourcesContent":["import { assertNever } from \"@alchemy/common\";\nimport {\n concatHex,\n encodePacked,\n getContractAddress,\n keccak256,\n type Address,\n type Hex,\n} from \"viem\";\nimport { parsePublicKey } from \"webauthn-p256\";\n\nexport type PredictModularAccountV2AddressParams = {\n factoryAddress: Address;\n implementationAddress: Address; // Should be the implementation address of the account type you are predicting the address for.\n salt: bigint;\n} & (\n | {\n type: \"MA\";\n ownerAddress: Address;\n entityId: number;\n }\n | {\n type: \"SMA\";\n ownerAddress: Address;\n }\n | {\n type: \"WebAuthn\";\n ownerPublicKey: Hex;\n entityId: number;\n }\n);\n\n/**\n * Predicts the address of a modular account V2 based on the provided parameters, which include factory address, salt, and implementation address. This function supports different types of accounts including \"SMA\", \"MA\", and \"WebAuthn\".\n *\n * @example\n * ```ts\n * import { predictModularAccountV2Address } from \"@alchemy/smart-accounts\";\n *\n * const accountAddress = predictModularAccountV2Address({\n * factoryAddress: \"0xFactoryAddress\" as Address,\n * implementationAddress: \"0xImplementation\" as Address,\n * salt: 0n,\n * type: \"SMA\",\n * ownerAddress: \"0xOwner\" as Address,\n * });\n * ```\n *\n * @param {PredictModularAccountV2AddressParams} params The parameters for predicting the modular account address, including `factoryAddress`, `salt`, `implementationAddress`, and additional properties based on the account type.\n * @returns {Address} The predicted address for the modular account V2.\n */\nexport function predictModularAccountV2Address(\n params: PredictModularAccountV2AddressParams,\n): Address {\n const { factoryAddress, salt, implementationAddress } = params;\n\n // Note(v4): prediction for MA is currently untested, because it is not supported as an account type yet.\n // Prior to using this prediction logic, ensure that the counterfactual computation is correct by updating `predictAddress.test.ts` to include a test for MA.\n const { combinedSalt, initcode } = (() => {\n switch (params.type) {\n case \"SMA\":\n // MAv2 factory uses max uint32 for SMA entityId\n return {\n combinedSalt: getCombinedSaltK1(\n params.ownerAddress,\n salt,\n 0xffffffff,\n ),\n initcode: getProxyBytecodeWithImmutableArgs(\n implementationAddress,\n params.ownerAddress,\n ),\n };\n case \"MA\":\n return {\n combinedSalt: getCombinedSaltK1(\n params.ownerAddress,\n salt,\n params.entityId,\n ),\n initcode: getProxyBytecode(implementationAddress),\n };\n case \"WebAuthn\":\n const { x, y } = parsePublicKey(params.ownerPublicKey);\n return {\n combinedSalt: getCombinedSaltWebAuthn(\n { x, y },\n salt,\n params.entityId,\n ),\n initcode: getProxyBytecode(implementationAddress),\n };\n default:\n return assertNever(params, \"Unexpected MAv2 type\");\n }\n })();\n\n return getContractAddress({\n from: factoryAddress,\n opcode: \"CREATE2\",\n salt: combinedSalt,\n bytecode: initcode,\n });\n}\n\nfunction getCombinedSaltK1(\n ownerAddress: Address,\n salt: bigint,\n entityId: number,\n): Hex {\n return keccak256(\n encodePacked(\n [\"address\", \"uint256\", \"uint32\"],\n [ownerAddress, salt, entityId],\n ),\n );\n}\n\nfunction getCombinedSaltWebAuthn(\n ownerPublicKey: { x: bigint; y: bigint },\n salt: bigint,\n entityId: number,\n): Hex {\n return keccak256(\n encodePacked(\n [\"uint256\", \"uint256\", \"uint256\", \"uint32\"],\n [ownerPublicKey.x, ownerPublicKey.y, salt, entityId],\n ),\n );\n}\n\nfunction getProxyBytecode(implementationAddress: Address): Hex {\n return concatHex([\n \"0x603d3d8160223d3973\",\n implementationAddress,\n \"0x60095155f3363d3d373d3d363d7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc545af43d6000803e6038573d6000fd5b3d6000f3\",\n ]);\n}\n\nfunction getProxyBytecodeWithImmutableArgs(\n implementationAddress: Address,\n immutableArgs: Hex,\n): Hex {\n return `0x6100513d8160233d3973${implementationAddress.slice(\n 2,\n )}60095155f3363d3d373d3d363d7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc545af43d6000803e6038573d6000fd5b3d6000f3${immutableArgs.slice(\n 2,\n )}`;\n}\n"]}
1
+ {"version":3,"file":"predictAddress.js","sourceRoot":"","sources":["../../../src/ma-v2/predictAddress.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EACL,SAAS,EACT,kBAAkB,EAClB,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACd,SAAS,GAIV,MAAM,MAAM,CAAC;AACd,OAAO,EACL,mBAAmB,GAEpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAkBvD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,8BAA8B,CAC5C,MAA4C;IAE5C,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,qBAAqB,EAAE,GAAG,MAAM,CAAC;IAE/D,yGAAyG;IACzG,6JAA6J;IAC7J,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,GAAG,CAAC,GAAG,EAAE;QACvC,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;YACpB,KAAK,KAAK;gBACR,gDAAgD;gBAChD,OAAO;oBACL,YAAY,EAAE,iBAAiB,CAC7B,MAAM,CAAC,YAAY,EACnB,IAAI,EACJ,UAAU,CACX;oBACD,QAAQ,EAAE,iCAAiC,CACzC,qBAAqB,EACrB,MAAM,CAAC,YAAY,CACpB;iBACF,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,EAAE,CAAC;QAChE,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,kBAAkB,CAAC;gBACjC,GAAG,EAAE,iBAAiB;gBACtB,IAAI,EAAE,WAAW;aAClB,CAAC,CAAC;YACH,IAAI,OAAO,CAAC,YAAY,KAAK,0BAA0B,EAAE,CAAC;gBACxD,MAAM,CAAC,YAAY,EAAE,WAAW,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;gBACjD,OAAO,8BAA8B,CAAC;oBACpC,cAAc;oBACd,qBAAqB;oBACrB,IAAI,EAAE,WAAW;oBACjB,IAAI,EAAE,KAAK;oBACX,YAAY,EAAE,YAAY;iBAC3B,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,qCAAqC;QACvC,CAAC;IACH,CAAC;IACD,OAAO,wBAAwB,CAAC,MAAM,EAAE;QACtC,OAAO,EAAE,cAAc;QACvB,WAAW;QACX,UAAU;KACX,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { assertNever } from \"@alchemy/common\";\nimport {\n concatHex,\n decodeFunctionData,\n encodePacked,\n getContractAddress,\n isAddressEqual,\n keccak256,\n type Address,\n type Client,\n type Hex,\n} from \"viem\";\nimport {\n entryPoint07Address,\n type EntryPointVersion,\n} from \"viem/account-abstraction\";\nimport { accountFactoryAbi } from \"./abis/accountFactoryAbi.js\";\nimport { DefaultAddress } from \"./utils/account.js\";\nimport { getSenderFromFactoryData } from \"../utils.js\";\n\nexport type PredictModularAccountV2AddressParams = {\n factoryAddress: Address;\n implementationAddress: Address; // Should be the implementation address of the account type you are predicting the address for.\n salt: bigint;\n} & (\n | {\n type: \"MA\";\n ownerAddress: Address;\n entityId: number;\n }\n | {\n type: \"SMA\";\n ownerAddress: Address;\n }\n);\n\n/**\n * Predicts the address of a modular account V2 based on the provided parameters, which include factory address, salt, and implementation address. This function supports different types of accounts including \"SMA\" and \"MA\".\n *\n * @example\n * ```ts\n * import { predictModularAccountV2Address } from \"@alchemy/smart-accounts\";\n *\n * const accountAddress = predictModularAccountV2Address({\n * factoryAddress: \"0xFactoryAddress\" as Address,\n * implementationAddress: \"0xImplementation\" as Address,\n * salt: 0n,\n * type: \"SMA\",\n * ownerAddress: \"0xOwner\" as Address,\n * });\n * ```\n *\n * @param {PredictModularAccountV2AddressParams} params The parameters for predicting the modular account address, including `factoryAddress`, `salt`, `implementationAddress`, and additional properties based on the account type.\n * @returns {Address} The predicted address for the modular account V2.\n */\nexport function predictModularAccountV2Address(\n params: PredictModularAccountV2AddressParams,\n): Address {\n const { factoryAddress, salt, implementationAddress } = params;\n\n // Note(v4): prediction for MA is currently untested, because it is not supported as an account type yet.\n // Prior to using this prediction logic, ensure that the counterfactual computation is correct by updating `predictAddress.test.ts` to include a test for MA.\n const { combinedSalt, initcode } = (() => {\n switch (params.type) {\n case \"SMA\":\n // MAv2 factory uses max uint32 for SMA entityId\n return {\n combinedSalt: getCombinedSaltK1(\n params.ownerAddress,\n salt,\n 0xffffffff,\n ),\n initcode: getProxyBytecodeWithImmutableArgs(\n implementationAddress,\n params.ownerAddress,\n ),\n };\n case \"MA\":\n return {\n combinedSalt: getCombinedSaltK1(\n params.ownerAddress,\n salt,\n params.entityId,\n ),\n initcode: getProxyBytecode(implementationAddress),\n };\n default:\n return assertNever(params, \"Unexpected MAv2 type\");\n }\n })();\n\n return getContractAddress({\n from: factoryAddress,\n opcode: \"CREATE2\",\n salt: combinedSalt,\n bytecode: initcode,\n });\n}\n\nfunction getCombinedSaltK1(\n ownerAddress: Address,\n salt: bigint,\n entityId: number,\n): Hex {\n return keccak256(\n encodePacked(\n [\"address\", \"uint256\", \"uint32\"],\n [ownerAddress, salt, entityId],\n ),\n );\n}\n\nfunction getProxyBytecode(implementationAddress: Address): Hex {\n return concatHex([\n \"0x603d3d8160223d3973\",\n implementationAddress,\n \"0x60095155f3363d3d373d3d363d7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc545af43d6000803e6038573d6000fd5b3d6000f3\",\n ]);\n}\n\nfunction getProxyBytecodeWithImmutableArgs(\n implementationAddress: Address,\n immutableArgs: Hex,\n): Hex {\n return `0x6100513d8160233d3973${implementationAddress.slice(\n 2,\n )}60095155f3363d3d373d3d363d7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc545af43d6000803e6038573d6000fd5b3d6000f3${immutableArgs.slice(\n 2,\n )}`;\n}\n\nexport type GetModularAccountV2AddressFromFactoryDataParams = {\n client: Client;\n factoryAddress: Address;\n factoryData: Hex;\n implementationAddress: Address;\n entryPoint?: {\n version: EntryPointVersion;\n address: Address;\n };\n};\n\n/**\n * Gets the modular account v2 address from factory data.\n * If the factory is a known default (SMA), decodes the args and predicts without RPC.\n * Otherwise falls back to calling the entry point's getSenderAddress.\n *\n * @param {GetModularAccountV2AddressFromFactoryDataParams} params - The parameters\n * @returns {Promise<Address>} The account address\n */\nexport async function getModularAccountV2AddressFromFactoryData({\n client,\n factoryAddress,\n factoryData,\n implementationAddress,\n entryPoint = {\n version: \"0.7\",\n address: entryPoint07Address,\n },\n}: GetModularAccountV2AddressFromFactoryDataParams): Promise<Address> {\n // Try SMA factory\n if (isAddressEqual(factoryAddress, DefaultAddress.MAV2_FACTORY)) {\n try {\n const decoded = decodeFunctionData({\n abi: accountFactoryAbi,\n data: factoryData,\n });\n if (decoded.functionName === \"createSemiModularAccount\") {\n const [decodedOwner, decodedSalt] = decoded.args;\n return predictModularAccountV2Address({\n factoryAddress,\n implementationAddress,\n salt: decodedSalt,\n type: \"SMA\",\n ownerAddress: decodedOwner,\n });\n }\n } catch {\n // Decode failed, fall through to RPC\n }\n }\n return getSenderFromFactoryData(client, {\n factory: factoryAddress,\n factoryData,\n entryPoint,\n });\n}\n"]}
@@ -8,18 +8,15 @@ import type { ModularAccountV2Base } from "../accounts/base.js";
8
8
  */
9
9
  export declare const DefaultAddress: {
10
10
  MAV2_FACTORY: "0x00000000000017c61b5bEe81050EC8eFc9c6fecd";
11
- MAV2_FACTORY_WEBAUTHN: "0x55010E571dCf07e254994bfc88b9C1C8FAe31960";
12
11
  SMAV2_BYTECODE: "0x000000000000c5A9089039570Dd36455b5C07383";
13
12
  SMAV2_STORAGE: "0x0000000000006E2f9d80CaEc0Da6500f005EB25A";
14
13
  SMAV2_7702: "0x69007702764179f14F51cdce752f4f775d74E139";
15
- MAV2: "0x00000000000002377B26b1EdA7b0BC371C60DD4f";
16
14
  };
17
15
  /**
18
16
  * A mapping of default addresses for the ModularAccountV2 modules.
19
17
  */
20
18
  export declare const DefaultModuleAddress: {
21
19
  SINGLE_SIGNER_VALIDATION: "0x00000000000099DE0BF6fA90dEB851E2A2df7d83";
22
- WEBAUTHN_VALIDATION: "0x0000000000001D9d34E07D9834274dF9ae575217";
23
20
  TIME_RANGE: "0x00000000000082B8e2012be914dFA4f62A0573eA";
24
21
  PAYMASTER_GUARD: "0x0000000000001aA7A7F7E29abe0be06c72FD42A1";
25
22
  NATIVE_TOKEN_LIMIT: "0x00000000000001e541f0D090868FBe24b59Fbe06";
@@ -5,18 +5,15 @@ import { semiModularAccountStorageAbi } from "../abis/semiModularAccountStorageA
5
5
  */
6
6
  export const DefaultAddress = {
7
7
  MAV2_FACTORY: "0x00000000000017c61b5bEe81050EC8eFc9c6fecd",
8
- MAV2_FACTORY_WEBAUTHN: "0x55010E571dCf07e254994bfc88b9C1C8FAe31960",
9
8
  SMAV2_BYTECODE: "0x000000000000c5A9089039570Dd36455b5C07383",
10
9
  SMAV2_STORAGE: "0x0000000000006E2f9d80CaEc0Da6500f005EB25A",
11
10
  SMAV2_7702: "0x69007702764179f14F51cdce752f4f775d74E139",
12
- MAV2: "0x00000000000002377B26b1EdA7b0BC371C60DD4f",
13
11
  };
14
12
  /**
15
13
  * A mapping of default addresses for the ModularAccountV2 modules.
16
14
  */
17
15
  export const DefaultModuleAddress = {
18
16
  SINGLE_SIGNER_VALIDATION: "0x00000000000099DE0BF6fA90dEB851E2A2df7d83",
19
- WEBAUTHN_VALIDATION: "0x0000000000001D9d34E07D9834274dF9ae575217",
20
17
  TIME_RANGE: "0x00000000000082B8e2012be914dFA4f62A0573eA",
21
18
  PAYMASTER_GUARD: "0x0000000000001aA7A7F7E29abe0be06c72FD42A1",
22
19
  NATIVE_TOKEN_LIMIT: "0x00000000000001e541f0D090868FBe24b59Fbe06",
@@ -91,6 +88,7 @@ export function serializeModuleEntity(config) {
91
88
  * @returns {boolean} True if the account is a ModularAccountV2, false otherwise.
92
89
  */
93
90
  export function isModularAccountV2(account) {
94
- return "source" in account && account.source === "ModularAccountV2";
91
+ return ("smartAccountType" in account &&
92
+ account.smartAccountType === "ModularAccountV2");
95
93
  }
96
94
  //# sourceMappingURL=account.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"account.js","sourceRoot":"","sources":["../../../../src/ma-v2/utils/account.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,kBAAkB,EAClB,KAAK,GAGN,MAAM,MAAM,CAAC;AAId,OAAO,EAAE,4BAA4B,EAAE,MAAM,yCAAyC,CAAC;AAGvF;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,YAAY,EAAE,4CAA4C;IAC1D,qBAAqB,EAAE,4CAA4C;IACnE,cAAc,EAAE,4CAA4C;IAC5D,aAAa,EAAE,4CAA4C;IAC3D,UAAU,EAAE,4CAA4C;IACxD,IAAI,EAAE,4CAA4C;CACjB,CAAC;AAEpC;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,wBAAwB,EAAE,4CAA4C;IACtE,mBAAmB,EAAE,4CAA4C;IACjE,UAAU,EAAE,4CAA4C;IACxD,eAAe,EAAE,4CAA4C;IAC7D,kBAAkB,EAAE,4CAA4C;IAChE,SAAS,EAAE,4CAA4C;CACtB,CAAC;AAEpC;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC;AAEzC;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAQ,YAAY,CAAC;AAM1D;;;;;GAK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viem\";\nimport type { SmartAccount } from \"viem/account-abstraction\";\nimport type { GetAccountParameter } from \"../../types.js\";\nimport type { ModuleEntity, UpgradeToData } from \"../types.js\";\nimport { semiModularAccountStorageAbi } from \"../abis/semiModularAccountStorageAbi.js\";\nimport type { ModularAccountV2Base } from \"../accounts/base.js\";\n\n/**\n * A mapping of default addresses for the ModularAccountV2.\n */\nexport const DefaultAddress = {\n MAV2_FACTORY: \"0x00000000000017c61b5bEe81050EC8eFc9c6fecd\",\n MAV2_FACTORY_WEBAUTHN: \"0x55010E571dCf07e254994bfc88b9C1C8FAe31960\",\n SMAV2_BYTECODE: \"0x000000000000c5A9089039570Dd36455b5C07383\",\n SMAV2_STORAGE: \"0x0000000000006E2f9d80CaEc0Da6500f005EB25A\",\n SMAV2_7702: \"0x69007702764179f14F51cdce752f4f775d74E139\",\n MAV2: \"0x00000000000002377B26b1EdA7b0BC371C60DD4f\",\n} satisfies Record<string, Address>;\n\n/**\n * A mapping of default addresses for the ModularAccountV2 modules.\n */\nexport const DefaultModuleAddress = {\n SINGLE_SIGNER_VALIDATION: \"0x00000000000099DE0BF6fA90dEB851E2A2df7d83\",\n WEBAUTHN_VALIDATION: \"0x0000000000001D9d34E07D9834274dF9ae575217\",\n TIME_RANGE: \"0x00000000000082B8e2012be914dFA4f62A0573eA\",\n PAYMASTER_GUARD: \"0x0000000000001aA7A7F7E29abe0be06c72FD42A1\",\n NATIVE_TOKEN_LIMIT: \"0x00000000000001e541f0D090868FBe24b59Fbe06\",\n ALLOWLIST: \"0x00000000003e826473a313e600b5b9b791f5a59a\",\n} satisfies Record<string, Address>;\n\n/**\n * The default owner entity ID.\n */\nexport const DEFAULT_OWNER_ENTITY_ID = 0;\n\n/**\n * The selector for the execute user operation function.\n */\nexport const EXECUTE_USER_OP_SELECTOR: Hex = \"0x8DD7712F\";\n\nexport type GetMAV2UpgradeToData<\n TAccount extends SmartAccount | undefined = SmartAccount | undefined,\n> = GetAccountParameter<TAccount>;\n\n/**\n * Gets the upgrade to data for the ModularAccountV2.\n *\n * @param {Address} ownerAddress - The address of the owner.\n * @returns {Promise<UpgradeToData>} The upgrade to data.\n */\nexport async function getMAV2UpgradeToData(\n ownerAddress: Address,\n): Promise<UpgradeToData> {\n const initData = encodeFunctionData({\n abi: semiModularAccountStorageAbi,\n functionName: \"initialize\",\n args: [ownerAddress],\n });\n\n return {\n implAddress: DefaultAddress.SMAV2_STORAGE,\n initializationData: initData,\n // TODO(v5): do we need `createModularAccountV2FromExisting()` in the return type here like we had in v4 or no?\n // Almost certainly not, but we need to clean up other parts in SDK for client-side upgrades.\n };\n}\n\nexport type BuildNonceParams = {\n nonceKey?: bigint;\n entityId?: number;\n isGlobalValidation?: boolean;\n isDeferredAction?: boolean;\n isDirectCallValidation?: boolean;\n};\n\n/**\n * Builds a full nonce key.\n *\n * @param {BuildNonceParams} params - The parameters for building a full nonce key.\n * @returns {bigint} The full nonce key.\n */\nexport const buildFullNonceKey = ({\n nonceKey = 0n,\n entityId = 0,\n isGlobalValidation = true,\n isDeferredAction = false,\n}: BuildNonceParams): bigint => {\n return (\n (nonceKey << 40n) +\n (BigInt(entityId) << 8n) +\n (isDeferredAction ? 2n : 0n) +\n (isGlobalValidation ? 1n : 0n)\n );\n};\n\n/**\n * Serializes a module entity into a hexadecimal format by concatenating the module address and entity ID.\n *\n * @example\n * ```ts\n * import { serializeModuleEntity } from \"@alchemy/smart-accounts\";\n * import { Address } from \"viem\";\n *\n * const moduleAddress: Address = \"0x1234\";\n * const entityId: number = 1234;\n *\n * const moduleEntityHex = serializeModuleEntity({\n * moduleAddress,\n * entityId\n * });\n * ```\n *\n * @param {ModuleEntity} config The module entity configuration containing the module address and entity ID\n * @returns {Hex} A hexadecimal string representation of the serialized module entity\n */\nexport function serializeModuleEntity(config: ModuleEntity): Hex {\n return concatHex([config.moduleAddress, toHex(config.entityId, { size: 4 })]);\n}\n\n/**\n * Checks if an account is a ModularAccountV2.\n *\n * @param {SmartAccount} account - The account to check.\n * @returns {boolean} True if the account is a ModularAccountV2, false otherwise.\n */\nexport function isModularAccountV2(\n account: SmartAccount,\n): account is ModularAccountV2Base {\n return \"source\" in account && account.source === \"ModularAccountV2\";\n}\n"]}
1
+ {"version":3,"file":"account.js","sourceRoot":"","sources":["../../../../src/ma-v2/utils/account.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,kBAAkB,EAClB,KAAK,GAGN,MAAM,MAAM,CAAC;AAId,OAAO,EAAE,4BAA4B,EAAE,MAAM,yCAAyC,CAAC;AAGvF;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,YAAY,EAAE,4CAA4C;IAC1D,cAAc,EAAE,4CAA4C;IAC5D,aAAa,EAAE,4CAA4C;IAC3D,UAAU,EAAE,4CAA4C;CACvB,CAAC;AAEpC;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,wBAAwB,EAAE,4CAA4C;IACtE,UAAU,EAAE,4CAA4C;IACxD,eAAe,EAAE,4CAA4C;IAC7D,kBAAkB,EAAE,4CAA4C;IAChE,SAAS,EAAE,4CAA4C;CACtB,CAAC;AAEpC;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC;AAEzC;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAQ,YAAY,CAAC;AAM1D;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,YAAqB;IAErB,MAAM,QAAQ,GAAG,kBAAkB,CAAC;QAClC,GAAG,EAAE,4BAA4B;QACjC,YAAY,EAAE,YAAY;QAC1B,IAAI,EAAE,CAAC,YAAY,CAAC;KACrB,CAAC,CAAC;IAEH,OAAO;QACL,WAAW,EAAE,cAAc,CAAC,aAAa;QACzC,kBAAkB,EAAE,QAAQ;QAC5B,+GAA+G;QAC/G,6FAA6F;KAC9F,CAAC;AACJ,CAAC;AAUD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,EAChC,QAAQ,GAAG,EAAE,EACb,QAAQ,GAAG,CAAC,EACZ,kBAAkB,GAAG,IAAI,EACzB,gBAAgB,GAAG,KAAK,GACP,EAAU,EAAE;IAC7B,OAAO,CACL,CAAC,QAAQ,IAAI,GAAG,CAAC;QACjB,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;QACxB,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5B,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAC/B,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAoB;IACxD,OAAO,SAAS,CAAC,CAAC,MAAM,CAAC,aAAa,EAAE,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAChF,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAChC,OAAqB;IAErB,OAAO,CACL,kBAAkB,IAAI,OAAO;QAC7B,OAAO,CAAC,gBAAgB,KAAK,kBAAkB,CAChD,CAAC;AACJ,CAAC","sourcesContent":["import {\n concatHex,\n encodeFunctionData,\n toHex,\n type Address,\n type Hex,\n} from \"viem\";\nimport type { SmartAccount } from \"viem/account-abstraction\";\nimport type { GetAccountParameter } from \"../../types.js\";\nimport type { ModuleEntity, UpgradeToData } from \"../types.js\";\nimport { semiModularAccountStorageAbi } from \"../abis/semiModularAccountStorageAbi.js\";\nimport type { ModularAccountV2Base } from \"../accounts/base.js\";\n\n/**\n * A mapping of default addresses for the ModularAccountV2.\n */\nexport const DefaultAddress = {\n MAV2_FACTORY: \"0x00000000000017c61b5bEe81050EC8eFc9c6fecd\",\n SMAV2_BYTECODE: \"0x000000000000c5A9089039570Dd36455b5C07383\",\n SMAV2_STORAGE: \"0x0000000000006E2f9d80CaEc0Da6500f005EB25A\",\n SMAV2_7702: \"0x69007702764179f14F51cdce752f4f775d74E139\",\n} satisfies Record<string, Address>;\n\n/**\n * A mapping of default addresses for the ModularAccountV2 modules.\n */\nexport const DefaultModuleAddress = {\n SINGLE_SIGNER_VALIDATION: \"0x00000000000099DE0BF6fA90dEB851E2A2df7d83\",\n TIME_RANGE: \"0x00000000000082B8e2012be914dFA4f62A0573eA\",\n PAYMASTER_GUARD: \"0x0000000000001aA7A7F7E29abe0be06c72FD42A1\",\n NATIVE_TOKEN_LIMIT: \"0x00000000000001e541f0D090868FBe24b59Fbe06\",\n ALLOWLIST: \"0x00000000003e826473a313e600b5b9b791f5a59a\",\n} satisfies Record<string, Address>;\n\n/**\n * The default owner entity ID.\n */\nexport const DEFAULT_OWNER_ENTITY_ID = 0;\n\n/**\n * The selector for the execute user operation function.\n */\nexport const EXECUTE_USER_OP_SELECTOR: Hex = \"0x8DD7712F\";\n\nexport type GetMAV2UpgradeToData<\n TAccount extends SmartAccount | undefined = SmartAccount | undefined,\n> = GetAccountParameter<TAccount>;\n\n/**\n * Gets the upgrade to data for the ModularAccountV2.\n *\n * @param {Address} ownerAddress - The address of the owner.\n * @returns {Promise<UpgradeToData>} The upgrade to data.\n */\nexport async function getMAV2UpgradeToData(\n ownerAddress: Address,\n): Promise<UpgradeToData> {\n const initData = encodeFunctionData({\n abi: semiModularAccountStorageAbi,\n functionName: \"initialize\",\n args: [ownerAddress],\n });\n\n return {\n implAddress: DefaultAddress.SMAV2_STORAGE,\n initializationData: initData,\n // TODO(v5): do we need `createModularAccountV2FromExisting()` in the return type here like we had in v4 or no?\n // Almost certainly not, but we need to clean up other parts in SDK for client-side upgrades.\n };\n}\n\nexport type BuildNonceParams = {\n nonceKey?: bigint;\n entityId?: number;\n isGlobalValidation?: boolean;\n isDeferredAction?: boolean;\n isDirectCallValidation?: boolean;\n};\n\n/**\n * Builds a full nonce key.\n *\n * @param {BuildNonceParams} params - The parameters for building a full nonce key.\n * @returns {bigint} The full nonce key.\n */\nexport const buildFullNonceKey = ({\n nonceKey = 0n,\n entityId = 0,\n isGlobalValidation = true,\n isDeferredAction = false,\n}: BuildNonceParams): bigint => {\n return (\n (nonceKey << 40n) +\n (BigInt(entityId) << 8n) +\n (isDeferredAction ? 2n : 0n) +\n (isGlobalValidation ? 1n : 0n)\n );\n};\n\n/**\n * Serializes a module entity into a hexadecimal format by concatenating the module address and entity ID.\n *\n * @example\n * ```ts\n * import { serializeModuleEntity } from \"@alchemy/smart-accounts\";\n * import { Address } from \"viem\";\n *\n * const moduleAddress: Address = \"0x1234\";\n * const entityId: number = 1234;\n *\n * const moduleEntityHex = serializeModuleEntity({\n * moduleAddress,\n * entityId\n * });\n * ```\n *\n * @param {ModuleEntity} config The module entity configuration containing the module address and entity ID\n * @returns {Hex} A hexadecimal string representation of the serialized module entity\n */\nexport function serializeModuleEntity(config: ModuleEntity): Hex {\n return concatHex([config.moduleAddress, toHex(config.entityId, { size: 4 })]);\n}\n\n/**\n * Checks if an account is a ModularAccountV2.\n *\n * @param {SmartAccount} account - The account to check.\n * @returns {boolean} True if the account is a ModularAccountV2, false otherwise.\n */\nexport function isModularAccountV2(\n account: SmartAccount,\n): account is ModularAccountV2Base {\n return (\n \"smartAccountType\" in account &&\n account.smartAccountType === \"ModularAccountV2\"\n );\n}\n"]}
@@ -1,6 +1,5 @@
1
1
  import { type Address, type Hash, type Hex } from "viem";
2
2
  import { SignaturePrefix } from "../types.js";
3
- import { type WebAuthnP256 } from "ox";
4
3
  export type PackUOSignatureParams = {
5
4
  validationSignature: Hex;
6
5
  };
@@ -13,7 +12,7 @@ export type PackUOSignatureParams = {
13
12
  export declare const packUOSignature: ({ validationSignature, }: PackUOSignatureParams) => Hex;
14
13
  export type Pack1271SignatureParams = {
15
14
  entityId: number;
16
- validationSignaturePrefix: SignaturePrefix | null;
15
+ validationSignaturePrefix: SignaturePrefix;
17
16
  validationSignature: Hex;
18
17
  };
19
18
  /**
@@ -51,13 +50,3 @@ export declare function toReplaySafeTypedData({ address, chainId, hash, salt, }:
51
50
  };
52
51
  primaryType: "ReplaySafeHash";
53
52
  };
54
- /**
55
- * Wraps a P256 signature with the webauthn metadata.
56
- *
57
- * @param {ToWebAuthnSignatureParams} params - The parameters for wrapping a P256 signature with the webauthn metadata.
58
- * @returns {object} The wrapped P256 signature.
59
- */
60
- export declare function toWebAuthnSignature({ webauthn, signature, }: {
61
- webauthn: WebAuthnP256.SignMetadata;
62
- signature: Hex;
63
- }): `0x${string}`;
@@ -1,6 +1,5 @@
1
- import { concatHex, encodeAbiParameters, toHex, } from "viem";
1
+ import { concatHex, toHex } from "viem";
2
2
  import { SignaturePrefix } from "../types.js";
3
- import { Signature } from "ox";
4
3
  /**
5
4
  * Signature packing utility for user operations.
6
5
  *
@@ -49,36 +48,4 @@ export function toReplaySafeTypedData({ address, chainId, hash, salt, }) {
49
48
  primaryType: "ReplaySafeHash",
50
49
  };
51
50
  }
52
- /**
53
- * Wraps a P256 signature with the webauthn metadata.
54
- *
55
- * @param {ToWebAuthnSignatureParams} params - The parameters for wrapping a P256 signature with the webauthn metadata.
56
- * @returns {object} The wrapped P256 signature.
57
- */
58
- export function toWebAuthnSignature({ webauthn, signature, }) {
59
- const { r, s } = Signature.fromHex(signature);
60
- return encodeAbiParameters([
61
- {
62
- name: "params",
63
- type: "tuple",
64
- components: [
65
- { name: "authenticatorData", type: "bytes" },
66
- { name: "clientDataJSON", type: "string" },
67
- { name: "challengeIndex", type: "uint256" },
68
- { name: "typeIndex", type: "uint256" },
69
- { name: "r", type: "uint256" },
70
- { name: "s", type: "uint256" },
71
- ],
72
- },
73
- ], [
74
- {
75
- authenticatorData: webauthn.authenticatorData,
76
- clientDataJSON: webauthn.clientDataJSON,
77
- challengeIndex: BigInt(webauthn.challengeIndex),
78
- typeIndex: BigInt(webauthn.typeIndex),
79
- r,
80
- s,
81
- },
82
- ]);
83
- }
84
51
  //# sourceMappingURL=signature.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"signature.js","sourceRoot":"","sources":["../../../../src/ma-v2/utils/signature.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,mBAAmB,EACnB,KAAK,GAIN,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAqB,MAAM,IAAI,CAAC;AAOlD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC;AAC9B,iEAAiE;AACjE,mBAAmB,GACG,EAAO,EAAE;IAC/B,OAAO,SAAS,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAC;AAC1D,CAAC,CAAC;AASF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,EAChC,QAAQ,EACR,yBAAyB,EACzB,mBAAmB,GACK,EAAO,EAAE;IACjC,OAAO,SAAS,CAAC;QACf,MAAM;QACN,KAAK,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;QAC5B,MAAM;QACN,GAAG,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACjE,mBAAmB;KACpB,CAAC,CAAC;AACL,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,EACpC,OAAO,EACP,OAAO,EACP,IAAI,EACJ,IAAI,GAML;IACC,OAAO;QACL,MAAM,EAAE;YACN,OAAO;YACP,iBAAiB,EAAE,OAAO;YAC1B,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC1B;QACD,KAAK,EAAE;YACL,cAAc,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;SACpD;QACD,OAAO,EAAE;YACP,IAAI;SACL;QACD,WAAW,EAAE,gBAAyB;KACvC,CAAC;AACJ,CAAC;AACD;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,EAClC,QAAQ,EACR,SAAS,GAIV;IACC,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC9C,OAAO,mBAAmB,CACxB;QACE;YACE,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,OAAO;YACb,UAAU,EAAE;gBACV,EAAE,IAAI,EAAE,mBAAmB,EAAE,IAAI,EAAE,OAAO,EAAE;gBAC5C,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,QAAQ,EAAE;gBAC1C,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,SAAS,EAAE;gBAC3C,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE;gBACtC,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE;gBAC9B,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE;aAC/B;SACF;KACF,EACD;QACE;YACE,iBAAiB,EAAE,QAAQ,CAAC,iBAAiB;YAC7C,cAAc,EAAE,QAAQ,CAAC,cAAc;YACvC,cAAc,EAAE,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC;YAC/C,SAAS,EAAE,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC;YACrC,CAAC;YACD,CAAC;SACF;KACF,CACF,CAAC;AACJ,CAAC","sourcesContent":["import {\n concatHex,\n encodeAbiParameters,\n toHex,\n type Address,\n type Hash,\n type Hex,\n} from \"viem\";\nimport { SignaturePrefix } from \"../types.js\";\nimport { Signature, type WebAuthnP256 } from \"ox\";\n\nexport type PackUOSignatureParams = {\n // orderedHookData: HookData[];\n validationSignature: Hex;\n};\n\n/**\n * Signature packing utility for user operations.\n *\n * @param {PackUOSignatureParams} params - The parameters for packing a user operation signature.\n * @returns {Hex} The packed user operation signature.\n */\nexport const packUOSignature = ({\n // orderedHookData, TODO: integrate in next iteration of MAv2 sdk\n validationSignature,\n}: PackUOSignatureParams): Hex => {\n return concatHex([\"0xFF\", \"0x00\", validationSignature]);\n};\n\n// TODO(v4): direct call validation 1271\nexport type Pack1271SignatureParams = {\n entityId: number;\n validationSignaturePrefix: SignaturePrefix | null;\n validationSignature: Hex;\n};\n\n/**\n * Signature packing utility for 1271 signatures.\n *\n * @param {Pack1271SignatureParams} params - The parameters for packing a 1271 signature.\n * @returns {Hex} The packed 1271 signature.\n */\nexport const pack1271Signature = ({\n entityId,\n validationSignaturePrefix,\n validationSignature,\n}: Pack1271SignatureParams): Hex => {\n return concatHex([\n \"0x00\",\n toHex(entityId, { size: 4 }),\n \"0xFF\",\n ...(validationSignaturePrefix ? [validationSignaturePrefix] : []),\n validationSignature,\n ]);\n};\n\n/**\n * Converts a hash to a replay safe typed data.\n *\n * @param {ToReplaySafeTypedDataParams} params - The parameters for converting a hash to a replay safe typed data.\n * @returns {object} The replay safe typed data.\n */\nexport function toReplaySafeTypedData({\n address,\n chainId,\n hash,\n salt,\n}: {\n address: Address;\n chainId: number;\n hash: Hash;\n salt?: Hex;\n}) {\n return {\n domain: {\n chainId,\n verifyingContract: address,\n ...(salt ? { salt } : {}),\n },\n types: {\n ReplaySafeHash: [{ name: \"hash\", type: \"bytes32\" }],\n },\n message: {\n hash,\n },\n primaryType: \"ReplaySafeHash\" as const,\n };\n}\n/**\n * Wraps a P256 signature with the webauthn metadata.\n *\n * @param {ToWebAuthnSignatureParams} params - The parameters for wrapping a P256 signature with the webauthn metadata.\n * @returns {object} The wrapped P256 signature.\n */\nexport function toWebAuthnSignature({\n webauthn,\n signature,\n}: {\n webauthn: WebAuthnP256.SignMetadata;\n signature: Hex;\n}) {\n const { r, s } = Signature.fromHex(signature);\n return encodeAbiParameters(\n [\n {\n name: \"params\",\n type: \"tuple\",\n components: [\n { name: \"authenticatorData\", type: \"bytes\" },\n { name: \"clientDataJSON\", type: \"string\" },\n { name: \"challengeIndex\", type: \"uint256\" },\n { name: \"typeIndex\", type: \"uint256\" },\n { name: \"r\", type: \"uint256\" },\n { name: \"s\", type: \"uint256\" },\n ],\n },\n ],\n [\n {\n authenticatorData: webauthn.authenticatorData,\n clientDataJSON: webauthn.clientDataJSON,\n challengeIndex: BigInt(webauthn.challengeIndex),\n typeIndex: BigInt(webauthn.typeIndex),\n r,\n s,\n },\n ],\n );\n}\n"]}
1
+ {"version":3,"file":"signature.js","sourceRoot":"","sources":["../../../../src/ma-v2/utils/signature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAqC,MAAM,MAAM,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAO9C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC;AAC9B,iEAAiE;AACjE,mBAAmB,GACG,EAAO,EAAE;IAC/B,OAAO,SAAS,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAC;AAC1D,CAAC,CAAC;AASF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,EAChC,QAAQ,EACR,yBAAyB,EACzB,mBAAmB,GACK,EAAO,EAAE;IACjC,OAAO,SAAS,CAAC;QACf,MAAM;QACN,KAAK,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;QAC5B,MAAM;QACN,GAAG,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACjE,mBAAmB;KACpB,CAAC,CAAC;AACL,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,EACpC,OAAO,EACP,OAAO,EACP,IAAI,EACJ,IAAI,GAML;IACC,OAAO;QACL,MAAM,EAAE;YACN,OAAO;YACP,iBAAiB,EAAE,OAAO;YAC1B,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC1B;QACD,KAAK,EAAE;YACL,cAAc,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;SACpD;QACD,OAAO,EAAE;YACP,IAAI;SACL;QACD,WAAW,EAAE,gBAAyB;KACvC,CAAC;AACJ,CAAC","sourcesContent":["import { concatHex, toHex, type Address, type Hash, type Hex } from \"viem\";\nimport { SignaturePrefix } from \"../types.js\";\n\nexport type PackUOSignatureParams = {\n // orderedHookData: HookData[];\n validationSignature: Hex;\n};\n\n/**\n * Signature packing utility for user operations.\n *\n * @param {PackUOSignatureParams} params - The parameters for packing a user operation signature.\n * @returns {Hex} The packed user operation signature.\n */\nexport const packUOSignature = ({\n // orderedHookData, TODO: integrate in next iteration of MAv2 sdk\n validationSignature,\n}: PackUOSignatureParams): Hex => {\n return concatHex([\"0xFF\", \"0x00\", validationSignature]);\n};\n\n// TODO(v4): direct call validation 1271\nexport type Pack1271SignatureParams = {\n entityId: number;\n validationSignaturePrefix: SignaturePrefix;\n validationSignature: Hex;\n};\n\n/**\n * Signature packing utility for 1271 signatures.\n *\n * @param {Pack1271SignatureParams} params - The parameters for packing a 1271 signature.\n * @returns {Hex} The packed 1271 signature.\n */\nexport const pack1271Signature = ({\n entityId,\n validationSignaturePrefix,\n validationSignature,\n}: Pack1271SignatureParams): Hex => {\n return concatHex([\n \"0x00\",\n toHex(entityId, { size: 4 }),\n \"0xFF\",\n ...(validationSignaturePrefix ? [validationSignaturePrefix] : []),\n validationSignature,\n ]);\n};\n\n/**\n * Converts a hash to a replay safe typed data.\n *\n * @param {ToReplaySafeTypedDataParams} params - The parameters for converting a hash to a replay safe typed data.\n * @returns {object} The replay safe typed data.\n */\nexport function toReplaySafeTypedData({\n address,\n chainId,\n hash,\n salt,\n}: {\n address: Address;\n chainId: number;\n hash: Hash;\n salt?: Hex;\n}) {\n return {\n domain: {\n chainId,\n verifyingContract: address,\n ...(salt ? { salt } : {}),\n },\n types: {\n ReplaySafeHash: [{ name: \"hash\", type: \"bytes32\" }],\n },\n message: {\n hash,\n },\n primaryType: \"ReplaySafeHash\" as const,\n };\n}\n"]}
@@ -1,10 +1,17 @@
1
1
  import type { Abi, Address, Hex, IsUndefined, SignableMessage, TypedDataDefinition } from "viem";
2
- import type { EntryPointVersion, SmartAccount } from "viem/account-abstraction";
2
+ import type { EntryPointVersion, SmartAccount, SmartAccountImplementation } from "viem/account-abstraction";
3
3
  export type GetAccountParameter<TAccount extends SmartAccount | undefined = SmartAccount | undefined, TAccountOverride extends SmartAccount = SmartAccount> = IsUndefined<TAccount> extends true ? {
4
4
  account: TAccountOverride;
5
5
  } : {
6
6
  account?: TAccountOverride;
7
7
  };
8
+ /**
9
+ * Helper type that converts a SmartAccount type to have a required `decodeCalls` function.
10
+ * This is useful for account implementations that always provide the `decodeCalls` functionality.
11
+ */
12
+ export type SmartAccountWithDecodeCalls<TImplementation extends SmartAccountImplementation> = SmartAccount<TImplementation> & {
13
+ decodeCalls: NonNullable<SmartAccount<TImplementation>["decodeCalls"]>;
14
+ };
8
15
  export type SignatureRequest = {
9
16
  type: "personal_sign";
10
17
  data: SignableMessage;
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n Abi,\n Address,\n Hex,\n IsUndefined,\n SignableMessage,\n TypedDataDefinition,\n} from \"viem\";\nimport type { EntryPointVersion, SmartAccount } from \"viem/account-abstraction\";\n\nexport type GetAccountParameter<\n TAccount extends SmartAccount | undefined = SmartAccount | undefined,\n TAccountOverride extends SmartAccount = SmartAccount,\n> =\n IsUndefined<TAccount> extends true\n ? { account: TAccountOverride }\n : { account?: TAccountOverride };\n\nexport type SignatureRequest =\n | {\n type: \"personal_sign\";\n data: SignableMessage;\n }\n | {\n type: \"eth_signTypedData_v4\";\n data: TypedDataDefinition;\n };\n\nexport type StaticSmartAccountImplementation<\n eip7702 extends boolean = boolean,\n entryPointVersion extends EntryPointVersion = EntryPointVersion,\n factoryArgs extends {} = {},\n entryPointAbi extends Abi | readonly unknown[] = Abi,\n accountAbi extends Abi | readonly unknown[] = Abi,\n factoryAbi extends Abi | readonly unknown[] = Abi,\n> = {\n readonly entryPoint: {\n readonly abi: entryPointAbi;\n readonly address: Address;\n readonly version: entryPointVersion;\n };\n readonly accountAbi: accountAbi;\n} & (eip7702 extends false\n ? {\n // Smart contract account specific fields\n readonly accountImplementation: Address;\n readonly getFactoryData: (factoryArgs: factoryArgs) => Hex;\n readonly predictAccountAddress: (factoryArgs: factoryArgs) => Address;\n readonly factoryAddress: Address;\n readonly factoryAbi: factoryAbi;\n }\n : {}) &\n (eip7702 extends true\n ? {\n // EIP-7702 account specific fields\n readonly delegationAddress: Address;\n }\n : {});\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n Abi,\n Address,\n Hex,\n IsUndefined,\n SignableMessage,\n TypedDataDefinition,\n} from \"viem\";\nimport type {\n EntryPointVersion,\n SmartAccount,\n SmartAccountImplementation,\n} from \"viem/account-abstraction\";\n\nexport type GetAccountParameter<\n TAccount extends SmartAccount | undefined = SmartAccount | undefined,\n TAccountOverride extends SmartAccount = SmartAccount,\n> =\n IsUndefined<TAccount> extends true\n ? { account: TAccountOverride }\n : { account?: TAccountOverride };\n\n/**\n * Helper type that converts a SmartAccount type to have a required `decodeCalls` function.\n * This is useful for account implementations that always provide the `decodeCalls` functionality.\n */\nexport type SmartAccountWithDecodeCalls<\n TImplementation extends SmartAccountImplementation,\n> = SmartAccount<TImplementation> & {\n decodeCalls: NonNullable<SmartAccount<TImplementation>[\"decodeCalls\"]>;\n};\n\nexport type SignatureRequest =\n | {\n type: \"personal_sign\";\n data: SignableMessage;\n }\n | {\n type: \"eth_signTypedData_v4\";\n data: TypedDataDefinition;\n };\n\nexport type StaticSmartAccountImplementation<\n eip7702 extends boolean = boolean,\n entryPointVersion extends EntryPointVersion = EntryPointVersion,\n factoryArgs extends {} = {},\n entryPointAbi extends Abi | readonly unknown[] = Abi,\n accountAbi extends Abi | readonly unknown[] = Abi,\n factoryAbi extends Abi | readonly unknown[] = Abi,\n> = {\n readonly entryPoint: {\n readonly abi: entryPointAbi;\n readonly address: Address;\n readonly version: entryPointVersion;\n };\n readonly accountAbi: accountAbi;\n} & (eip7702 extends false\n ? {\n // Smart contract account specific fields\n readonly accountImplementation: Address;\n readonly getFactoryData: (factoryArgs: factoryArgs) => Hex;\n readonly predictAccountAddress: (factoryArgs: factoryArgs) => Address;\n readonly factoryAddress: Address;\n readonly factoryAbi: factoryAbi;\n }\n : {}) &\n (eip7702 extends true\n ? {\n // EIP-7702 account specific fields\n readonly delegationAddress: Address;\n }\n : {});\n"]}
@@ -1,6 +1,36 @@
1
- import { type Client, type Hex } from "viem";
2
- import type { UserOperation } from "viem/account-abstraction";
1
+ import { type Address, type Client, type Hex } from "viem";
2
+ import { type EntryPointVersion, type UserOperation } from "viem/account-abstraction";
3
+ /**
4
+ * Checks if the current chain supports RIP-7212 (precompiled contract for secp256r1 curve operations).
5
+ * This is used to determine if the chain has native support for P256 signature verification,
6
+ * which is commonly used in WebAuthn/passkey implementations.
7
+ *
8
+ * @param {Client} client - The viem client to use for the check
9
+ * @returns {Promise<boolean>} True if the chain supports RIP-7212, false otherwise
10
+ */
3
11
  export declare const chainHas7212: (client: Client) => Promise<boolean>;
4
12
  export declare function packAccountGasLimits(data: Pick<UserOperation, "verificationGasLimit" | "callGasLimit"> | Pick<UserOperation, "maxPriorityFeePerGas" | "maxFeePerGas">): Hex;
5
13
  export declare function packPaymasterData({ paymaster, paymasterVerificationGasLimit, paymasterPostOpGasLimit, paymasterData, }: Pick<UserOperation, "paymaster" | "paymasterVerificationGasLimit" | "paymasterPostOpGasLimit" | "paymasterData">): Hex;
6
14
  export declare const bigIntMultiply: (base: number | bigint | Hex, multiplier: number, roundingMode?: "ROUND" | "FLOOR" | "CEIL") => bigint;
15
+ /**
16
+ * Derives the counterfactual smart account address from init code by calling
17
+ * the entry point's `getSenderAddress` function.
18
+ *
19
+ * @param {Client} client - The viem client to use for the call.
20
+ * @param {object} params - The parameters for deriving the sender address.
21
+ * @param {Hex} params.factory - The factory address for the account.
22
+ * @param {Hex} params.factoryData - The factory data for the account.
23
+ * @param {object} params.entryPoint - The entry point contract details.
24
+ * @param {EntryPointVersion} [params.entryPoint.version] - The entry point version.
25
+ * @param {Address} params.entryPoint.address - The entry point contract address.
26
+ * @returns {Promise<Address>} The counterfactual address of the smart account.
27
+ */
28
+ export declare const getSenderFromFactoryData: (client: Client, params: {
29
+ factory: Hex;
30
+ factoryData: Hex;
31
+ entryPoint: {
32
+ version: EntryPointVersion;
33
+ address: Address;
34
+ };
35
+ }) => Promise<Address>;
36
+ export declare function is7702Delegated(delegation: Address, code: Hex | undefined): boolean;
package/dist/esm/utils.js CHANGED
@@ -1,8 +1,17 @@
1
- import { concat, toHex } from "viem";
1
+ import { concatHex, RawContractError, BaseError as ViemBaseError, toHex, } from "viem";
2
+ import { decodeErrorResult, encodeFunctionData, getAction, getAddress, isHex, } from "viem/utils";
3
+ import { entryPoint07Abi, } from "viem/account-abstraction";
4
+ import { assertNever, BaseError } from "@alchemy/common";
2
5
  import { call } from "viem/actions";
3
- import { getAction } from "viem/utils";
4
- import { BaseError } from "@alchemy/common";
5
6
  const RIP_7212_CHECK_BYTECODE = "0x60806040526040517f532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25815260056020820152600160408201527f4a03ef9f92eb268cafa601072489a56380fa0dc43171d7712813b3a19a1eb5e560608201527f3e213e28a608ce9a2f4a17fd830c6654018a79b3e0263d91a8ba90622df6f2f0608082015260208160a0836101005afa503d5f823e3d81f3fe";
7
+ /**
8
+ * Checks if the current chain supports RIP-7212 (precompiled contract for secp256r1 curve operations).
9
+ * This is used to determine if the chain has native support for P256 signature verification,
10
+ * which is commonly used in WebAuthn/passkey implementations.
11
+ *
12
+ * @param {Client} client - The viem client to use for the check
13
+ * @returns {Promise<boolean>} True if the chain supports RIP-7212, false otherwise
14
+ */
6
15
  export const chainHas7212 = async (client) => {
7
16
  const callAction = getAction(client, call, "call");
8
17
  const { data } = await callAction({
@@ -11,7 +20,7 @@ export const chainHas7212 = async (client) => {
11
20
  return data ? BigInt(data) === 1n : false;
12
21
  };
13
22
  export function packAccountGasLimits(data) {
14
- return concat(Object.values(data).map((v) => toHex(v, { size: 16 })));
23
+ return concatHex(Object.values(data).map((v) => toHex(v, { size: 16 })));
15
24
  }
16
25
  export function packPaymasterData({ paymaster, paymasterVerificationGasLimit, paymasterPostOpGasLimit, paymasterData, }) {
17
26
  if (!paymaster ||
@@ -20,7 +29,7 @@ export function packPaymasterData({ paymaster, paymasterVerificationGasLimit, pa
20
29
  !paymasterData) {
21
30
  return "0x";
22
31
  }
23
- return concat([
32
+ return concatHex([
24
33
  paymaster,
25
34
  toHex(paymasterVerificationGasLimit, { size: 16 }),
26
35
  toHex(paymasterPostOpGasLimit, { size: 16 }),
@@ -49,4 +58,65 @@ export const bigIntMultiply = (base, multiplier, roundingMode = "CEIL") => {
49
58
  return product >= 0n ? product / scale : (product - scale + 1n) / scale;
50
59
  }
51
60
  };
61
+ /**
62
+ * Derives the counterfactual smart account address from init code by calling
63
+ * the entry point's `getSenderAddress` function.
64
+ *
65
+ * @param {Client} client - The viem client to use for the call.
66
+ * @param {object} params - The parameters for deriving the sender address.
67
+ * @param {Hex} params.factory - The factory address for the account.
68
+ * @param {Hex} params.factoryData - The factory data for the account.
69
+ * @param {object} params.entryPoint - The entry point contract details.
70
+ * @param {EntryPointVersion} [params.entryPoint.version] - The entry point version.
71
+ * @param {Address} params.entryPoint.address - The entry point contract address.
72
+ * @returns {Promise<Address>} The counterfactual address of the smart account.
73
+ */
74
+ export const getSenderFromFactoryData = async (client, params) => {
75
+ const action = getAction(client, call, "call");
76
+ const data = encodeFunctionData({
77
+ abi: entryPoint07Abi, // getSenderAddress is the same for EP v0.6, EP v0.7, and v0.8
78
+ functionName: "getSenderAddress",
79
+ args: [concatHex([params.factory, params.factoryData])],
80
+ });
81
+ try {
82
+ // getSenderAddress is expected to revert with the computed sender
83
+ await action({ to: params.entryPoint.address, data });
84
+ }
85
+ catch (err) {
86
+ const revertData = getRevertErrorData(err);
87
+ if (!isHex(revertData)) {
88
+ throw new BaseError("Failed to get sender address from init code: no revert data found.");
89
+ }
90
+ switch (params.entryPoint.version) {
91
+ case "0.9":
92
+ case "0.8":
93
+ case "0.7": {
94
+ const decoded = decodeErrorResult({
95
+ abi: entryPoint07Abi, // same error signature for EP v0.7 and v0.8
96
+ data: revertData,
97
+ });
98
+ if (decoded.errorName !== "SenderAddressResult") {
99
+ throw new BaseError(`Unexpected error from getSenderAddress: ${decoded.errorName}`);
100
+ }
101
+ return decoded.args[0];
102
+ }
103
+ case "0.6":
104
+ // EP v0.6: last 20 bytes is the address.
105
+ return getAddress(`0x${revertData.slice(-40)}`);
106
+ default:
107
+ return assertNever(params.entryPoint.version, "Unexpected entry point version");
108
+ }
109
+ }
110
+ throw new BaseError("Expected getSenderAddress to revert.");
111
+ };
112
+ // Borrowed from Viem: https://github.com/wevm/viem/blob/3ff6c2f19350dcbe49017e2b3d5a2cf761ab9070/src/actions/public/call.ts#L473
113
+ function getRevertErrorData(err) {
114
+ if (!(err instanceof ViemBaseError))
115
+ return undefined;
116
+ const error = err.walk();
117
+ return typeof error?.data === "object" ? error.data?.data : error.data;
118
+ }
119
+ export function is7702Delegated(delegation, code) {
120
+ return (code?.toLowerCase() === concatHex(["0xef0100", delegation]).toLowerCase());
121
+ }
52
122
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,MAAM,EAAY,KAAK,EAAE,MAAM,MAAM,CAAC;AAC5D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type Client, concat, type Hex, toHex } from \"viem\";\nimport { call } from \"viem/actions\";\nimport { getAction } from \"viem/utils\";\nimport type { UserOperation } from \"viem/account-abstraction\";\nimport { BaseError } from \"@alchemy/common\";\n\nconst RIP_7212_CHECK_BYTECODE =\n \"0x60806040526040517f532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25815260056020820152600160408201527f4a03ef9f92eb268cafa601072489a56380fa0dc43171d7712813b3a19a1eb5e560608201527f3e213e28a608ce9a2f4a17fd830c6654018a79b3e0263d91a8ba90622df6f2f0608082015260208160a0836101005afa503d5f823e3d81f3fe\";\n\nexport const chainHas7212 = async (client: Client): Promise<boolean> => {\n const callAction = getAction(client, call, \"call\");\n\n const { data } = await callAction({\n data: RIP_7212_CHECK_BYTECODE,\n });\n\n return data ? BigInt(data) === 1n : false;\n};\n\nexport function packAccountGasLimits(\n data:\n | Pick<UserOperation, \"verificationGasLimit\" | \"callGasLimit\">\n | Pick<UserOperation, \"maxPriorityFeePerGas\" | \"maxFeePerGas\">,\n): Hex {\n return concat(Object.values(data).map((v) => toHex(v, { size: 16 })));\n}\n\nexport function packPaymasterData({\n paymaster,\n paymasterVerificationGasLimit,\n paymasterPostOpGasLimit,\n paymasterData,\n}: Pick<\n UserOperation,\n | \"paymaster\"\n | \"paymasterVerificationGasLimit\"\n | \"paymasterPostOpGasLimit\"\n | \"paymasterData\"\n>): Hex {\n if (\n !paymaster ||\n !paymasterVerificationGasLimit ||\n !paymasterPostOpGasLimit ||\n !paymasterData\n ) {\n return \"0x\";\n }\n return concat([\n paymaster,\n toHex(paymasterVerificationGasLimit, { size: 16 }),\n toHex(paymasterPostOpGasLimit, { size: 16 }),\n paymasterData,\n ]);\n}\n\nexport const bigIntMultiply = (\n base: number | bigint | Hex,\n multiplier: number,\n roundingMode: \"ROUND\" | \"FLOOR\" | \"CEIL\" = \"CEIL\",\n) => {\n if (Number.isInteger(multiplier)) {\n return BigInt(base) * BigInt(multiplier);\n }\n\n const multiplierStr = multiplier.toString();\n const decimalPlaces = multiplierStr.split(\".\")[1]?.length ?? 0;\n\n if (decimalPlaces > 4) {\n throw new BaseError(\"bigIntMultiply max precision is 4 decimal places.\");\n }\n\n const scale = BigInt(10 ** decimalPlaces);\n const scaledMultiplier = BigInt(multiplierStr.replace(\".\", \"\"));\n const product = BigInt(base) * scaledMultiplier;\n\n switch (roundingMode) {\n case \"ROUND\":\n return (product + scale / 2n) / scale;\n case \"CEIL\":\n return product >= 0n ? (product + scale - 1n) / scale : product / scale;\n case \"FLOOR\":\n default:\n return product >= 0n ? product / scale : (product - scale + 1n) / scale;\n }\n};\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,SAAS,EAET,gBAAgB,EAChB,SAAS,IAAI,aAAa,EAC1B,KAAK,GACN,MAAM,MAAM,CAAC;AACd,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,SAAS,EACT,UAAU,EACV,KAAK,GACN,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,eAAe,GAGhB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,MAAM,uBAAuB,GAC3B,sTAAsT,CAAC;AAEzT;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAAE,MAAc,EAAoB,EAAE;IACrE,MAAM,UAAU,GAAG,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IAEnD,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,UAAU,CAAC;QAChC,IAAI,EAAE,uBAAuB;KAC9B,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;AAC5C,CA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EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;AACzE,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,UAAmB,EACnB,IAAqB;IAErB,OAAO,CACL,IAAI,EAAE,WAAW,EAAE,KAAK,SAAS,CAAC,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,WAAW,EAAE,CAC1E,CAAC;AACJ,CAAC","sourcesContent":["import {\n type Address,\n type Client,\n concatHex,\n type Hex,\n RawContractError,\n BaseError as ViemBaseError,\n toHex,\n} from \"viem\";\nimport {\n decodeErrorResult,\n encodeFunctionData,\n getAction,\n getAddress,\n isHex,\n} from \"viem/utils\";\nimport {\n entryPoint07Abi,\n type EntryPointVersion,\n type UserOperation,\n} from \"viem/account-abstraction\";\nimport { assertNever, BaseError } from \"@alchemy/common\";\nimport { call } from \"viem/actions\";\n\nconst RIP_7212_CHECK_BYTECODE =\n \"0x60806040526040517f532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25815260056020820152600160408201527f4a03ef9f92eb268cafa601072489a56380fa0dc43171d7712813b3a19a1eb5e560608201527f3e213e28a608ce9a2f4a17fd830c6654018a79b3e0263d91a8ba90622df6f2f0608082015260208160a0836101005afa503d5f823e3d81f3fe\";\n\n/**\n * Checks if the current chain supports RIP-7212 (precompiled contract for secp256r1 curve operations).\n * This is used to determine if the chain has native support for P256 signature verification,\n * which is commonly used in WebAuthn/passkey implementations.\n *\n * @param {Client} client - The viem client to use for the check\n * @returns {Promise<boolean>} True if the chain supports RIP-7212, false otherwise\n */\nexport const chainHas7212 = async (client: Client): Promise<boolean> => {\n const callAction = getAction(client, call, \"call\");\n\n const { data } = await callAction({\n data: RIP_7212_CHECK_BYTECODE,\n });\n\n return data ? BigInt(data) === 1n : false;\n};\n\nexport function packAccountGasLimits(\n data:\n | Pick<UserOperation, \"verificationGasLimit\" | \"callGasLimit\">\n | Pick<UserOperation, \"maxPriorityFeePerGas\" | \"maxFeePerGas\">,\n): Hex {\n return concatHex(Object.values(data).map((v) => toHex(v, { size: 16 })));\n}\n\nexport function packPaymasterData({\n paymaster,\n paymasterVerificationGasLimit,\n paymasterPostOpGasLimit,\n paymasterData,\n}: Pick<\n UserOperation,\n | \"paymaster\"\n | \"paymasterVerificationGasLimit\"\n | \"paymasterPostOpGasLimit\"\n | \"paymasterData\"\n>): Hex {\n if (\n !paymaster ||\n !paymasterVerificationGasLimit ||\n !paymasterPostOpGasLimit ||\n !paymasterData\n ) {\n return \"0x\";\n }\n return concatHex([\n paymaster,\n toHex(paymasterVerificationGasLimit, { size: 16 }),\n toHex(paymasterPostOpGasLimit, { size: 16 }),\n paymasterData,\n ]);\n}\n\nexport const bigIntMultiply = (\n base: number | bigint | Hex,\n multiplier: number,\n roundingMode: \"ROUND\" | \"FLOOR\" | \"CEIL\" = \"CEIL\",\n) => {\n if (Number.isInteger(multiplier)) {\n return BigInt(base) * BigInt(multiplier);\n }\n\n const multiplierStr = multiplier.toString();\n const decimalPlaces = multiplierStr.split(\".\")[1]?.length ?? 0;\n\n if (decimalPlaces > 4) {\n throw new BaseError(\"bigIntMultiply max precision is 4 decimal places.\");\n }\n\n const scale = BigInt(10 ** decimalPlaces);\n const scaledMultiplier = BigInt(multiplierStr.replace(\".\", \"\"));\n const product = BigInt(base) * scaledMultiplier;\n\n switch (roundingMode) {\n case \"ROUND\":\n return (product + scale / 2n) / scale;\n case \"CEIL\":\n return product >= 0n ? (product + scale - 1n) / scale : product / scale;\n case \"FLOOR\":\n default:\n return product >= 0n ? product / scale : (product - scale + 1n) / scale;\n }\n};\n\n/**\n * Derives the counterfactual smart account address from init code by calling\n * the entry point's `getSenderAddress` function.\n *\n * @param {Client} client - The viem client to use for the call.\n * @param {object} params - The parameters for deriving the sender address.\n * @param {Hex} params.factory - The factory address for the account.\n * @param {Hex} params.factoryData - The factory data for the account.\n * @param {object} params.entryPoint - The entry point contract details.\n * @param {EntryPointVersion} [params.entryPoint.version] - The entry point version.\n * @param {Address} params.entryPoint.address - The entry point contract address.\n * @returns {Promise<Address>} The counterfactual address of the smart account.\n */\nexport const getSenderFromFactoryData = async (\n client: Client,\n params: {\n factory: Hex;\n factoryData: Hex;\n entryPoint: {\n version: EntryPointVersion;\n address: Address;\n };\n },\n): Promise<Address> => {\n const action = getAction(client, call, \"call\");\n\n const data = encodeFunctionData({\n abi: entryPoint07Abi, // getSenderAddress is the same for EP v0.6, EP v0.7, and v0.8\n functionName: \"getSenderAddress\",\n args: [concatHex([params.factory, params.factoryData])],\n });\n\n try {\n // getSenderAddress is expected to revert with the computed sender\n await action({ to: params.entryPoint.address, data });\n } catch (err) {\n const revertData = getRevertErrorData(err);\n if (!isHex(revertData)) {\n throw new BaseError(\n \"Failed to get sender address from init code: no revert data found.\",\n );\n }\n\n switch (params.entryPoint.version) {\n case \"0.9\":\n case \"0.8\":\n case \"0.7\": {\n const decoded = decodeErrorResult({\n abi: entryPoint07Abi, // same error signature for EP v0.7 and v0.8\n data: revertData,\n });\n if (decoded.errorName !== \"SenderAddressResult\") {\n throw new BaseError(\n `Unexpected error from getSenderAddress: ${decoded.errorName}`,\n );\n }\n return decoded.args[0];\n }\n case \"0.6\":\n // EP v0.6: last 20 bytes is the address.\n return getAddress(`0x${revertData.slice(-40)}`);\n default:\n return assertNever(\n params.entryPoint.version,\n \"Unexpected entry point version\",\n );\n }\n }\n throw new BaseError(\"Expected getSenderAddress to revert.\");\n};\n\n// Borrowed from Viem: https://github.com/wevm/viem/blob/3ff6c2f19350dcbe49017e2b3d5a2cf761ab9070/src/actions/public/call.ts#L473\nfunction getRevertErrorData(err: unknown) {\n if (!(err instanceof ViemBaseError)) return undefined;\n const error = err.walk() as RawContractError;\n return typeof error?.data === \"object\" ? error.data?.data : error.data;\n}\n\nexport function is7702Delegated(\n delegation: Address,\n code: Hex | undefined,\n): boolean {\n return (\n code?.toLowerCase() === concatHex([\"0xef0100\", delegation]).toLowerCase()\n );\n}\n"]}
@@ -1 +1 @@
1
- export declare const VERSION = "0.0.0";
1
+ export declare const VERSION = "0.0.0-alpha.20";
@@ -1,4 +1,4 @@
1
1
  // This file is autogenerated by inject-version.ts. Any changes will be
2
2
  // overwritten on commit!
3
- export const VERSION = "0.0.0";
3
+ export const VERSION = "0.0.0-alpha.20";
4
4
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yBAAyB;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"0.0.0\";\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yBAAyB;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,gBAAgB,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"0.0.0-alpha.20\";\n"]}
@@ -1,3 +1,5 @@
1
+ export type * from "./types.js";
2
+ export { chainHas7212 } from "./utils.js";
1
3
  export type * from "./light-account/accounts/account.js";
2
4
  export { toLightAccount } from "./light-account/accounts/account.js";
3
5
  export type * from "./light-account/accounts/multi-owner-account.js";
@@ -30,14 +32,13 @@ export type * from "./ma-v2/decorators/deferralActions.js";
30
32
  export { deferralActions } from "./ma-v2/decorators/deferralActions.js";
31
33
  export type * from "./ma-v2/decorators/installValidation.js";
32
34
  export { installValidationActions } from "./ma-v2/decorators/installValidation.js";
33
- export { semiModularAccountV2StaticImpl, semiModularAccount7702StaticImpl, webAuthnModularAccountV2StaticImpl, } from "./ma-v2/mav2StaticImpl.js";
35
+ export { semiModularAccountV2StaticImpl, semiModularAccount7702StaticImpl, } from "./ma-v2/mav2StaticImpl.js";
34
36
  export type * from "./ma-v2/mav2StaticImpl.js";
35
37
  export { AllowlistModule } from "./ma-v2/modules/allowlist-module/module.js";
36
38
  export { NativeTokenLimitModule } from "./ma-v2/modules/native-token-limit-module/module.js";
37
39
  export { PaymasterGuardModule } from "./ma-v2/modules/paymaster-guard-module/module.js";
38
40
  export { SingleSignerValidationModule } from "./ma-v2/modules/single-signer-validation/module.js";
39
41
  export { TimeRangeModule } from "./ma-v2/modules/time-range-module/module.js";
40
- export { WebAuthnValidationModule } from "./ma-v2/modules/webauthn-validation/module.js";
41
42
  export type * from "./ma-v2/permissionBuilder.js";
42
43
  export { PermissionBuilder, PermissionType, } from "./ma-v2/permissionBuilder.js";
43
44
  export type * from "./ma-v2/predictAddress.js";
@@ -50,7 +51,7 @@ export { parseDeferredAction, buildDeferredActionDigest, } from "./ma-v2/utils/d
50
51
  export type * from "./ma-v2/utils/hooks.js";
51
52
  export { serializeValidationConfig, serializeHookConfig, } from "./ma-v2/utils/hooks.js";
52
53
  export type * from "./ma-v2/utils/signature.js";
53
- export { packUOSignature, pack1271Signature, toReplaySafeTypedData, toWebAuthnSignature, } from "./ma-v2/utils/signature.js";
54
+ export { packUOSignature, pack1271Signature, toReplaySafeTypedData, } from "./ma-v2/utils/signature.js";
54
55
  export { EntityIdOverrideError } from "./errors/EntityIdOverrideError.js";
55
56
  export { InvalidDeferredActionNonceError } from "./errors/InvalidDeferredActionNonceError.js";
56
57
  export { InvalidEntityIdError } from "./errors/InvalidEntityIdError.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,mBAAmB,qCAAqC,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAErE,mBAAmB,iDAAiD,CAAC;AACrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,iDAAiD,CAAC;AAM3F,mBAAmB,2CAA2C,CAAC;AAC/D,OAAO,EAAE,8BAA8B,EAAE,MAAM,2CAA2C,CAAC;AAE3F,mBAAmB,0CAA0C,CAAC;AAC9D,OAAO,EAAE,6BAA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8BAA8B,CAAC;AAEtC,mBAAmB,2BAA2B,CAAC;AAC/C,OAAO,EAAE,8BAA8B,EAAE,MAAM,2BAA2B,CAAC;AAE3E,mBAAmB,kBAAkB,CAAC;AAEtC,mBAAmB,0BAA0B,CAAC;AAC9C,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,uBAAuB,EACvB,wBAAwB,EACxB,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAElC,mBAAmB,kCAAkC,CAAC;AACtD,OAAO,EACL,mBAAmB,EACnB,yBAAyB,GAC1B,MAAM,kCAAkC,CAAC;AAE1C,mBAAmB,wBAAwB,CAAC;AAC5C,OAAO,EACL,yBAAyB,EACzB,mBAAmB,GACpB,MAAM,wBAAwB,CAAC;AAEhC,mBAAmB,4BAA4B,CAAC;AAChD,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,+BAA+B,EAAE,MAAM,6CAA6C,CAAC;AAC9F,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,2BAA2B,EAC3B,2BAA2B,EAC3B,wBAAwB,EACxB,oBAAoB,EACpB,sBAAsB,EACtB,0BAA0B,EAC1B,gCAAgC,EAChC,gBAAgB,EAChB,qBAAqB,EACrB,8BAA8B,EAC9B,kBAAkB,GACnB,MAAM,qCAAqC,CAAC"}
@@ -8,16 +8,21 @@ export type LightAccount<TLightAccountVersion extends LightAccountVersion<"Light
8
8
  export type ToLightAccountParams<TLightAccountVersion extends LightAccountVersion<"LightAccount"> = LightAccountVersion<"LightAccount">> = {
9
9
  client: Client<Transport, Chain, JsonRpcAccount | LocalAccount | undefined>;
10
10
  owner: JsonRpcAccount | LocalAccount;
11
- salt?: bigint;
12
11
  accountAddress?: Address;
13
- factoryAddress?: Address;
12
+ factory?: Address;
14
13
  version?: TLightAccountVersion;
15
- };
14
+ } & ({
15
+ salt?: bigint;
16
+ factoryData?: never;
17
+ } | {
18
+ salt?: never;
19
+ factoryData?: Hex;
20
+ });
16
21
  /**
17
22
  * Creates a light account.
18
23
  *
19
24
  * @param {ToLightAccountParams} param0 - The parameters for creating a light account.
20
25
  * @returns {Promise<LightAccount<TSigner, TLightAccountVersion>>} A light account.
21
26
  */
22
- export declare function toLightAccount<TLightAccountVersion extends LightAccountVersion<"LightAccount"> = LightAccountVersion<"LightAccount">>({ client, owner, salt: salt_, accountAddress: accountAddress_, version, factoryAddress, }: ToLightAccountParams<TLightAccountVersion>): Promise<LightAccount<TLightAccountVersion>>;
27
+ export declare function toLightAccount<TLightAccountVersion extends LightAccountVersion<"LightAccount"> = LightAccountVersion<"LightAccount">>({ client, owner, salt: salt_, accountAddress: accountAddress_, version, factory, factoryData: factoryData_, }: ToLightAccountParams<TLightAccountVersion>): Promise<LightAccount<TLightAccountVersion>>;
23
28
  //# sourceMappingURL=account.d.ts.map