@alchemy/smart-accounts 0.0.0-alpha.6 → 0.0.0-alpha.7

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 (25) hide show
  1. package/dist/esm/light-account/accounts/account.d.ts +2 -2
  2. package/dist/esm/light-account/accounts/account.js +4 -4
  3. package/dist/esm/light-account/accounts/account.js.map +1 -1
  4. package/dist/esm/light-account/accounts/multi-owner-account.d.ts +2 -2
  5. package/dist/esm/light-account/accounts/multi-owner-account.js +3 -3
  6. package/dist/esm/light-account/accounts/multi-owner-account.js.map +1 -1
  7. package/dist/esm/ma-v1/accounts/multi-owner-account.d.ts +2 -2
  8. package/dist/esm/ma-v1/accounts/multi-owner-account.js +3 -3
  9. package/dist/esm/ma-v1/accounts/multi-owner-account.js.map +1 -1
  10. package/dist/esm/ma-v2/accounts/account.d.ts +3 -3
  11. package/dist/esm/ma-v2/accounts/account.js +2 -2
  12. package/dist/esm/ma-v2/accounts/account.js.map +1 -1
  13. package/dist/types/light-account/accounts/account.d.ts +2 -2
  14. package/dist/types/light-account/accounts/account.d.ts.map +1 -1
  15. package/dist/types/light-account/accounts/multi-owner-account.d.ts +2 -2
  16. package/dist/types/light-account/accounts/multi-owner-account.d.ts.map +1 -1
  17. package/dist/types/ma-v1/accounts/multi-owner-account.d.ts +2 -2
  18. package/dist/types/ma-v1/accounts/multi-owner-account.d.ts.map +1 -1
  19. package/dist/types/ma-v2/accounts/account.d.ts +3 -3
  20. package/dist/types/ma-v2/accounts/account.d.ts.map +1 -1
  21. package/package.json +4 -4
  22. package/src/light-account/accounts/account.ts +5 -7
  23. package/src/light-account/accounts/multi-owner-account.ts +4 -4
  24. package/src/ma-v1/accounts/multi-owner-account.ts +4 -4
  25. package/src/ma-v2/accounts/account.ts +4 -4
@@ -10,7 +10,7 @@ export type ToLightAccountParams<TLightAccountVersion extends LightAccountVersio
10
10
  owner: JsonRpcAccount | LocalAccount;
11
11
  salt?: bigint;
12
12
  accountAddress?: Address;
13
- factoryAddress?: Address;
13
+ factory?: Address;
14
14
  factoryData?: Hex;
15
15
  version?: TLightAccountVersion;
16
16
  };
@@ -20,4 +20,4 @@ export type ToLightAccountParams<TLightAccountVersion extends LightAccountVersio
20
20
  * @param {ToLightAccountParams} param0 - The parameters for creating a light account.
21
21
  * @returns {Promise<LightAccount<TSigner, TLightAccountVersion>>} A light account.
22
22
  */
23
- export declare function toLightAccount<TLightAccountVersion extends LightAccountVersion<"LightAccount"> = LightAccountVersion<"LightAccount">>({ client, owner, salt: salt_, accountAddress: accountAddress_, version, factoryAddress, factoryData: factoryData_, }: ToLightAccountParams<TLightAccountVersion>): Promise<LightAccount<TLightAccountVersion>>;
23
+ 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>>;
@@ -17,7 +17,7 @@ import { LOGGER } from "../../logger.js";
17
17
  * @param {ToLightAccountParams} param0 - The parameters for creating a light account.
18
18
  * @returns {Promise<LightAccount<TSigner, TLightAccountVersion>>} A light account.
19
19
  */
20
- export async function toLightAccount({ client, owner, salt: salt_ = 0n, accountAddress: accountAddress_, version = defaultLightAccountVersion(), factoryAddress = AccountVersionRegistry.LightAccount[version].factoryAddress, factoryData: factoryData_, }) {
20
+ export async function toLightAccount({ client, owner, salt: salt_ = 0n, accountAddress: accountAddress_, version = defaultLightAccountVersion(), factory = AccountVersionRegistry.LightAccount[version].factoryAddress, factoryData: factoryData_, }) {
21
21
  LOGGER.debug("toLightAccount:start", {
22
22
  version,
23
23
  hasAccountAddress: !!accountAddress_,
@@ -26,12 +26,12 @@ export async function toLightAccount({ client, owner, salt: salt_ = 0n, accountA
26
26
  const factoryAbi = version === "v2.0.0"
27
27
  ? LightAccountFactoryAbi_v2
28
28
  : LightAccountFactoryAbi_v1;
29
- const salt = LightAccountUnsupported1271Factories.has(lowerAddress(factoryAddress))
29
+ const salt = LightAccountUnsupported1271Factories.has(lowerAddress(factory))
30
30
  ? 0n
31
31
  : salt_;
32
32
  const accountAddress = accountAddress_ ??
33
33
  predictLightAccountAddress({
34
- factoryAddress,
34
+ factoryAddress: factory,
35
35
  salt,
36
36
  ownerAddress: owner.address,
37
37
  version,
@@ -45,7 +45,7 @@ export async function toLightAccount({ client, owner, salt: salt_ = 0n, accountA
45
45
  args: [owner.address, salt],
46
46
  });
47
47
  return {
48
- factory: factoryAddress,
48
+ factory,
49
49
  factoryData,
50
50
  };
51
51
  };
@@ -1 +1 @@
1
- {"version":3,"file":"account.js","sourceRoot":"","sources":["../../../../src/light-account/accounts/account.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,GAQnB,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAEL,sBAAsB,GACvB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,oCAAoC,EACpC,0BAA0B,GAC3B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,kBAAkB,EAAyB,MAAM,WAAW,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAuBzC;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAGlC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3C,MAAM;QACN,KAAK;QACL,GAAG,EAAE,UAAU;QACf,cAAc;QACd,IAAI,EAAE,cAAc;QACpB,OAAO;QACP,cAAc;KACf,CAAC,CAAC;IAEH,OAAO;QACL,GAAG,WAAW;QAEd,uBAAuB,EAAE,CAAC,QAAiB,EAAE,EAAE;YAC7C,OAAO,kBAAkB,CAAC;gBACxB,GAAG,EAAE,UAAU;gBACf,YAAY,EAAE,mBAAmB;gBACjC,IAAI,EAAE,CAAC,QAAQ,CAAC;aACjB,CAAC,CAAC;QACL,CAAC;QAED,KAAK,CAAC,eAAe;YACnB,MAAM,CAAC,KAAK,CAAC,uBAAuB,EAAE,EAAE,cAAc,EAAE,CAAC,CAAC;YAC1D,MAAM,kBAAkB,GAAG,SAAS,CAClC,MAAM,EACN,YAAY,EACZ,cAAc,CACf,CAAC;YACF,MAAM,KAAK,GAAG,MAAM,kBAAkB,CAAC;gBACrC,OAAO,EAAE,cAAc;gBACvB,GAAG,EAAE,UAAU;gBACf,YAAY,EAAE,OAAO;aACtB,CAAC,CAAC;YAEH,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;gBAClB,MAAM,CAAC,KAAK,CAAC,wBAAwB,EAAE,EAAE,cAAc,EAAE,CAAC,CAAC;gBAC3D,MAAM,IAAI,SAAS,CAAC,8BAA8B,CAAC,CAAC;YACtD,CAAC;YAED,MAAM,CAAC,KAAK,CAAC,yBAAyB,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;YACnD,OAAO,KAAK,CAAC;QACf,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import {\n encodeFunctionData,\n type Address,\n type Chain,\n type Client,\n type Hex,\n type JsonRpcAccount,\n type LocalAccount,\n type Transport,\n} from \"viem\";\nimport { readContract } from \"viem/actions\";\nimport { LightAccountAbi_v1 } from \"../abis/LightAccountAbi_v1.js\";\nimport { LightAccountAbi_v2 } from \"../abis/LightAccountAbi_v2.js\";\nimport { LightAccountFactoryAbi_v1 } from \"../abis/LightAccountFactoryAbi_v1.js\";\nimport { LightAccountFactoryAbi_v2 } from \"../abis/LightAccountFactoryAbi_v2.js\";\nimport { predictLightAccountAddress } from \"../predictAddress.js\";\nimport {\n type LightAccountVersion,\n AccountVersionRegistry,\n} from \"../registry.js\";\nimport {\n LightAccountUnsupported1271Factories,\n defaultLightAccountVersion,\n} from \"../utils.js\";\nimport { toLightAccountBase, type LightAccountBase } from \"./base.js\";\nimport { BaseError, lowerAddress } from \"@alchemy/common\";\nimport { getAction } from \"viem/utils\";\nimport { LOGGER } from \"../../logger.js\";\n\nexport type LightAccount<\n TLightAccountVersion extends\n LightAccountVersion<\"LightAccount\"> = LightAccountVersion<\"LightAccount\">,\n> = LightAccountBase<\"LightAccount\", TLightAccountVersion> & {\n encodeTransferOwnership: (newOwner: Address) => Hex;\n getOwnerAddress: () => Promise<Address>;\n};\n\nexport type ToLightAccountParams<\n TLightAccountVersion extends\n LightAccountVersion<\"LightAccount\"> = LightAccountVersion<\"LightAccount\">,\n> = {\n client: Client<Transport, Chain, JsonRpcAccount | LocalAccount | undefined>;\n owner: JsonRpcAccount | LocalAccount;\n salt?: bigint;\n accountAddress?: Address;\n factoryAddress?: Address;\n factoryData?: Hex;\n version?: TLightAccountVersion;\n};\n\n/**\n * Creates a light account.\n *\n * @param {ToLightAccountParams} param0 - The parameters for creating a light account.\n * @returns {Promise<LightAccount<TSigner, TLightAccountVersion>>} A light account.\n */\nexport async function toLightAccount<\n TLightAccountVersion extends\n LightAccountVersion<\"LightAccount\"> = LightAccountVersion<\"LightAccount\">,\n>({\n client,\n owner,\n salt: salt_ = 0n,\n accountAddress: accountAddress_,\n version = defaultLightAccountVersion() as TLightAccountVersion,\n factoryAddress = AccountVersionRegistry.LightAccount[version].factoryAddress,\n factoryData: factoryData_,\n}: ToLightAccountParams<TLightAccountVersion>): Promise<\n LightAccount<TLightAccountVersion>\n> {\n LOGGER.debug(\"toLightAccount:start\", {\n version,\n hasAccountAddress: !!accountAddress_,\n });\n\n const accountAbi =\n version === \"v2.0.0\" ? LightAccountAbi_v2 : LightAccountAbi_v1;\n const factoryAbi =\n version === \"v2.0.0\"\n ? LightAccountFactoryAbi_v2\n : LightAccountFactoryAbi_v1;\n\n const salt = LightAccountUnsupported1271Factories.has(\n lowerAddress(factoryAddress),\n )\n ? 0n\n : salt_;\n\n const accountAddress =\n accountAddress_ ??\n predictLightAccountAddress({\n factoryAddress,\n salt,\n ownerAddress: owner.address,\n version,\n });\n\n LOGGER.debug(\"toLightAccount:address-resolved\", { accountAddress });\n\n const getFactoryArgs = async () => {\n const factoryData =\n factoryData_ ??\n encodeFunctionData({\n abi: factoryAbi,\n functionName: \"createAccount\",\n args: [owner.address, salt],\n });\n\n return {\n factory: factoryAddress,\n factoryData,\n };\n };\n\n const baseAccount = await toLightAccountBase({\n client,\n owner,\n abi: accountAbi,\n accountAddress,\n type: \"LightAccount\",\n version,\n getFactoryArgs,\n });\n\n return {\n ...baseAccount,\n\n encodeTransferOwnership: (newOwner: Address) => {\n return encodeFunctionData({\n abi: accountAbi,\n functionName: \"transferOwnership\",\n args: [newOwner],\n });\n },\n\n async getOwnerAddress(): Promise<Address> {\n LOGGER.debug(\"getOwnerAddress:start\", { accountAddress });\n const readContractAction = getAction(\n client,\n readContract,\n \"readContract\",\n );\n const owner = await readContractAction({\n address: accountAddress,\n abi: accountAbi,\n functionName: \"owner\",\n });\n\n if (owner == null) {\n LOGGER.error(\"getOwnerAddress:failed\", { accountAddress });\n throw new BaseError(\"could not get on-chain owner\");\n }\n\n LOGGER.debug(\"getOwnerAddress:success\", { owner });\n return owner;\n },\n };\n}\n"]}
1
+ {"version":3,"file":"account.js","sourceRoot":"","sources":["../../../../src/light-account/accounts/account.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,GAQnB,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,E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AC,CAAC;YAEH,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;gBAClB,MAAM,CAAC,KAAK,CAAC,wBAAwB,EAAE,EAAE,cAAc,EAAE,CAAC,CAAC;gBAC3D,MAAM,IAAI,SAAS,CAAC,8BAA8B,CAAC,CAAC;YACtD,CAAC;YAED,MAAM,CAAC,KAAK,CAAC,yBAAyB,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;YACnD,OAAO,KAAK,CAAC;QACf,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import {\n encodeFunctionData,\n type Address,\n type Chain,\n type Client,\n type Hex,\n type JsonRpcAccount,\n type LocalAccount,\n type Transport,\n} from \"viem\";\nimport { readContract } from \"viem/actions\";\nimport { LightAccountAbi_v1 } from \"../abis/LightAccountAbi_v1.js\";\nimport { LightAccountAbi_v2 } from \"../abis/LightAccountAbi_v2.js\";\nimport { LightAccountFactoryAbi_v1 } from \"../abis/LightAccountFactoryAbi_v1.js\";\nimport { LightAccountFactoryAbi_v2 } from \"../abis/LightAccountFactoryAbi_v2.js\";\nimport { predictLightAccountAddress } from \"../predictAddress.js\";\nimport {\n type LightAccountVersion,\n AccountVersionRegistry,\n} from \"../registry.js\";\nimport {\n LightAccountUnsupported1271Factories,\n defaultLightAccountVersion,\n} from \"../utils.js\";\nimport { toLightAccountBase, type LightAccountBase } from \"./base.js\";\nimport { BaseError, lowerAddress } from \"@alchemy/common\";\nimport { getAction } from \"viem/utils\";\nimport { LOGGER } from \"../../logger.js\";\n\nexport type LightAccount<\n TLightAccountVersion extends\n LightAccountVersion<\"LightAccount\"> = LightAccountVersion<\"LightAccount\">,\n> = LightAccountBase<\"LightAccount\", TLightAccountVersion> & {\n encodeTransferOwnership: (newOwner: Address) => Hex;\n getOwnerAddress: () => Promise<Address>;\n};\n\nexport type ToLightAccountParams<\n TLightAccountVersion extends\n LightAccountVersion<\"LightAccount\"> = LightAccountVersion<\"LightAccount\">,\n> = {\n client: Client<Transport, Chain, JsonRpcAccount | LocalAccount | undefined>;\n owner: JsonRpcAccount | LocalAccount;\n salt?: bigint;\n accountAddress?: Address;\n factory?: Address;\n factoryData?: Hex;\n version?: TLightAccountVersion;\n};\n\n/**\n * Creates a light account.\n *\n * @param {ToLightAccountParams} param0 - The parameters for creating a light account.\n * @returns {Promise<LightAccount<TSigner, TLightAccountVersion>>} A light account.\n */\nexport async function toLightAccount<\n TLightAccountVersion extends\n LightAccountVersion<\"LightAccount\"> = LightAccountVersion<\"LightAccount\">,\n>({\n client,\n owner,\n salt: salt_ = 0n,\n accountAddress: accountAddress_,\n version = defaultLightAccountVersion() as TLightAccountVersion,\n factory = AccountVersionRegistry.LightAccount[version].factoryAddress,\n factoryData: factoryData_,\n}: ToLightAccountParams<TLightAccountVersion>): Promise<\n LightAccount<TLightAccountVersion>\n> {\n LOGGER.debug(\"toLightAccount:start\", {\n version,\n hasAccountAddress: !!accountAddress_,\n });\n\n const accountAbi =\n version === \"v2.0.0\" ? LightAccountAbi_v2 : LightAccountAbi_v1;\n const factoryAbi =\n version === \"v2.0.0\"\n ? LightAccountFactoryAbi_v2\n : LightAccountFactoryAbi_v1;\n\n const salt = LightAccountUnsupported1271Factories.has(lowerAddress(factory))\n ? 0n\n : salt_;\n\n const accountAddress =\n accountAddress_ ??\n predictLightAccountAddress({\n factoryAddress: factory,\n salt,\n ownerAddress: owner.address,\n version,\n });\n\n LOGGER.debug(\"toLightAccount:address-resolved\", { accountAddress });\n\n const getFactoryArgs = async () => {\n const factoryData =\n factoryData_ ??\n encodeFunctionData({\n abi: factoryAbi,\n functionName: \"createAccount\",\n args: [owner.address, salt],\n });\n\n return {\n factory,\n factoryData,\n };\n };\n\n const baseAccount = await toLightAccountBase({\n client,\n owner,\n abi: accountAbi,\n accountAddress,\n type: \"LightAccount\",\n version,\n getFactoryArgs,\n });\n\n return {\n ...baseAccount,\n\n encodeTransferOwnership: (newOwner: Address) => {\n return encodeFunctionData({\n abi: accountAbi,\n functionName: \"transferOwnership\",\n args: [newOwner],\n });\n },\n\n async getOwnerAddress(): Promise<Address> {\n LOGGER.debug(\"getOwnerAddress:start\", { accountAddress });\n const readContractAction = getAction(\n client,\n readContract,\n \"readContract\",\n );\n const owner = await readContractAction({\n address: accountAddress,\n abi: accountAbi,\n functionName: \"owner\",\n });\n\n if (owner == null) {\n LOGGER.error(\"getOwnerAddress:failed\", { accountAddress });\n throw new BaseError(\"could not get on-chain owner\");\n }\n\n LOGGER.debug(\"getOwnerAddress:success\", { owner });\n return owner;\n },\n };\n}\n"]}
@@ -11,7 +11,7 @@ export type ToMultiOwnerLightAccountParams = {
11
11
  }[]];
12
12
  salt?: bigint;
13
13
  accountAddress?: Address;
14
- factoryAddress?: Address;
14
+ factory?: Address;
15
15
  factoryData?: Hex;
16
16
  };
17
17
  /**
@@ -20,4 +20,4 @@ export type ToMultiOwnerLightAccountParams = {
20
20
  * @param {ToMultiOwnerLightAccountParams} param0 - The parameters for creating a multi-owner light account.
21
21
  * @returns {Promise<MultiOwnerLightAccount<TSigner>>} A multi-owner light account.
22
22
  */
23
- export declare function toMultiOwnerLightAccount({ client, salt, owners, accountAddress: accountAddress_, factoryAddress, factoryData: factoryData_, }: ToMultiOwnerLightAccountParams): Promise<MultiOwnerLightAccount>;
23
+ export declare function toMultiOwnerLightAccount({ client, salt, owners, accountAddress: accountAddress_, factory, factoryData: factoryData_, }: ToMultiOwnerLightAccountParams): Promise<MultiOwnerLightAccount>;
@@ -13,7 +13,7 @@ import { AccountVersionRegistry } from "../registry.js";
13
13
  * @param {ToMultiOwnerLightAccountParams} param0 - The parameters for creating a multi-owner light account.
14
14
  * @returns {Promise<MultiOwnerLightAccount<TSigner>>} A multi-owner light account.
15
15
  */
16
- export async function toMultiOwnerLightAccount({ client, salt = 0n, owners, accountAddress: accountAddress_, factoryAddress = AccountVersionRegistry.MultiOwnerLightAccount["v2.0.0"]
16
+ export async function toMultiOwnerLightAccount({ client, salt = 0n, owners, accountAddress: accountAddress_, factory = AccountVersionRegistry.MultiOwnerLightAccount["v2.0.0"]
17
17
  .factoryAddress, factoryData: factoryData_, }) {
18
18
  const signer = owners[0];
19
19
  const dedupedOwners = Array.from(new Set(owners.map((it) => lowerAddress(it.address))));
@@ -24,7 +24,7 @@ export async function toMultiOwnerLightAccount({ client, salt = 0n, owners, acco
24
24
  });
25
25
  const accountAddress = accountAddress_ ??
26
26
  predictMultiOwnerLightAccountAddress({
27
- factoryAddress,
27
+ factoryAddress: factory,
28
28
  salt,
29
29
  ownerAddresses: sortedOwners,
30
30
  });
@@ -36,7 +36,7 @@ export async function toMultiOwnerLightAccount({ client, salt = 0n, owners, acco
36
36
  args: [sortedOwners, salt],
37
37
  });
38
38
  return {
39
- factory: factoryAddress,
39
+ factory,
40
40
  factoryData,
41
41
  };
42
42
  };
@@ -1 +1 @@
1
- {"version":3,"file":"multi-owner-account.js","sourceRoot":"","sources":["../../../../src/light-account/accounts/multi-owner-account.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,WAAW,GASZ,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAE,gCAAgC,EAAE,MAAM,6CAA6C,CAAC;AAC/F,OAAO,EAAE,oCAAoC,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAyB,MAAM,WAAW,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAsBxD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,EAC7C,MAAM,EACN,IAAI,GAAG,EAAE,EACT,MAAM,EACN,cAAc,EAAE,eAAe,EAC/B,cAAc,GAAG,sBAAsB,CA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;QAC9B,OAAO,EAAE,QAAQ;QACjB,cAAc;KACf,CAAC,CAAC;IAEH,OAAO;QACL,GAAG,WAAW;QAEd,kBAAkB,EAAE,CAAC,WAAsB,EAAE,cAAyB,EAAE,EAAE;YACxE,OAAO,kBAAkB,CAAC;gBACxB,GAAG,EAAE,yBAAyB;gBAC9B,YAAY,EAAE,cAAc;gBAC5B,IAAI,EAAE,CAAC,WAAW,EAAE,cAAc,CAAC;aACpC,CAAC,CAAC;QACL,CAAC;QAED,KAAK,CAAC,iBAAiB;YACrB,MAAM,kBAAkB,GAAG,SAAS,CAClC,MAAM,EACN,YAAY,EACZ,cAAc,CACf,CAAC;YACF,MAAM,aAAa,GAAG,MAAM,kBAAkB,CAAC;gBAC7C,OAAO,EAAE,cAAc;gBACvB,GAAG,EAAE,yBAAyB;gBAC9B,YAAY,EAAE,QAAQ;aACvB,CAAC,CAAC;YAEH,IAAI,aAAa,IAAI,IAAI,EAAE,CAAC;gBAC1B,MAAM,IAAI,SAAS,CAAC,+BAA+B,CAAC,CAAC;YACvD,CAAC;YAED,IACE,CAAC,aAAa;iBACX,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;iBAC7B,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,EACzC,CAAC;gBACD,MAAM,IAAI,SAAS,CACjB,qDAAqD,CACtD,CAAC;YACJ,CAAC;YAED,OAAO,aAAa,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import {\n encodeFunctionData,\n hexToBigInt,\n type Address,\n type Chain,\n type Client,\n type Hex,\n type JsonRpcAccount,\n type LocalAccount,\n type OneOf,\n type Transport,\n} from \"viem\";\nimport { readContract } from \"viem/actions\";\nimport { MultiOwnerLightAccountAbi } from \"../abis/MultiOwnerLightAccountAbi.js\";\nimport { MultiOwnerLightAccountFactoryAbi } from \"../abis/MultiOwnerLightAccountFactoryAbi.js\";\nimport { predictMultiOwnerLightAccountAddress } from \"../predictAddress.js\";\nimport { toLightAccountBase, type LightAccountBase } from \"./base.js\";\nimport { BaseError, lowerAddress } from \"@alchemy/common\";\nimport { getAction } from \"viem/utils\";\nimport { AccountVersionRegistry } from \"../registry.js\";\n\nexport type MultiOwnerLightAccount = LightAccountBase<\n \"MultiOwnerLightAccount\",\n \"v2.0.0\"\n> & {\n encodeUpdateOwners: (\n ownersToAdd: Address[],\n ownersToRemove: Address[],\n ) => Hex;\n getOwnerAddresses: () => Promise<readonly Address[]>;\n};\n\nexport type ToMultiOwnerLightAccountParams = {\n client: Client<Transport, Chain, JsonRpcAccount | LocalAccount | undefined>;\n owners: [OneOf<JsonRpcAccount | LocalAccount>, ...{ address: Address }[]];\n salt?: bigint;\n accountAddress?: Address;\n factoryAddress?: Address;\n factoryData?: Hex;\n};\n\n/**\n * Creates a multi-owner light account.\n *\n * @param {ToMultiOwnerLightAccountParams} param0 - The parameters for creating a multi-owner light account.\n * @returns {Promise<MultiOwnerLightAccount<TSigner>>} A multi-owner light account.\n */\nexport async function toMultiOwnerLightAccount({\n client,\n salt = 0n,\n owners,\n accountAddress: accountAddress_,\n factoryAddress = AccountVersionRegistry.MultiOwnerLightAccount[\"v2.0.0\"]\n .factoryAddress,\n factoryData: factoryData_,\n}: ToMultiOwnerLightAccountParams): Promise<MultiOwnerLightAccount> {\n const signer = owners[0];\n\n const dedupedOwners = Array.from(\n new Set(owners.map((it) => lowerAddress(it.address))),\n );\n\n const sortedOwners = dedupedOwners.sort((a, b) => {\n const bigintA = hexToBigInt(a);\n const bigintB = hexToBigInt(b);\n return bigintA < bigintB ? -1 : bigintA > bigintB ? 1 : 0;\n });\n\n const accountAddress =\n accountAddress_ ??\n predictMultiOwnerLightAccountAddress({\n factoryAddress,\n salt,\n ownerAddresses: sortedOwners,\n });\n\n const getFactoryArgs = async () => {\n const factoryData =\n factoryData_ ??\n encodeFunctionData({\n abi: MultiOwnerLightAccountFactoryAbi,\n functionName: \"createAccount\",\n args: [sortedOwners, salt],\n });\n\n return {\n factory: factoryAddress,\n factoryData,\n };\n };\n\n const baseAccount = await toLightAccountBase({\n client,\n owner: signer,\n abi: MultiOwnerLightAccountAbi,\n accountAddress,\n type: \"MultiOwnerLightAccount\",\n version: \"v2.0.0\",\n getFactoryArgs,\n });\n\n return {\n ...baseAccount,\n\n encodeUpdateOwners: (ownersToAdd: Address[], ownersToRemove: Address[]) => {\n return encodeFunctionData({\n abi: MultiOwnerLightAccountAbi,\n functionName: \"updateOwners\",\n args: [ownersToAdd, ownersToRemove],\n });\n },\n\n async getOwnerAddresses(): Promise<readonly Address[]> {\n const readContractAction = getAction(\n client,\n readContract,\n \"readContract\",\n );\n const ownersOnChain = await readContractAction({\n address: accountAddress,\n abi: MultiOwnerLightAccountAbi,\n functionName: \"owners\",\n });\n\n if (ownersOnChain == null) {\n throw new BaseError(\"could not get on-chain owners\");\n }\n\n if (\n !ownersOnChain\n .map((it) => lowerAddress(it))\n .includes(lowerAddress(signer.address))\n ) {\n throw new BaseError(\n \"on-chain owners does not include the current signer\",\n );\n }\n\n return ownersOnChain;\n },\n };\n}\n"]}
1
+ {"version":3,"file":"multi-owner-account.js","sourceRoot":"","sources":["../../../../src/light-account/accounts/multi-owner-account.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,WAAW,GASZ,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAE,gCAAgC,EAAE,MAAM,6CAA6C,CAAC;AAC/F,OAAO,EAAE,oCAAoC,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAyB,MAAM,WAAW,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACv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hex,\n type JsonRpcAccount,\n type LocalAccount,\n type OneOf,\n type Transport,\n} from \"viem\";\nimport { readContract } from \"viem/actions\";\nimport { MultiOwnerLightAccountAbi } from \"../abis/MultiOwnerLightAccountAbi.js\";\nimport { MultiOwnerLightAccountFactoryAbi } from \"../abis/MultiOwnerLightAccountFactoryAbi.js\";\nimport { predictMultiOwnerLightAccountAddress } from \"../predictAddress.js\";\nimport { toLightAccountBase, type LightAccountBase } from \"./base.js\";\nimport { BaseError, lowerAddress } from \"@alchemy/common\";\nimport { getAction } from \"viem/utils\";\nimport { AccountVersionRegistry } from \"../registry.js\";\n\nexport type MultiOwnerLightAccount = LightAccountBase<\n \"MultiOwnerLightAccount\",\n \"v2.0.0\"\n> & {\n encodeUpdateOwners: (\n ownersToAdd: Address[],\n ownersToRemove: Address[],\n ) => Hex;\n getOwnerAddresses: () => Promise<readonly Address[]>;\n};\n\nexport type ToMultiOwnerLightAccountParams = {\n client: Client<Transport, Chain, JsonRpcAccount | LocalAccount | undefined>;\n owners: [OneOf<JsonRpcAccount | LocalAccount>, ...{ address: Address }[]];\n salt?: bigint;\n accountAddress?: Address;\n factory?: Address;\n factoryData?: Hex;\n};\n\n/**\n * Creates a multi-owner light account.\n *\n * @param {ToMultiOwnerLightAccountParams} param0 - The parameters for creating a multi-owner light account.\n * @returns {Promise<MultiOwnerLightAccount<TSigner>>} A multi-owner light account.\n */\nexport async function toMultiOwnerLightAccount({\n client,\n salt = 0n,\n owners,\n accountAddress: accountAddress_,\n factory = AccountVersionRegistry.MultiOwnerLightAccount[\"v2.0.0\"]\n .factoryAddress,\n factoryData: factoryData_,\n}: ToMultiOwnerLightAccountParams): Promise<MultiOwnerLightAccount> {\n const signer = owners[0];\n\n const dedupedOwners = Array.from(\n new Set(owners.map((it) => lowerAddress(it.address))),\n );\n\n const sortedOwners = dedupedOwners.sort((a, b) => {\n const bigintA = hexToBigInt(a);\n const bigintB = hexToBigInt(b);\n return bigintA < bigintB ? -1 : bigintA > bigintB ? 1 : 0;\n });\n\n const accountAddress =\n accountAddress_ ??\n predictMultiOwnerLightAccountAddress({\n factoryAddress: factory,\n salt,\n ownerAddresses: sortedOwners,\n });\n\n const getFactoryArgs = async () => {\n const factoryData =\n factoryData_ ??\n encodeFunctionData({\n abi: MultiOwnerLightAccountFactoryAbi,\n functionName: \"createAccount\",\n args: [sortedOwners, salt],\n });\n\n return {\n factory,\n factoryData,\n };\n };\n\n const baseAccount = await toLightAccountBase({\n client,\n owner: signer,\n abi: MultiOwnerLightAccountAbi,\n accountAddress,\n type: \"MultiOwnerLightAccount\",\n version: \"v2.0.0\",\n getFactoryArgs,\n });\n\n return {\n ...baseAccount,\n\n encodeUpdateOwners: (ownersToAdd: Address[], ownersToRemove: Address[]) => {\n return encodeFunctionData({\n abi: MultiOwnerLightAccountAbi,\n functionName: \"updateOwners\",\n args: [ownersToAdd, ownersToRemove],\n });\n },\n\n async getOwnerAddresses(): Promise<readonly Address[]> {\n const readContractAction = getAction(\n client,\n readContract,\n \"readContract\",\n );\n const ownersOnChain = await readContractAction({\n address: accountAddress,\n abi: MultiOwnerLightAccountAbi,\n functionName: \"owners\",\n });\n\n if (ownersOnChain == null) {\n throw new BaseError(\"could not get on-chain owners\");\n }\n\n if (\n !ownersOnChain\n .map((it) => lowerAddress(it))\n .includes(lowerAddress(signer.address))\n ) {\n throw new BaseError(\n \"on-chain owners does not include the current signer\",\n );\n }\n\n return ownersOnChain;\n },\n };\n}\n"]}
@@ -11,7 +11,7 @@ export type ToMultiOwnerModularAccountV1Params = {
11
11
  }[]];
12
12
  salt?: bigint;
13
13
  accountAddress?: Address;
14
- factoryAddress?: Address;
14
+ factory?: Address;
15
15
  factoryData?: Hex;
16
16
  };
17
17
  /**
@@ -20,4 +20,4 @@ export type ToMultiOwnerModularAccountV1Params = {
20
20
  * @param {ToMultiOwnerModularAccountV1Params} param0 - The parameters for creating a multi-owner MAv1 account.
21
21
  * @returns {Promise<MultiOwnerModularAccountV1<TSigner>>} A multi-owner MAv1 account.
22
22
  */
23
- export declare function toMultiOwnerModularAccountV1({ client, salt, owners, accountAddress: accountAddress_, factoryAddress, factoryData: factoryData_, }: ToMultiOwnerModularAccountV1Params): Promise<MultiOwnerModularAccountV1>;
23
+ export declare function toMultiOwnerModularAccountV1({ client, salt, owners, accountAddress: accountAddress_, factory, factoryData: factoryData_, }: ToMultiOwnerModularAccountV1Params): Promise<MultiOwnerModularAccountV1>;
@@ -14,7 +14,7 @@ import { MultiOwnerPluginAbi } from "../abis/MultiOwnerPlugin.js";
14
14
  * @param {ToMultiOwnerModularAccountV1Params} param0 - The parameters for creating a multi-owner MAv1 account.
15
15
  * @returns {Promise<MultiOwnerModularAccountV1<TSigner>>} A multi-owner MAv1 account.
16
16
  */
17
- export async function toMultiOwnerModularAccountV1({ client, salt = 0n, owners, accountAddress: accountAddress_, factoryAddress = DefaultMaV1Address.MULTI_OWNER_MAV1_FACTORY, factoryData: factoryData_, }) {
17
+ export async function toMultiOwnerModularAccountV1({ client, salt = 0n, owners, accountAddress: accountAddress_, factory = DefaultMaV1Address.MULTI_OWNER_MAV1_FACTORY, factoryData: factoryData_, }) {
18
18
  const signer = owners[0];
19
19
  const dedupedOwners = Array.from(new Set(owners.map((it) => lowerAddress(it.address))));
20
20
  const sortedOwners = dedupedOwners.sort((a, b) => {
@@ -24,7 +24,7 @@ export async function toMultiOwnerModularAccountV1({ client, salt = 0n, owners,
24
24
  });
25
25
  const accountAddress = accountAddress_ ??
26
26
  predictMultiOwnerModularAccountV1Address({
27
- factoryAddress,
27
+ factoryAddress: factory,
28
28
  salt,
29
29
  ownerAddresses: sortedOwners,
30
30
  });
@@ -36,7 +36,7 @@ export async function toMultiOwnerModularAccountV1({ client, salt = 0n, owners,
36
36
  args: [salt, sortedOwners],
37
37
  });
38
38
  return {
39
- factory: factoryAddress,
39
+ factory,
40
40
  factoryData,
41
41
  };
42
42
  };
@@ -1 +1 @@
1
- {"version":3,"file":"multi-owner-account.js","sourceRoot":"","sources":["../../../../src/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EAAE,GAAG;aACb;YACD,WAAW,EAAE,8BAA8B;SAC5C,CAAC;IACJ,CAAC,CAAC;IAEF,MAAM,WAAW,GAAG,MAAM,sBAAsB,CAAC;QAC/C,MAAM;QACN,KAAK,EAAE,MAAM;QACb,cAAc;QACd,cAAc;QACd,IAAI,EAAE,4BAA4B;QAClC,aAAa;KACd,CAAC,CAAC;IAEH,OAAO;QACL,GAAG,WAAW;QAEd,kBAAkB,EAAE,CAAC,WAAsB,EAAE,cAAyB,EAAE,EAAE;YACxE,OAAO,kBAAkB,CAAC;gBACxB,GAAG,EAAE,oCAAoC;gBACzC,YAAY,EAAE,cAAc;gBAC5B,IAAI,EAAE,CAAC,WAAW,EAAE,cAAc,CAAC;aACpC,CAAC,CAAC;QACL,CAAC;QAED,KAAK,CAAC,iBAAiB;YACrB,MAAM,kBAAkB,GAAG,SAAS,CAClC,MAAM,EACN,YAAY,EACZ,cAAc,CACf,CAAC;YACF,MAAM,aAAa,GAAG,MAAM,kBAAkB,CAAC;gBAC7C,OAAO,EAAE,wBAAwB,CAAC,WAAW;gBAC7C,GAAG,EAAE,mBAAmB;gBACxB,YAAY,EAAE,UAAU;gBACxB,IAAI,EAAE,CAAC,cAAc,CAAC;aACvB,CAAC,CAAC;YAEH,IACE,CAAC,aAAa;iBACX,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;iBAC7B,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,EACzC,CAAC;gBACD,MAAM,IAAI,SAAS,CACjB,qDAAqD,CACtD,CAAC;YACJ,CAAC;YAED,OAAO,aAAa,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import {\n hexToBigInt,\n type Address,\n type Chain,\n type Client,\n type Hex,\n type JsonRpcAccount,\n type LocalAccount,\n type OneOf,\n type Transport,\n encodeFunctionData,\n type Hash,\n type TypedDataDefinition,\n} from \"viem\";\nimport { toModularAccountV1Base, type ModularAccountV1Base } from \"./base.js\";\nimport { lowerAddress, BaseError } from \"@alchemy/common\";\nimport { DefaultMaV1Address, DefaultMaV1PluginAddress } from \"../account.js\";\nimport { MultiOwnerModularAccountFactoryAbi } from \"../abis/MultiOwnerModularAccountFactory.js\";\nimport { predictMultiOwnerModularAccountV1Address } from \"../predictAddress.js\";\nimport { MultiOwnerPluginExecutionFunctionAbi } from \"../abis/MultiOwnerPluginExecutionFunction.js\";\nimport { readContract } from \"viem/actions\";\nimport { getAction } from \"viem/utils\";\nimport { MultiOwnerPluginAbi } from \"../abis/MultiOwnerPlugin.js\";\n\nexport type MultiOwnerModularAccountV1 = ModularAccountV1Base & {\n encodeUpdateOwners: (\n ownersToAdd: Address[],\n ownersToRemove: Address[],\n ) => Hex;\n getOwnerAddresses: () => Promise<readonly Address[]>;\n};\n\nexport type ToMultiOwnerModularAccountV1Params = {\n client: Client<Transport, Chain, JsonRpcAccount | LocalAccount | undefined>;\n owners: [OneOf<JsonRpcAccount | LocalAccount>, ...{ address: Address }[]];\n salt?: bigint;\n accountAddress?: Address;\n factoryAddress?: Address;\n factoryData?: Hex;\n};\n\n/**\n * Creates a multi-owner MAv1 account.\n *\n * @param {ToMultiOwnerModularAccountV1Params} param0 - The parameters for creating a multi-owner MAv1 account.\n * @returns {Promise<MultiOwnerModularAccountV1<TSigner>>} A multi-owner MAv1 account.\n */\nexport async function toMultiOwnerModularAccountV1({\n client,\n salt = 0n,\n owners,\n accountAddress: accountAddress_,\n factoryAddress = DefaultMaV1Address.MULTI_OWNER_MAV1_FACTORY,\n factoryData: factoryData_,\n}: ToMultiOwnerModularAccountV1Params): Promise<MultiOwnerModularAccountV1> {\n const signer = owners[0];\n\n const dedupedOwners = Array.from(\n new Set(owners.map((it) => lowerAddress(it.address))),\n );\n\n const sortedOwners = dedupedOwners.sort((a, b) => {\n const bigintA = hexToBigInt(a);\n const bigintB = hexToBigInt(b);\n return bigintA < bigintB ? -1 : bigintA > bigintB ? 1 : 0;\n });\n\n const accountAddress =\n accountAddress_ ??\n predictMultiOwnerModularAccountV1Address({\n factoryAddress,\n salt,\n ownerAddresses: sortedOwners,\n });\n\n const getFactoryArgs = async () => {\n const factoryData =\n factoryData_ ??\n encodeFunctionData({\n abi: MultiOwnerModularAccountFactoryAbi,\n functionName: \"createAccount\",\n args: [salt, sortedOwners],\n });\n\n return {\n factory: factoryAddress,\n factoryData,\n };\n };\n\n const get712Wrapper = async (msg: Hash): Promise<TypedDataDefinition> => {\n const readContractAction = getAction(client, readContract, \"readContract\");\n\n const [, name, version, chainId, verifyingContract, salt] =\n await readContractAction({\n abi: MultiOwnerPluginAbi,\n address: DefaultMaV1PluginAddress.MULTI_OWNER,\n functionName: \"eip712Domain\",\n account: accountAddress,\n });\n\n return {\n domain: {\n chainId: Number(chainId),\n name,\n salt,\n verifyingContract,\n version,\n },\n types: {\n AlchemyModularAccountMessage: [{ name: \"message\", type: \"bytes\" }],\n },\n message: {\n message: msg,\n },\n primaryType: \"AlchemyModularAccountMessage\",\n };\n };\n\n const baseAccount = await toModularAccountV1Base({\n client,\n owner: signer,\n accountAddress,\n getFactoryArgs,\n type: \"MultiOwnerModularAccountV1\",\n get712Wrapper,\n });\n\n return {\n ...baseAccount,\n\n encodeUpdateOwners: (ownersToAdd: Address[], ownersToRemove: Address[]) => {\n return encodeFunctionData({\n abi: MultiOwnerPluginExecutionFunctionAbi,\n functionName: \"updateOwners\",\n args: [ownersToAdd, ownersToRemove],\n });\n },\n\n async getOwnerAddresses(): Promise<readonly Address[]> {\n const readContractAction = getAction(\n client,\n readContract,\n \"readContract\",\n );\n const ownersOnChain = await readContractAction({\n address: DefaultMaV1PluginAddress.MULTI_OWNER,\n abi: MultiOwnerPluginAbi,\n functionName: \"ownersOf\",\n args: [accountAddress],\n });\n\n if (\n !ownersOnChain\n .map((it) => lowerAddress(it))\n .includes(lowerAddress(signer.address))\n ) {\n throw new BaseError(\n \"on-chain owners does not include the current signer\",\n );\n }\n\n return ownersOnCh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EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;aACnE;YACD,OAAO,EAAE;gBACP,OAAO,EAAE,GAAG;aACb;YACD,WAAW,EAAE,8BAA8B;SAC5C,CAAC;IACJ,CAAC,CAAC;IAEF,MAAM,WAAW,GAAG,MAAM,sBAAsB,CAAC;QAC/C,MAAM;QACN,KAAK,EAAE,MAAM;QACb,cAAc;QACd,cAAc;QACd,IAAI,EAAE,4BAA4B;QAClC,aAAa;KACd,CAAC,CAAC;IAEH,OAAO;QACL,GAAG,WAAW;QAEd,kBAAkB,EAAE,CAAC,WAAsB,EAAE,cAAyB,EAAE,EAAE;YACxE,OAAO,kBAAkB,CAAC;gBACxB,GAAG,EAAE,oCAAoC;gBACzC,YAAY,EAAE,cAAc;gBAC5B,IAAI,EAAE,CAAC,WAAW,EAAE,cAAc,CAAC;aACpC,CAAC,CAAC;QACL,CAAC;QAED,KAAK,CAAC,iBAAiB;YACrB,MAAM,kBAAkB,GAAG,SAAS,CAClC,MAAM,EACN,YAAY,EACZ,cAAc,CACf,CAAC;YACF,MAAM,aAAa,GAAG,MAAM,kBAAkB,CAAC;gBAC7C,OAAO,EAAE,wBAAwB,CAAC,WAAW;gBAC7C,GAAG,EAAE,mBAAmB;gBACxB,YAAY,EAAE,UAAU;gBACxB,IAAI,EAAE,CAAC,cAAc,CAAC;aACvB,CAAC,CAAC;YAEH,IACE,CAAC,aAAa;iBACX,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;iBAC7B,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,EACzC,CAAC;gBACD,MAAM,IAAI,SAAS,CACjB,qDAAqD,CACtD,CAAC;YACJ,CAAC;YAED,OAAO,aAAa,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import {\n hexToBigInt,\n type Address,\n type Chain,\n type Client,\n type Hex,\n type JsonRpcAccount,\n type LocalAccount,\n type OneOf,\n type Transport,\n encodeFunctionData,\n type Hash,\n type TypedDataDefinition,\n} from \"viem\";\nimport { toModularAccountV1Base, type ModularAccountV1Base } from \"./base.js\";\nimport { lowerAddress, BaseError } from \"@alchemy/common\";\nimport { DefaultMaV1Address, DefaultMaV1PluginAddress } from \"../account.js\";\nimport { MultiOwnerModularAccountFactoryAbi } from \"../abis/MultiOwnerModularAccountFactory.js\";\nimport { predictMultiOwnerModularAccountV1Address } from \"../predictAddress.js\";\nimport { MultiOwnerPluginExecutionFunctionAbi } from \"../abis/MultiOwnerPluginExecutionFunction.js\";\nimport { readContract } from \"viem/actions\";\nimport { getAction } from \"viem/utils\";\nimport { MultiOwnerPluginAbi } from \"../abis/MultiOwnerPlugin.js\";\n\nexport type MultiOwnerModularAccountV1 = ModularAccountV1Base & {\n encodeUpdateOwners: (\n ownersToAdd: Address[],\n ownersToRemove: Address[],\n ) => Hex;\n getOwnerAddresses: () => Promise<readonly Address[]>;\n};\n\nexport type ToMultiOwnerModularAccountV1Params = {\n client: Client<Transport, Chain, JsonRpcAccount | LocalAccount | undefined>;\n owners: [OneOf<JsonRpcAccount | LocalAccount>, ...{ address: Address }[]];\n salt?: bigint;\n accountAddress?: Address;\n factory?: Address;\n factoryData?: Hex;\n};\n\n/**\n * Creates a multi-owner MAv1 account.\n *\n * @param {ToMultiOwnerModularAccountV1Params} param0 - The parameters for creating a multi-owner MAv1 account.\n * @returns {Promise<MultiOwnerModularAccountV1<TSigner>>} A multi-owner MAv1 account.\n */\nexport async function toMultiOwnerModularAccountV1({\n client,\n salt = 0n,\n owners,\n accountAddress: accountAddress_,\n factory = DefaultMaV1Address.MULTI_OWNER_MAV1_FACTORY,\n factoryData: factoryData_,\n}: ToMultiOwnerModularAccountV1Params): Promise<MultiOwnerModularAccountV1> {\n const signer = owners[0];\n\n const dedupedOwners = Array.from(\n new Set(owners.map((it) => lowerAddress(it.address))),\n );\n\n const sortedOwners = dedupedOwners.sort((a, b) => {\n const bigintA = hexToBigInt(a);\n const bigintB = hexToBigInt(b);\n return bigintA < bigintB ? -1 : bigintA > bigintB ? 1 : 0;\n });\n\n const accountAddress =\n accountAddress_ ??\n predictMultiOwnerModularAccountV1Address({\n factoryAddress: factory,\n salt,\n ownerAddresses: sortedOwners,\n });\n\n const getFactoryArgs = async () => {\n const factoryData =\n factoryData_ ??\n encodeFunctionData({\n abi: MultiOwnerModularAccountFactoryAbi,\n functionName: \"createAccount\",\n args: [salt, sortedOwners],\n });\n\n return {\n factory,\n factoryData,\n };\n };\n\n const get712Wrapper = async (msg: Hash): Promise<TypedDataDefinition> => {\n const readContractAction = getAction(client, readContract, \"readContract\");\n\n const [, name, version, chainId, verifyingContract, salt] =\n await readContractAction({\n abi: MultiOwnerPluginAbi,\n address: DefaultMaV1PluginAddress.MULTI_OWNER,\n functionName: \"eip712Domain\",\n account: accountAddress,\n });\n\n return {\n domain: {\n chainId: Number(chainId),\n name,\n salt,\n verifyingContract,\n version,\n },\n types: {\n AlchemyModularAccountMessage: [{ name: \"message\", type: \"bytes\" }],\n },\n message: {\n message: msg,\n },\n primaryType: \"AlchemyModularAccountMessage\",\n };\n };\n\n const baseAccount = await toModularAccountV1Base({\n client,\n owner: signer,\n accountAddress,\n getFactoryArgs,\n type: \"MultiOwnerModularAccountV1\",\n get712Wrapper,\n });\n\n return {\n ...baseAccount,\n\n encodeUpdateOwners: (ownersToAdd: Address[], ownersToRemove: Address[]) => {\n return encodeFunctionData({\n abi: MultiOwnerPluginExecutionFunctionAbi,\n functionName: \"updateOwners\",\n args: [ownersToAdd, ownersToRemove],\n });\n },\n\n async getOwnerAddresses(): Promise<readonly Address[]> {\n const readContractAction = getAction(\n client,\n readContract,\n \"readContract\",\n );\n const ownersOnChain = await readContractAction({\n address: DefaultMaV1PluginAddress.MULTI_OWNER,\n abi: MultiOwnerPluginAbi,\n functionName: \"ownersOf\",\n args: [accountAddress],\n });\n\n if (\n !ownersOnChain\n .map((it) => lowerAddress(it))\n .includes(lowerAddress(signer.address))\n ) {\n throw new BaseError(\n \"on-chain owners does not include the current signer\",\n );\n }\n\n return ownersOnChain;\n },\n };\n}\n"]}
@@ -13,12 +13,12 @@ export type ToModularAccountV2Params<TMode extends Mode | undefined = Mode | und
13
13
  mode?: TMode;
14
14
  } & (TMode extends "7702" ? {
15
15
  salt?: never;
16
- factoryAddress?: never;
16
+ factory?: never;
17
17
  factoryData?: never;
18
18
  implementationAddress?: never;
19
19
  } : {
20
20
  salt?: bigint;
21
- factoryAddress?: Address;
21
+ factory?: Address;
22
22
  factoryData?: Hex;
23
23
  implementationAddress?: Address;
24
24
  });
@@ -28,5 +28,5 @@ export type ToModularAccountV2Params<TMode extends Mode | undefined = Mode | und
28
28
  * @param {ToModularAccountV2Params} param0 - The parameters for creating a MAv2 account.
29
29
  * @returns {Promise<ModularAccountV2>} A MAv2 account.
30
30
  */
31
- export declare function toModularAccountV2<TMode extends Mode = Mode>({ client, owner, deferredAction, signerEntity, accountAddress: accountAddress_, salt, factoryAddress: factoryAddress_, factoryData: factoryData_, implementationAddress: implementationAddress_, mode, }: ToModularAccountV2Params<TMode>): Promise<ModularAccountV2>;
31
+ export declare function toModularAccountV2<TMode extends Mode = Mode>({ client, owner, deferredAction, signerEntity, accountAddress: accountAddress_, salt, factory, factoryData: factoryData_, implementationAddress: implementationAddress_, mode, }: ToModularAccountV2Params<TMode>): Promise<ModularAccountV2>;
32
32
  export {};
@@ -14,7 +14,7 @@ import { LOGGER } from "../../logger.js";
14
14
  * @param {ToModularAccountV2Params} param0 - The parameters for creating a MAv2 account.
15
15
  * @returns {Promise<ModularAccountV2>} A MAv2 account.
16
16
  */
17
- export async function toModularAccountV2({ client, owner, deferredAction, signerEntity, accountAddress: accountAddress_, salt = 0n, factoryAddress: factoryAddress_, factoryData: factoryData_, implementationAddress: implementationAddress_, mode, }) {
17
+ export async function toModularAccountV2({ client, owner, deferredAction, signerEntity, accountAddress: accountAddress_, salt = 0n, factory, factoryData: factoryData_, implementationAddress: implementationAddress_, mode, }) {
18
18
  const is7702 = mode === "7702";
19
19
  LOGGER.debug("toModularAccountV2:start", {
20
20
  ownerType: owner.type,
@@ -23,7 +23,7 @@ export async function toModularAccountV2({ client, owner, deferredAction, signer
23
23
  hasAccountAddress: !!accountAddress_,
24
24
  });
25
25
  const entityId = signerEntity?.entityId ?? DEFAULT_OWNER_ENTITY_ID;
26
- const factoryAddress = factoryAddress_ ??
26
+ const factoryAddress = factory ??
27
27
  (owner.type === "webAuthn"
28
28
  ? DefaultAddress.MAV2_FACTORY_WEBAUTHN
29
29
  : DefaultAddress.MAV2_FACTORY);
@@ -1 +1 @@
1
- {"version":3,"file":"account.js","sourceRoot":"","sources":["../../../../src/ma-v2/accounts/account.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,GASnB,MAAM,MAAM,CAAC;AAKd,OAAO,EAAE,sBAAsB,EAA6B,MAAM,WAAW,CAAC;AAE9E,OAAO,EAAE,8BAA8B,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AA8BzC;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAA4B,EAClE,MAAM,EACN,KAAK,EACL,cAAc,EACd,YAAY,EACZ,cAAc,EAAE,eAAe,EAC/B,IAAI,GAAG,EAAE,EACT,cAAc,EAAE,eAAe,EAC/B,WAAW,EAAE,YAAY,EACzB,qBAAqB,EAAE,sBAAsB,EAC7C,IAAI,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I,gCAAgC,CAC5D,CAAC;QACJ,CAAC;QACD,IAAI,KAAK,CAAC,iBAAiB,IAAI,IAAI,EAAE,CAAC;YACpC,MAAM,CAAC,KAAK,CAAC,8CAA8C,CAAC,CAAC;YAC7D,MAAM,IAAI,iBAAiB,CACzB,qEAAqE,CACtE,CAAC;QACJ,CAAC;QACD,IACE,QAAQ,KAAK,uBAAuB;YACpC,KAAK,CAAC,OAAO,KAAK,cAAc,EAChC,CAAC;YACD,MAAM,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC;YACtD,MAAM,IAAI,qBAAqB,EAAE,CAAC;QACpC,CAAC;QACD,aAAa,GAAG;YACd,iEAAiE;YACjE,+DAA+D;YAC/D,wCAAwC;YACxC,OAAO,EAAE,KAA0B;YACnC,OAAO,EAAE,cAAc,CAAC,UAAU;SACnC,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,sBAAsB,CAAC;QACxC,MAAM;QACN,KAAK;QACL,cAAc;QACd,cAAc;QACd,YAAY;QACZ,cAAc;QACd,aAAa;KACd,CAAC,CAAC;IAEH,OAAO;QACL,GAAG,IAAI;QACP,sFAAsF;KACvF,CAAC;AACJ,CAAC","sourcesContent":["import {\n encodeFunctionData,\n type Address,\n type Chain,\n type Client,\n type Hex,\n type JsonRpcAccount,\n type LocalAccount,\n type PrivateKeyAccount,\n type Transport,\n} from \"viem\";\nimport type {\n WebAuthnAccount,\n ToSmartAccountParameters,\n} from \"viem/account-abstraction\";\nimport { toModularAccountV2Base, type ModularAccountV2Base } from \"./base.js\";\nimport type { SignerEntity } from \"../types.js\";\nimport { predictModularAccountV2Address } from \"../predictAddress.js\";\nimport { parsePublicKey } from \"webauthn-p256\";\nimport { accountFactoryAbi } from \"../abis/accountFactoryAbi.js\";\nimport { webAuthnFactoryAbi } from \"../abis/webAuthnFactoryAbi.js\";\nimport { EntityIdOverrideError } from \"../../errors/EntityIdOverrideError.js\";\nimport { InvalidOwnerError } from \"../../errors/InvalidOwnerError.js\";\nimport { DEFAULT_OWNER_ENTITY_ID, DefaultAddress } from \"../utils/account.js\";\nimport { LOGGER } from \"../../logger.js\";\n\ntype Mode = \"default\" | \"7702\";\n\n// TODO(v5): does this need to be extended w/ any more methods like LightAccount does?\nexport type ModularAccountV2 = ModularAccountV2Base & {};\n\nexport type ToModularAccountV2Params<\n TMode extends Mode | undefined = Mode | undefined,\n> = {\n client: Client<Transport, Chain, JsonRpcAccount | LocalAccount | undefined>;\n owner: JsonRpcAccount | LocalAccount | WebAuthnAccount;\n deferredAction?: Hex;\n signerEntity?: SignerEntity;\n accountAddress?: Address;\n mode?: TMode;\n} & (TMode extends \"7702\"\n ? {\n salt?: never;\n factoryAddress?: never;\n factoryData?: never;\n implementationAddress?: never;\n }\n : {\n salt?: bigint;\n factoryAddress?: Address;\n factoryData?: Hex;\n implementationAddress?: Address;\n });\n\n/**\n * Creates a MAv2 account.\n *\n * @param {ToModularAccountV2Params} param0 - The parameters for creating a MAv2 account.\n * @returns {Promise<ModularAccountV2>} A MAv2 account.\n */\nexport async function toModularAccountV2<TMode extends Mode = Mode>({\n client,\n owner,\n deferredAction,\n signerEntity,\n accountAddress: accountAddress_,\n salt = 0n,\n factoryAddress: factoryAddress_,\n factoryData: factoryData_,\n implementationAddress: implementationAddress_,\n mode,\n}: ToModularAccountV2Params<TMode>): Promise<ModularAccountV2> {\n const is7702 = mode === \"7702\";\n\n LOGGER.debug(\"toModularAccountV2:start\", {\n ownerType: owner.type,\n mode,\n hasDeferredAction: !!deferredAction,\n hasAccountAddress: !!accountAddress_,\n });\n\n const entityId = signerEntity?.entityId ?? DEFAULT_OWNER_ENTITY_ID;\n\n const factoryAddress =\n factoryAddress_ ??\n (owner.type === \"webAuthn\"\n ? DefaultAddress.MAV2_FACTORY_WEBAUTHN\n : DefaultAddress.MAV2_FACTORY);\n\n const implementationAddress =\n implementationAddress_ ??\n (is7702\n ? DefaultAddress.SMAV2_7702\n : owner.type === \"webAuthn\"\n ? DefaultAddress.MAV2\n : DefaultAddress.SMAV2_BYTECODE);\n\n const getFactoryArgs = async () => {\n if (is7702) {\n // This is only for EP 0.8.0.\n // return {\n // factory: \"0x7702\",\n // factoryData: \"0x\",\n // } as const;\n return {\n factory: undefined,\n factoryData: undefined,\n } as const;\n }\n\n if (owner.type === \"webAuthn\") {\n const { x, y } = parsePublicKey(owner.publicKey);\n return {\n factory: factoryAddress,\n factoryData:\n factoryData_ ??\n encodeFunctionData({\n abi: webAuthnFactoryAbi,\n functionName: \"createWebAuthnAccount\",\n args: [x, y, salt, entityId],\n }),\n };\n }\n\n return {\n factory: factoryAddress,\n factoryData:\n factoryData_ ??\n encodeFunctionData({\n abi: accountFactoryAbi,\n functionName: \"createSemiModularAccount\",\n args: [owner.address, salt],\n }),\n };\n };\n\n const accountAddress =\n accountAddress_ ??\n (mode === \"7702\" && owner.type === \"local\"\n ? owner.address\n : predictModularAccountV2Address({\n factoryAddress,\n implementationAddress,\n salt,\n ...(owner.type === \"webAuthn\"\n ? {\n type: \"WebAuthn\",\n ownerPublicKey: owner.publicKey,\n entityId,\n }\n : {\n type: \"SMA\", // `MA` is never used here since we only support deploying SMA & WebAuthn accounts.\n ownerAddress: owner.address,\n entityId,\n }),\n }));\n\n LOGGER.debug(\"toModularAccountV2:address-resolved\", {\n accountAddress,\n is7702,\n });\n\n let authorization: ToSmartAccountParameters[\"authorization\"];\n if (is7702) {\n LOGGER.debug(\"toModularAccountV2:7702-mode\");\n // TODO(v5): Ensure this works w/ our signer types.\n if (owner.type !== \"local\") {\n LOGGER.error(\"toModularAccountV2:invalid-owner-type\", {\n ownerType: owner.type,\n });\n throw new InvalidOwnerError(\n `Owner of type ${owner.type} is unsupported for 7702 mode.`,\n );\n }\n if (owner.signAuthorization == null) {\n LOGGER.error(\"toModularAccountV2:missing-signAuthorization\");\n throw new InvalidOwnerError(\n \"Owner must implement `signAuthorization` to be used with 7702 mode.\",\n );\n }\n if (\n entityId === DEFAULT_OWNER_ENTITY_ID &&\n owner.address !== accountAddress\n ) {\n LOGGER.error(\"toModularAccountV2:entity-id-override\");\n throw new EntityIdOverrideError();\n }\n authorization = {\n // The current version of Viem has some pretty strict constraints\n // on a `PrivateKeyAccount`, but this seems safe as long as the\n // owner is able to `signAuthorization`.\n account: owner as PrivateKeyAccount,\n address: DefaultAddress.SMAV2_7702,\n };\n }\n\n const base = await toModularAccountV2Base({\n client,\n owner,\n accountAddress,\n getFactoryArgs,\n signerEntity,\n deferredAction,\n authorization,\n });\n\n return {\n ...base,\n // TODO(v5): does this need to be extended w/ any more methods like LightAccount does?\n };\n}\n"]}
1
+ {"version":3,"file":"account.js","sourceRoot":"","sources":["../../../../src/ma-v2/accounts/account.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,GASnB,MAAM,MAAM,CAAC;AAKd,OAAO,EAAE,sBAAsB,EAA6B,MAAM,WAAW,CAAC;AAE9E,OAAO,EAAE,8BAA8B,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AA8BzC;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAA4B,EAClE,MAAM,EACN,KAAK,EACL,cAAc,EACd,YAAY,EACZ,cAAc,EAAE,eAAe,EAC/B,IAAI,GAAG,EAAE,EACT,OAAO,EACP,WAAW,EAAE,YAAY,EACzB,qBAAqB,EAAE,sBAAsB,EAC7C,IAAI,GAC4B;IAChC,MAAM,MAAM,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ACJ,CAAC;QACD,IAAI,KAAK,CAAC,iBAAiB,IAAI,IAAI,EAAE,CAAC;YACpC,MAAM,CAAC,KAAK,CAAC,8CAA8C,CAAC,CAAC;YAC7D,MAAM,IAAI,iBAAiB,CACzB,qEAAqE,CACtE,CAAC;QACJ,CAAC;QACD,IACE,QAAQ,KAAK,uBAAuB;YACpC,KAAK,CAAC,OAAO,KAAK,cAAc,EAChC,CAAC;YACD,MAAM,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC;YACtD,MAAM,IAAI,qBAAqB,EAAE,CAAC;QACpC,CAAC;QACD,aAAa,GAAG;YACd,iEAAiE;YACjE,+DAA+D;YAC/D,wCAAwC;YACxC,OAAO,EAAE,KAA0B;YACnC,OAAO,EAAE,cAAc,CAAC,UAAU;SACnC,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,sBAAsB,CAAC;QACxC,MAAM;QACN,KAAK;QACL,cAAc;QACd,cAAc;QACd,YAAY;QACZ,cAAc;QACd,aAAa;KACd,CAAC,CAAC;IAEH,OAAO;QACL,GAAG,IAAI;QACP,sFAAsF;KACvF,CAAC;AACJ,CAAC","sourcesContent":["import {\n encodeFunctionData,\n type Address,\n type Chain,\n type Client,\n type Hex,\n type JsonRpcAccount,\n type LocalAccount,\n type PrivateKeyAccount,\n type Transport,\n} from \"viem\";\nimport type {\n WebAuthnAccount,\n ToSmartAccountParameters,\n} from \"viem/account-abstraction\";\nimport { toModularAccountV2Base, type ModularAccountV2Base } from \"./base.js\";\nimport type { SignerEntity } from \"../types.js\";\nimport { predictModularAccountV2Address } from \"../predictAddress.js\";\nimport { parsePublicKey } from \"webauthn-p256\";\nimport { accountFactoryAbi } from \"../abis/accountFactoryAbi.js\";\nimport { webAuthnFactoryAbi } from \"../abis/webAuthnFactoryAbi.js\";\nimport { EntityIdOverrideError } from \"../../errors/EntityIdOverrideError.js\";\nimport { InvalidOwnerError } from \"../../errors/InvalidOwnerError.js\";\nimport { DEFAULT_OWNER_ENTITY_ID, DefaultAddress } from \"../utils/account.js\";\nimport { LOGGER } from \"../../logger.js\";\n\ntype Mode = \"default\" | \"7702\";\n\n// TODO(v5): does this need to be extended w/ any more methods like LightAccount does?\nexport type ModularAccountV2 = ModularAccountV2Base & {};\n\nexport type ToModularAccountV2Params<\n TMode extends Mode | undefined = Mode | undefined,\n> = {\n client: Client<Transport, Chain, JsonRpcAccount | LocalAccount | undefined>;\n owner: JsonRpcAccount | LocalAccount | WebAuthnAccount;\n deferredAction?: Hex;\n signerEntity?: SignerEntity;\n accountAddress?: Address;\n mode?: TMode;\n} & (TMode extends \"7702\"\n ? {\n salt?: never;\n factory?: never;\n factoryData?: never;\n implementationAddress?: never;\n }\n : {\n salt?: bigint;\n factory?: Address;\n factoryData?: Hex;\n implementationAddress?: Address;\n });\n\n/**\n * Creates a MAv2 account.\n *\n * @param {ToModularAccountV2Params} param0 - The parameters for creating a MAv2 account.\n * @returns {Promise<ModularAccountV2>} A MAv2 account.\n */\nexport async function toModularAccountV2<TMode extends Mode = Mode>({\n client,\n owner,\n deferredAction,\n signerEntity,\n accountAddress: accountAddress_,\n salt = 0n,\n factory,\n factoryData: factoryData_,\n implementationAddress: implementationAddress_,\n mode,\n}: ToModularAccountV2Params<TMode>): Promise<ModularAccountV2> {\n const is7702 = mode === \"7702\";\n\n LOGGER.debug(\"toModularAccountV2:start\", {\n ownerType: owner.type,\n mode,\n hasDeferredAction: !!deferredAction,\n hasAccountAddress: !!accountAddress_,\n });\n\n const entityId = signerEntity?.entityId ?? DEFAULT_OWNER_ENTITY_ID;\n\n const factoryAddress =\n factory ??\n (owner.type === \"webAuthn\"\n ? DefaultAddress.MAV2_FACTORY_WEBAUTHN\n : DefaultAddress.MAV2_FACTORY);\n\n const implementationAddress =\n implementationAddress_ ??\n (is7702\n ? DefaultAddress.SMAV2_7702\n : owner.type === \"webAuthn\"\n ? DefaultAddress.MAV2\n : DefaultAddress.SMAV2_BYTECODE);\n\n const getFactoryArgs = async () => {\n if (is7702) {\n // This is only for EP 0.8.0.\n // return {\n // factory: \"0x7702\",\n // factoryData: \"0x\",\n // } as const;\n return {\n factory: undefined,\n factoryData: undefined,\n } as const;\n }\n\n if (owner.type === \"webAuthn\") {\n const { x, y } = parsePublicKey(owner.publicKey);\n return {\n factory: factoryAddress,\n factoryData:\n factoryData_ ??\n encodeFunctionData({\n abi: webAuthnFactoryAbi,\n functionName: \"createWebAuthnAccount\",\n args: [x, y, salt, entityId],\n }),\n };\n }\n\n return {\n factory: factoryAddress,\n factoryData:\n factoryData_ ??\n encodeFunctionData({\n abi: accountFactoryAbi,\n functionName: \"createSemiModularAccount\",\n args: [owner.address, salt],\n }),\n };\n };\n\n const accountAddress =\n accountAddress_ ??\n (mode === \"7702\" && owner.type === \"local\"\n ? owner.address\n : predictModularAccountV2Address({\n factoryAddress,\n implementationAddress,\n salt,\n ...(owner.type === \"webAuthn\"\n ? {\n type: \"WebAuthn\",\n ownerPublicKey: owner.publicKey,\n entityId,\n }\n : {\n type: \"SMA\", // `MA` is never used here since we only support deploying SMA & WebAuthn accounts.\n ownerAddress: owner.address,\n entityId,\n }),\n }));\n\n LOGGER.debug(\"toModularAccountV2:address-resolved\", {\n accountAddress,\n is7702,\n });\n\n let authorization: ToSmartAccountParameters[\"authorization\"];\n if (is7702) {\n LOGGER.debug(\"toModularAccountV2:7702-mode\");\n // TODO(v5): Ensure this works w/ our signer types.\n if (owner.type !== \"local\") {\n LOGGER.error(\"toModularAccountV2:invalid-owner-type\", {\n ownerType: owner.type,\n });\n throw new InvalidOwnerError(\n `Owner of type ${owner.type} is unsupported for 7702 mode.`,\n );\n }\n if (owner.signAuthorization == null) {\n LOGGER.error(\"toModularAccountV2:missing-signAuthorization\");\n throw new InvalidOwnerError(\n \"Owner must implement `signAuthorization` to be used with 7702 mode.\",\n );\n }\n if (\n entityId === DEFAULT_OWNER_ENTITY_ID &&\n owner.address !== accountAddress\n ) {\n LOGGER.error(\"toModularAccountV2:entity-id-override\");\n throw new EntityIdOverrideError();\n }\n authorization = {\n // The current version of Viem has some pretty strict constraints\n // on a `PrivateKeyAccount`, but this seems safe as long as the\n // owner is able to `signAuthorization`.\n account: owner as PrivateKeyAccount,\n address: DefaultAddress.SMAV2_7702,\n };\n }\n\n const base = await toModularAccountV2Base({\n client,\n owner,\n accountAddress,\n getFactoryArgs,\n signerEntity,\n deferredAction,\n authorization,\n });\n\n return {\n ...base,\n // TODO(v5): does this need to be extended w/ any more methods like LightAccount does?\n };\n}\n"]}
@@ -10,7 +10,7 @@ export type ToLightAccountParams<TLightAccountVersion extends LightAccountVersio
10
10
  owner: JsonRpcAccount | LocalAccount;
11
11
  salt?: bigint;
12
12
  accountAddress?: Address;
13
- factoryAddress?: Address;
13
+ factory?: Address;
14
14
  factoryData?: Hex;
15
15
  version?: TLightAccountVersion;
16
16
  };
@@ -20,5 +20,5 @@ export type ToLightAccountParams<TLightAccountVersion extends LightAccountVersio
20
20
  * @param {ToLightAccountParams} param0 - The parameters for creating a light account.
21
21
  * @returns {Promise<LightAccount<TSigner, TLightAccountVersion>>} A light account.
22
22
  */
23
- export declare function toLightAccount<TLightAccountVersion extends LightAccountVersion<"LightAccount"> = LightAccountVersion<"LightAccount">>({ client, owner, salt: salt_, accountAddress: accountAddress_, version, factoryAddress, factoryData: factoryData_, }: ToLightAccountParams<TLightAccountVersion>): Promise<LightAccount<TLightAccountVersion>>;
23
+ 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>>;
24
24
  //# sourceMappingURL=account.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../../../src/light-account/accounts/account.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,MAAM,EACX,KAA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AmB,CAAC,cAAc,CAAC,EAC3E,EACA,MAAM,EACN,KAAK,EACL,IAAI,EAAE,KAAU,EAChB,cAAc,EAAE,eAAe,EAC/B,OAA8D,EAC9D,OAAqE,EACrE,WAAW,EAAE,YAAY,GAC1B,EAAE,oBAAoB,CAAC,oBAAoB,CAAC,GAAG,OAAO,CACrD,YAAY,CAAC,oBAAoB,CAAC,CACnC,CAsFA"}
@@ -11,7 +11,7 @@ export type ToMultiOwnerLightAccountParams = {
11
11
  }[]];
12
12
  salt?: bigint;
13
13
  accountAddress?: Address;
14
- factoryAddress?: Address;
14
+ factory?: Address;
15
15
  factoryData?: Hex;
16
16
  };
17
17
  /**
@@ -20,5 +20,5 @@ export type ToMultiOwnerLightAccountParams = {
20
20
  * @param {ToMultiOwnerLightAccountParams} param0 - The parameters for creating a multi-owner light account.
21
21
  * @returns {Promise<MultiOwnerLightAccount<TSigner>>} A multi-owner light account.
22
22
  */
23
- export declare function toMultiOwnerLightAccount({ client, salt, owners, accountAddress: accountAddress_, factoryAddress, factoryData: factoryData_, }: ToMultiOwnerLightAccountParams): Promise<MultiOwnerLightAccount>;
23
+ export declare function toMultiOwnerLightAccount({ client, salt, owners, accountAddress: accountAddress_, factory, factoryData: factoryData_, }: ToMultiOwnerLightAccountParams): Promise<MultiOwnerLightAccount>;
24
24
  //# sourceMappingURL=multi-owner-account.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"multi-owner-account.d.ts","sourceRoot":"","sources":["../../../../src/light-account/accounts/multi-owner-account.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,MAAM,EACX,KAAK,GAAG,EACR,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,KAAK,EACV,KAAK,SAAS,EACf,MAAM,MAAM,CAAC;AAKd,OAAO,EAAsB,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAKtE,MAAM,MAAM,sBAAsB,GAAG,gBAAgB,CACnD,wBAAwB,EACxB,QAAQ,CACT,GAAG;IACF,kBAAkB,EAAE,CAClB,WAAW,EAAE,OAAO,EAAE,EACtB,cAAc,EAAE,OAAO,EAAE,KACtB,GAAG,CAAC;IACT,iBAAiB,EAAE,MAAM,OAAO,CAAC,SAAS,OAAO,EAAE,CAAC,CAAC;CACtD,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE,KAAK,EAAE,cAAc,GAAG,YAAY,GAAG,SAAS,CAAC,CAAC;IAC5E,MAAM,EAAE,CAAC,KAAK,CAAC,cAAc,GAAG,YAAY,CAAC,EAAE,GAAG;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,EAAE,CAAC,CAAC;IAC1E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,WAAW,CAAC,EAAE,GAAG,CAAC;CACnB,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAAC,EAC7C,MAAM,EACN,IAAS,EACT,MAAM,EACN,cAAc,EAAE,eAAe,EAC/B,cACiB,EACjB,WAAW,EAAE,YAAY,GAC1B,EAAE,8BAA8B,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAsFlE"}
1
+ {"version":3,"file":"multi-owner-account.d.ts","sourceRoot":"","sources":["../../../../src/light-account/accounts/multi-owner-account.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,MAAM,EACX,KAAK,GAAG,EACR,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,KAAK,EACV,KAAK,SAAS,EACf,MAAM,MAAM,CAAC;AAKd,OAAO,EAAsB,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAKtE,MAAM,MAAM,sBAAsB,GAAG,gBAAgB,CACnD,wBAAwB,EACxB,QAAQ,CACT,GAAG;IACF,kBAAkB,EAAE,CAClB,WAAW,EAAE,OAAO,EAAE,EACtB,cAAc,EAAE,OAAO,EAAE,KACtB,GAAG,CAAC;IACT,iBAAiB,EAAE,MAAM,OAAO,CAAC,SAAS,OAAO,EAAE,CAAC,CAAC;CACtD,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE,KAAK,EAAE,cAAc,GAAG,YAAY,GAAG,SAAS,CAAC,CAAC;IAC5E,MAAM,EAAE,CAAC,KAAK,CAAC,cAAc,GAAG,YAAY,CAAC,EAAE,GAAG;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,EAAE,CAAC,CAAC;IAC1E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,GAAG,CAAC;CACnB,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAAC,EAC7C,MAAM,EACN,IAAS,EACT,MAAM,EACN,cAAc,EAAE,eAAe,EAC/B,OACiB,EACjB,WAAW,EAAE,YAAY,GAC1B,EAAE,8BAA8B,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAsFlE"}
@@ -11,7 +11,7 @@ export type ToMultiOwnerModularAccountV1Params = {
11
11
  }[]];
12
12
  salt?: bigint;
13
13
  accountAddress?: Address;
14
- factoryAddress?: Address;
14
+ factory?: Address;
15
15
  factoryData?: Hex;
16
16
  };
17
17
  /**
@@ -20,5 +20,5 @@ export type ToMultiOwnerModularAccountV1Params = {
20
20
  * @param {ToMultiOwnerModularAccountV1Params} param0 - The parameters for creating a multi-owner MAv1 account.
21
21
  * @returns {Promise<MultiOwnerModularAccountV1<TSigner>>} A multi-owner MAv1 account.
22
22
  */
23
- export declare function toMultiOwnerModularAccountV1({ client, salt, owners, accountAddress: accountAddress_, factoryAddress, factoryData: factoryData_, }: ToMultiOwnerModularAccountV1Params): Promise<MultiOwnerModularAccountV1>;
23
+ export declare function toMultiOwnerModularAccountV1({ client, salt, owners, accountAddress: accountAddress_, factory, factoryData: factoryData_, }: ToMultiOwnerModularAccountV1Params): Promise<MultiOwnerModularAccountV1>;
24
24
  //# sourceMappingURL=multi-owner-account.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"multi-owner-account.d.ts","sourceRoot":"","sources":["../../../../src/ma-v1/accounts/multi-owner-account.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,MAAM,EACX,KAAK,GAAG,EACR,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,KAAK,EACV,KAAK,SAAS,EAIf,MAAM,MAAM,CAAC;AACd,OAAO,EAA0B,KAAK,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAU9E,MAAM,MAAM,0BAA0B,GAAG,oBAAoB,GAAG;IAC9D,kBAAkB,EAAE,CAClB,WAAW,EAAE,OAAO,EAAE,EACtB,cAAc,EAAE,OAAO,EAAE,KACtB,GAAG,CAAC;IACT,iBAAiB,EAAE,MAAM,OAAO,CAAC,SAAS,OAAO,EAAE,CAAC,CAAC;CACtD,CAAC;AAEF,MAAM,MAAM,kCAAkC,GAAG;IAC/C,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE,KAAK,EAAE,cAAc,GAAG,YAAY,GAAG,SAAS,CAAC,CAAC;IAC5E,MAAM,EAAE,CAAC,KAAK,CAAC,cAAc,GAAG,YAAY,CAAC,EAAE,GAAG;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,EAAE,CAAC,CAAC;IAC1E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,WAAW,CAAC,EAAE,GAAG,CAAC;CACnB,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,4BAA4B,CAAC,EACjD,MAAM,EACN,IAAS,EACT,MAAM,EACN,cAAc,EAAE,eAAe,EAC/B,cAA4D,EAC5D,WAAW,EAAE,YAAY,GAC1B,EAAE,kCAAkC,GAAG,OAAO,CAAC,0BAA0B,CAAC,CA+G1E"}
1
+ {"version":3,"file":"multi-owner-account.d.ts","sourceRoot":"","sources":["../../../../src/ma-v1/accounts/multi-owner-account.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,MAAM,EACX,KAAK,GAAG,EACR,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,KAAK,EACV,KAAK,SAAS,EAIf,MAAM,MAAM,CAAC;AACd,OAAO,EAA0B,KAAK,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAU9E,MAAM,MAAM,0BAA0B,GAAG,oBAAoB,GAAG;IAC9D,kBAAkB,EAAE,CAClB,WAAW,EAAE,OAAO,EAAE,EACtB,cAAc,EAAE,OAAO,EAAE,KACtB,GAAG,CAAC;IACT,iBAAiB,EAAE,MAAM,OAAO,CAAC,SAAS,OAAO,EAAE,CAAC,CAAC;CACtD,CAAC;AAEF,MAAM,MAAM,kCAAkC,GAAG;IAC/C,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE,KAAK,EAAE,cAAc,GAAG,YAAY,GAAG,SAAS,CAAC,CAAC;IAC5E,MAAM,EAAE,CAAC,KAAK,CAAC,cAAc,GAAG,YAAY,CAAC,EAAE,GAAG;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,EAAE,CAAC,CAAC;IAC1E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,GAAG,CAAC;CACnB,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,4BAA4B,CAAC,EACjD,MAAM,EACN,IAAS,EACT,MAAM,EACN,cAAc,EAAE,eAAe,EAC/B,OAAqD,EACrD,WAAW,EAAE,YAAY,GAC1B,EAAE,kCAAkC,GAAG,OAAO,CAAC,0BAA0B,CAAC,CA+G1E"}
@@ -13,12 +13,12 @@ export type ToModularAccountV2Params<TMode extends Mode | undefined = Mode | und
13
13
  mode?: TMode;
14
14
  } & (TMode extends "7702" ? {
15
15
  salt?: never;
16
- factoryAddress?: never;
16
+ factory?: never;
17
17
  factoryData?: never;
18
18
  implementationAddress?: never;
19
19
  } : {
20
20
  salt?: bigint;
21
- factoryAddress?: Address;
21
+ factory?: Address;
22
22
  factoryData?: Hex;
23
23
  implementationAddress?: Address;
24
24
  });
@@ -28,6 +28,6 @@ export type ToModularAccountV2Params<TMode extends Mode | undefined = Mode | und
28
28
  * @param {ToModularAccountV2Params} param0 - The parameters for creating a MAv2 account.
29
29
  * @returns {Promise<ModularAccountV2>} A MAv2 account.
30
30
  */
31
- export declare function toModularAccountV2<TMode extends Mode = Mode>({ client, owner, deferredAction, signerEntity, accountAddress: accountAddress_, salt, factoryAddress: factoryAddress_, factoryData: factoryData_, implementationAddress: implementationAddress_, mode, }: ToModularAccountV2Params<TMode>): Promise<ModularAccountV2>;
31
+ export declare function toModularAccountV2<TMode extends Mode = Mode>({ client, owner, deferredAction, signerEntity, accountAddress: accountAddress_, salt, factory, factoryData: factoryData_, implementationAddress: implementationAddress_, mode, }: ToModularAccountV2Params<TMode>): Promise<ModularAccountV2>;
32
32
  export {};
33
33
  //# sourceMappingURL=account.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../../../src/ma-v2/accounts/account.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,MAAM,EACX,KAAK,GAAG,EACR,KAAK,cAAc,EACnB,KAAK,YAAY,EAEjB,KAAK,SAAS,EACf,MAAM,MAAM,CAAC;AACd,OAAO,KAAK,EACV,eAAe,EAEhB,MAAM,0BAA0B,CAAC;AAClC,OAAO,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CAAC;IAClB,WAAW,CAAC,EAAE,GAAG,CAAC;IAClB,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC,CAAC,CAAC;AAEP;;;;;GAKG;AACH,wBAAsB,kBAAkB,CAAC,KAAK,SAAS,IAAI,GAAG,IAAI,EAAE,EAClE,MAAM,EACN,KAAK,EACL,cAAc,EACd,YAAY,EACZ,cAAc,EAAE,eAAe,EAC/B,IAAS,EACT,OAAO,EACP,WAAW,EAAE,YAAY,EACzB,qBAAqB,EAAE,sBAAsB,EAC7C,IAAI,GACL,EAAE,wBAAwB,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,CA2I7D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alchemy/smart-accounts",
3
- "version": "0.0.0-alpha.6",
3
+ "version": "0.0.0-alpha.7",
4
4
  "description": "This package contains all of the viem interfaces for Alchemy's Smart Contract Accounts",
5
5
  "author": "Alchemy",
6
6
  "license": "MIT",
@@ -39,11 +39,11 @@
39
39
  "test:run": "vitest run"
40
40
  },
41
41
  "devDependencies": {
42
- "@alchemy/aa-infra": "0.0.0-alpha.6",
42
+ "@alchemy/aa-infra": "0.0.0-alpha.7",
43
43
  "typescript-template": "*"
44
44
  },
45
45
  "dependencies": {
46
- "@alchemy/common": "0.0.0-alpha.6",
46
+ "@alchemy/common": "0.0.0-alpha.7",
47
47
  "ox": "^0.9.6",
48
48
  "viem": "^2.32.0",
49
49
  "webauthn-p256": "^0.0.10"
@@ -60,5 +60,5 @@
60
60
  "url": "https://github.com/alchemyplatform/aa-sdk/issues"
61
61
  },
62
62
  "homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
63
- "gitHead": "51d1115bb8a1507ba5fa56ad6b28ca03562106a6"
63
+ "gitHead": "0c3ba9574625caa8349cc7e17ee43bbbd8f25d42"
64
64
  }
@@ -43,7 +43,7 @@ export type ToLightAccountParams<
43
43
  owner: JsonRpcAccount | LocalAccount;
44
44
  salt?: bigint;
45
45
  accountAddress?: Address;
46
- factoryAddress?: Address;
46
+ factory?: Address;
47
47
  factoryData?: Hex;
48
48
  version?: TLightAccountVersion;
49
49
  };
@@ -63,7 +63,7 @@ export async function toLightAccount<
63
63
  salt: salt_ = 0n,
64
64
  accountAddress: accountAddress_,
65
65
  version = defaultLightAccountVersion() as TLightAccountVersion,
66
- factoryAddress = AccountVersionRegistry.LightAccount[version].factoryAddress,
66
+ factory = AccountVersionRegistry.LightAccount[version].factoryAddress,
67
67
  factoryData: factoryData_,
68
68
  }: ToLightAccountParams<TLightAccountVersion>): Promise<
69
69
  LightAccount<TLightAccountVersion>
@@ -80,16 +80,14 @@ export async function toLightAccount<
80
80
  ? LightAccountFactoryAbi_v2
81
81
  : LightAccountFactoryAbi_v1;
82
82
 
83
- const salt = LightAccountUnsupported1271Factories.has(
84
- lowerAddress(factoryAddress),
85
- )
83
+ const salt = LightAccountUnsupported1271Factories.has(lowerAddress(factory))
86
84
  ? 0n
87
85
  : salt_;
88
86
 
89
87
  const accountAddress =
90
88
  accountAddress_ ??
91
89
  predictLightAccountAddress({
92
- factoryAddress,
90
+ factoryAddress: factory,
93
91
  salt,
94
92
  ownerAddress: owner.address,
95
93
  version,
@@ -107,7 +105,7 @@ export async function toLightAccount<
107
105
  });
108
106
 
109
107
  return {
110
- factory: factoryAddress,
108
+ factory,
111
109
  factoryData,
112
110
  };
113
111
  };
@@ -35,7 +35,7 @@ export type ToMultiOwnerLightAccountParams = {
35
35
  owners: [OneOf<JsonRpcAccount | LocalAccount>, ...{ address: Address }[]];
36
36
  salt?: bigint;
37
37
  accountAddress?: Address;
38
- factoryAddress?: Address;
38
+ factory?: Address;
39
39
  factoryData?: Hex;
40
40
  };
41
41
 
@@ -50,7 +50,7 @@ export async function toMultiOwnerLightAccount({
50
50
  salt = 0n,
51
51
  owners,
52
52
  accountAddress: accountAddress_,
53
- factoryAddress = AccountVersionRegistry.MultiOwnerLightAccount["v2.0.0"]
53
+ factory = AccountVersionRegistry.MultiOwnerLightAccount["v2.0.0"]
54
54
  .factoryAddress,
55
55
  factoryData: factoryData_,
56
56
  }: ToMultiOwnerLightAccountParams): Promise<MultiOwnerLightAccount> {
@@ -69,7 +69,7 @@ export async function toMultiOwnerLightAccount({
69
69
  const accountAddress =
70
70
  accountAddress_ ??
71
71
  predictMultiOwnerLightAccountAddress({
72
- factoryAddress,
72
+ factoryAddress: factory,
73
73
  salt,
74
74
  ownerAddresses: sortedOwners,
75
75
  });
@@ -84,7 +84,7 @@ export async function toMultiOwnerLightAccount({
84
84
  });
85
85
 
86
86
  return {
87
- factory: factoryAddress,
87
+ factory,
88
88
  factoryData,
89
89
  };
90
90
  };
@@ -35,7 +35,7 @@ export type ToMultiOwnerModularAccountV1Params = {
35
35
  owners: [OneOf<JsonRpcAccount | LocalAccount>, ...{ address: Address }[]];
36
36
  salt?: bigint;
37
37
  accountAddress?: Address;
38
- factoryAddress?: Address;
38
+ factory?: Address;
39
39
  factoryData?: Hex;
40
40
  };
41
41
 
@@ -50,7 +50,7 @@ export async function toMultiOwnerModularAccountV1({
50
50
  salt = 0n,
51
51
  owners,
52
52
  accountAddress: accountAddress_,
53
- factoryAddress = DefaultMaV1Address.MULTI_OWNER_MAV1_FACTORY,
53
+ factory = DefaultMaV1Address.MULTI_OWNER_MAV1_FACTORY,
54
54
  factoryData: factoryData_,
55
55
  }: ToMultiOwnerModularAccountV1Params): Promise<MultiOwnerModularAccountV1> {
56
56
  const signer = owners[0];
@@ -68,7 +68,7 @@ export async function toMultiOwnerModularAccountV1({
68
68
  const accountAddress =
69
69
  accountAddress_ ??
70
70
  predictMultiOwnerModularAccountV1Address({
71
- factoryAddress,
71
+ factoryAddress: factory,
72
72
  salt,
73
73
  ownerAddresses: sortedOwners,
74
74
  });
@@ -83,7 +83,7 @@ export async function toMultiOwnerModularAccountV1({
83
83
  });
84
84
 
85
85
  return {
86
- factory: factoryAddress,
86
+ factory,
87
87
  factoryData,
88
88
  };
89
89
  };
@@ -41,13 +41,13 @@ export type ToModularAccountV2Params<
41
41
  } & (TMode extends "7702"
42
42
  ? {
43
43
  salt?: never;
44
- factoryAddress?: never;
44
+ factory?: never;
45
45
  factoryData?: never;
46
46
  implementationAddress?: never;
47
47
  }
48
48
  : {
49
49
  salt?: bigint;
50
- factoryAddress?: Address;
50
+ factory?: Address;
51
51
  factoryData?: Hex;
52
52
  implementationAddress?: Address;
53
53
  });
@@ -65,7 +65,7 @@ export async function toModularAccountV2<TMode extends Mode = Mode>({
65
65
  signerEntity,
66
66
  accountAddress: accountAddress_,
67
67
  salt = 0n,
68
- factoryAddress: factoryAddress_,
68
+ factory,
69
69
  factoryData: factoryData_,
70
70
  implementationAddress: implementationAddress_,
71
71
  mode,
@@ -82,7 +82,7 @@ export async function toModularAccountV2<TMode extends Mode = Mode>({
82
82
  const entityId = signerEntity?.entityId ?? DEFAULT_OWNER_ENTITY_ID;
83
83
 
84
84
  const factoryAddress =
85
- factoryAddress_ ??
85
+ factory ??
86
86
  (owner.type === "webAuthn"
87
87
  ? DefaultAddress.MAV2_FACTORY_WEBAUTHN
88
88
  : DefaultAddress.MAV2_FACTORY);