@account-kit/smart-contracts 4.0.0-beta.2 → 4.0.0-beta.3

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.
@@ -34,7 +34,7 @@ export async function createLightAccountBase({ transport, chain, signer, abi, ve
34
34
  args: [upgradeToAddress, upgradeToInitData],
35
35
  });
36
36
  };
37
- const signWith1271WrapperV1 = async (hashedMessage) => {
37
+ const signWith1271Wrapper = async (hashedMessage, version) => {
38
38
  return signer.signTypedData({
39
39
  // EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)
40
40
  // https://github.com/alchemyplatform/light-account/blob/main/src/LightAccount.sol#L236
@@ -42,7 +42,7 @@ export async function createLightAccountBase({ transport, chain, signer, abi, ve
42
42
  chainId: Number(client.chain.id),
43
43
  name: type,
44
44
  verifyingContract: accountAddress,
45
- version: "1",
45
+ version,
46
46
  },
47
47
  types: {
48
48
  LightAccountMessage: [{ name: "message", type: "bytes" }],
@@ -97,9 +97,9 @@ export async function createLightAccountBase({ transport, chain, signer, abi, ve
97
97
  case "v1.0.2":
98
98
  throw new Error(`${type} ${String(version)} doesn't support 1271`);
99
99
  case "v1.1.0":
100
- return signWith1271WrapperV1(hashMessage(message));
100
+ return signWith1271Wrapper(hashMessage(message), "1");
101
101
  case "v2.0.0":
102
- const signature = await signWith1271WrapperV1(hashMessage(message));
102
+ const signature = await signWith1271Wrapper(hashMessage(message), "2");
103
103
  // TODO: handle case where signer is an SCA.
104
104
  return concat([SignatureType.EOA, signature]);
105
105
  default:
@@ -113,9 +113,9 @@ export async function createLightAccountBase({ transport, chain, signer, abi, ve
113
113
  case "v1.0.2":
114
114
  throw new Error(`Version ${String(version)} of LightAccount doesn't support 1271`);
115
115
  case "v1.1.0":
116
- return signWith1271WrapperV1(hashTypedData(params));
116
+ return signWith1271Wrapper(hashTypedData(params), "1");
117
117
  case "v2.0.0":
118
- const signature = await signWith1271WrapperV1(hashTypedData(params));
118
+ const signature = await signWith1271Wrapper(hashTypedData(params), "2");
119
119
  // TODO: handle case where signer is an SCA.
120
120
  return concat([SignatureType.EOA, signature]);
121
121
  default:
@@ -1 +1 @@
1
- {"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../../src/light-account/accounts/base.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,EAC3B,mBAAmB,EACnB,sBAAsB,GAOvB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,MAAM,EACN,kBAAkB,EAClB,OAAO,EACP,WAAW,EACX,aAAa,EACb,IAAI,GAML,MAAM,MAAM,CAAC;AAMd,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAErD,IAAK,aAIJ;AAJD,WAAK,aAAa;IAChB,6BAAY,CAAA;IACZ,kCAAiB,CAAA;IACjB,4CAA2B,CAAA;AAC7B,CAAC,EAJI,aAAa,KAAb,aAAa,QAIjB;AAkCD,yCAAyC;AAEzC,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAK1C,EACA,SAAS,EACT,KAAK,EACL,MAAM,EACN,GAAG,EACH,OAAO,EACP,IAAI,EACJ,UAAU,EACV,cAAc,EACd,kBAAkB,GAMnB;IAGC,MAAM,MAAM,GAAG,mBAAmB,CAAC;QACjC,SAAS;QACT,KAAK;KACN,CAAC,CAAC;IAEH,MAAM,sBAAsB,GAAG,KAAK,EAAE,EACpC,gBAAgB,EAChB,iBAAiB,GACM,EAAgB,EAAE;QACzC,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC;YACxC,OAAO,EAAE,cAAc;YACvB,sDAAsD;YACtD,IAAI,EAAE,oEAAoE;SAC3E,CAAC,CAAC;QAEH,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;YACpB,MAAM,IAAI,2BAA2B,CACnC,oEAAoE,EACpE,8BAA8B,CAC/B,CAAC;QACJ,CAAC;QAED,MAAM,uBAAuB,GAAG,MAAM,CAAC,MAAM,CAC3C,sBAAsB,CAAC,IAAI,CAAC,CAC7B,CA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aAAa,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC;gBAChD;oBACE,MAAM,IAAI,KAAK,CAAC,mBAAmB,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;YAC1E,CAAC;QACH,CAAC;QACD,iBAAiB,EAAE,GAAQ,EAAE;YAC3B,MAAM,SAAS,GACb,sIAAsI,CAAC;YACzI,QAAQ,OAAiB,EAAE,CAAC;gBAC1B,KAAK,QAAQ,CAAC;gBACd,KAAK,QAAQ,CAAC;gBACd,KAAK,QAAQ;oBACX,OAAO,SAAS,CAAC;gBACnB,KAAK,QAAQ;oBACX,OAAO,MAAM,CAAC,CAAC,aAAa,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC;gBAChD;oBACE,MAAM,IAAI,KAAK,CAAC,mBAAmB,IAAI,OAAO,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YACrE,CAAC;QACH,CAAC;QACD,sBAAsB;KACvB,CAAC,CAAC;IAEH,OAAO;QACL,GAAG,OAAO;QACV,MAAM,EAAE,IAAI;QACZ,sBAAsB,EAAE,GAAG,EAAE,CAAC,OAAO;QACrC,SAAS,EAAE,GAAG,EAAE,CAAC,MAAM;KACxB,CAAC;AACJ,CAAC","sourcesContent":["import {\n FailedToGetStorageSlotError,\n createBundlerClient,\n toSmartContractAccount,\n type Abi,\n type EntryPointDef,\n type SmartAccountSigner,\n type SmartContractAccountWithSigner,\n type ToSmartContractAccountParams,\n type UpgradeToAndCallParams,\n} from \"@aa-sdk/core\";\nimport {\n concat,\n encodeFunctionData,\n fromHex,\n hashMessage,\n hashTypedData,\n trim,\n type Address,\n type Chain,\n type Hex,\n type SignTypedDataParameters,\n type Transport,\n} from \"viem\";\nimport type {\n LightAccountEntryPointVersion,\n LightAccountType,\n LightAccountVersion,\n} from \"../types.js\";\nimport { AccountVersionRegistry } from \"../utils.js\";\n\nenum SignatureType {\n EOA = \"0x00\",\n CONTRACT = \"0x01\",\n CONTRACT_WITH_ADDR = \"0x02\",\n}\n\nexport type LightAccountBase<\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TLightAccountType extends LightAccountType = LightAccountType,\n TLightAccountVersion extends LightAccountVersion<TLightAccountType> = LightAccountVersion<TLightAccountType>\n> = SmartContractAccountWithSigner<\n TLightAccountType,\n TSigner,\n LightAccountEntryPointVersion<TLightAccountType, TLightAccountVersion>\n> & {\n getLightAccountVersion: () => TLightAccountVersion;\n};\n\n//#region CreateLightAccountBaseParams\nexport type CreateLightAccountBaseParams<\n TLightAccountType extends LightAccountType,\n TLightAccountVersion extends LightAccountVersion<TLightAccountType> = LightAccountVersion<TLightAccountType>,\n TTransport extends Transport = Transport,\n TSigner extends SmartAccountSigner = SmartAccountSigner\n> = Pick<\n ToSmartContractAccountParams<TLightAccountType, TTransport, Chain>,\n \"transport\" | \"chain\" | \"getAccountInitCode\"\n> & {\n abi: Abi;\n signer: TSigner;\n accountAddress: Address;\n type: TLightAccountType;\n version: TLightAccountVersion;\n entryPoint: EntryPointDef<\n LightAccountEntryPointVersion<TLightAccountType, TLightAccountVersion>,\n Chain\n >;\n};\n//#endregion CreateLightAccountBaseParams\n\nexport async function createLightAccountBase<\n TLightAccountType extends LightAccountType,\n TLightAccountVersion extends LightAccountVersion<TLightAccountType>,\n TTransport extends Transport = Transport,\n TSigner extends SmartAccountSigner = SmartAccountSigner\n>({\n transport,\n chain,\n signer,\n abi,\n version,\n type,\n entryPoint,\n accountAddress,\n getAccountInitCode,\n}: CreateLightAccountBaseParams<\n TLightAccountType,\n TLightAccountVersion,\n TTransport,\n TSigner\n>): Promise<\n LightAccountBase<TSigner, TLightAccountType, TLightAccountVersion>\n> {\n const client = createBundlerClient({\n transport,\n chain,\n });\n\n const encodeUpgradeToAndCall = async ({\n upgradeToAddress,\n upgradeToInitData,\n }: UpgradeToAndCallParams): Promise<Hex> => {\n const storage = await client.getStorageAt({\n address: accountAddress,\n // the slot at which impl addresses are stored by UUPS\n slot: \"0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc\",\n });\n\n if (storage == null) {\n throw new FailedToGetStorageSlotError(\n \"0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc\",\n \"Proxy Implementation Address\"\n );\n }\n\n const implementationAddresses = Object.values(\n AccountVersionRegistry[type]\n ).map(\n (x) => x.addresses.overrides?.[chain.id]?.impl ?? x.addresses.default.impl\n );\n\n // only upgrade undeployed accounts (storage 0) or deployed light accounts, error otherwise\n if (\n fromHex(storage, \"number\") !== 0 &&\n !implementationAddresses.some((x) => x === trim(storage))\n ) {\n throw new Error(\n `could not determine if smart account implementation is ${type} ${String(\n version\n )}`\n );\n }\n\n return encodeFunctionData({\n abi,\n functionName: \"upgradeToAndCall\",\n args: [upgradeToAddress, upgradeToInitData],\n });\n };\n\n const signWith1271WrapperV1 = async (hashedMessage: Hex): Promise<Hex> => {\n return signer.signTypedData({\n // EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\n // https://github.com/alchemyplatform/light-account/blob/main/src/LightAccount.sol#L236\n domain: {\n chainId: Number(client.chain.id),\n name: type,\n verifyingContract: accountAddress,\n version: \"1\",\n },\n types: {\n LightAccountMessage: [{ name: \"message\", type: \"bytes\" }],\n },\n message: {\n message: hashedMessage,\n },\n primaryType: \"LightAccountMessage\",\n });\n };\n\n const account = await toSmartContractAccount({\n transport,\n chain,\n entryPoint,\n accountAddress,\n source: type,\n getAccountInitCode,\n encodeExecute: async ({ target, data, value }) => {\n return encodeFunctionData({\n abi,\n functionName: \"execute\",\n args: [target, value ?? 0n, data],\n });\n },\n encodeBatchExecute: async (txs) => {\n const [targets, values, datas] = txs.reduce(\n (accum, curr) => {\n accum[0].push(curr.target);\n accum[1].push(curr.value ?? 0n);\n accum[2].push(curr.data);\n\n return accum;\n },\n [[], [], []] as [Address[], bigint[], Hex[]]\n );\n return encodeFunctionData({\n abi,\n functionName: \"executeBatch\",\n args: [targets, values, datas],\n });\n },\n signUserOperationHash: async (uoHash: Hex) => {\n const signature = await signer.signMessage({ raw: uoHash });\n switch (version) {\n case \"v2.0.0\":\n // TODO: handle case where signer is an SCA.\n return concat([SignatureType.EOA, signature]);\n default:\n return signature;\n }\n },\n async signMessage({ message }) {\n switch (version as string) {\n case \"v1.0.1\":\n return signer.signMessage(message);\n case \"v1.0.2\":\n throw new Error(`${type} ${String(version)} doesn't support 1271`);\n case \"v1.1.0\":\n return signWith1271WrapperV1(hashMessage(message));\n case \"v2.0.0\":\n const signature = await signWith1271WrapperV1(hashMessage(message));\n // TODO: handle case where signer is an SCA.\n return concat([SignatureType.EOA, signature]);\n default:\n throw new Error(`Unknown version ${type} of ${String(version)}`);\n }\n },\n async signTypedData(params) {\n switch (version as string) {\n case \"v1.0.1\":\n return signer.signTypedData(\n params as unknown as SignTypedDataParameters\n );\n case \"v1.0.2\":\n throw new Error(\n `Version ${String(version)} of LightAccount doesn't support 1271`\n );\n case \"v1.1.0\":\n return signWith1271WrapperV1(hashTypedData(params));\n case \"v2.0.0\":\n const signature = await signWith1271WrapperV1(hashTypedData(params));\n // TODO: handle case where signer is an SCA.\n return concat([SignatureType.EOA, signature]);\n default:\n throw new Error(`Unknown version ${String(version)} of LightAccount`);\n }\n },\n getDummySignature: (): Hex => {\n const signature =\n \"0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c\";\n switch (version as string) {\n case \"v1.0.1\":\n case \"v1.0.2\":\n case \"v1.1.0\":\n return signature;\n case \"v2.0.0\":\n return concat([SignatureType.EOA, signature]);\n default:\n throw new Error(`Unknown version ${type} of ${String(version)}`);\n }\n },\n encodeUpgradeToAndCall,\n });\n\n return {\n ...account,\n source: type,\n getLightAccountVersion: () => version,\n getSigner: () => signer,\n };\n}\n"]}
1
+ {"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../../src/light-account/accounts/base.ts"],"names":[],"mappings":"AAAA,OAAO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AC1E,CAAC;QACH,CAAC;QACD,iBAAiB,EAAE,GAAQ,EAAE;YAC3B,MAAM,SAAS,GACb,sIAAsI,CAAC;YACzI,QAAQ,OAAiB,EAAE,CAAC;gBAC1B,KAAK,QAAQ,CAAC;gBACd,KAAK,QAAQ,CAAC;gBACd,KAAK,QAAQ;oBACX,OAAO,SAAS,CAAC;gBACnB,KAAK,QAAQ;oBACX,OAAO,MAAM,CAAC,CAAC,aAAa,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC;gBAChD;oBACE,MAAM,IAAI,KAAK,CAAC,mBAAmB,IAAI,OAAO,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YACrE,CAAC;QACH,CAAC;QACD,sBAAsB;KACvB,CAAC,CAAC;IAEH,OAAO;QACL,GAAG,OAAO;QACV,MAAM,EAAE,IAAI;QACZ,sBAAsB,EAAE,GAAG,EAAE,CAAC,OAAO;QACrC,SAAS,EAAE,GAAG,EAAE,CAAC,MAAM;KACxB,CAAC;AACJ,CAAC","sourcesContent":["import {\n FailedToGetStorageSlotError,\n createBundlerClient,\n toSmartContractAccount,\n type Abi,\n type EntryPointDef,\n type SmartAccountSigner,\n type SmartContractAccountWithSigner,\n type ToSmartContractAccountParams,\n type UpgradeToAndCallParams,\n} from \"@aa-sdk/core\";\nimport {\n concat,\n encodeFunctionData,\n fromHex,\n hashMessage,\n hashTypedData,\n trim,\n type Address,\n type Chain,\n type Hex,\n type SignTypedDataParameters,\n type Transport,\n} from \"viem\";\nimport type {\n LightAccountEntryPointVersion,\n LightAccountType,\n LightAccountVersion,\n} from \"../types.js\";\nimport { AccountVersionRegistry } from \"../utils.js\";\n\nenum SignatureType {\n EOA = \"0x00\",\n CONTRACT = \"0x01\",\n CONTRACT_WITH_ADDR = \"0x02\",\n}\n\nexport type LightAccountBase<\n TSigner extends SmartAccountSigner = SmartAccountSigner,\n TLightAccountType extends LightAccountType = LightAccountType,\n TLightAccountVersion extends LightAccountVersion<TLightAccountType> = LightAccountVersion<TLightAccountType>\n> = SmartContractAccountWithSigner<\n TLightAccountType,\n TSigner,\n LightAccountEntryPointVersion<TLightAccountType, TLightAccountVersion>\n> & {\n getLightAccountVersion: () => TLightAccountVersion;\n};\n\n//#region CreateLightAccountBaseParams\nexport type CreateLightAccountBaseParams<\n TLightAccountType extends LightAccountType,\n TLightAccountVersion extends LightAccountVersion<TLightAccountType> = LightAccountVersion<TLightAccountType>,\n TTransport extends Transport = Transport,\n TSigner extends SmartAccountSigner = SmartAccountSigner\n> = Pick<\n ToSmartContractAccountParams<TLightAccountType, TTransport, Chain>,\n \"transport\" | \"chain\" | \"getAccountInitCode\"\n> & {\n abi: Abi;\n signer: TSigner;\n accountAddress: Address;\n type: TLightAccountType;\n version: TLightAccountVersion;\n entryPoint: EntryPointDef<\n LightAccountEntryPointVersion<TLightAccountType, TLightAccountVersion>,\n Chain\n >;\n};\n//#endregion CreateLightAccountBaseParams\n\nexport async function createLightAccountBase<\n TLightAccountType extends LightAccountType,\n TLightAccountVersion extends LightAccountVersion<TLightAccountType>,\n TTransport extends Transport = Transport,\n TSigner extends SmartAccountSigner = SmartAccountSigner\n>({\n transport,\n chain,\n signer,\n abi,\n version,\n type,\n entryPoint,\n accountAddress,\n getAccountInitCode,\n}: CreateLightAccountBaseParams<\n TLightAccountType,\n TLightAccountVersion,\n TTransport,\n TSigner\n>): Promise<\n LightAccountBase<TSigner, TLightAccountType, TLightAccountVersion>\n> {\n const client = createBundlerClient({\n transport,\n chain,\n });\n\n const encodeUpgradeToAndCall = async ({\n upgradeToAddress,\n upgradeToInitData,\n }: UpgradeToAndCallParams): Promise<Hex> => {\n const storage = await client.getStorageAt({\n address: accountAddress,\n // the slot at which impl addresses are stored by UUPS\n slot: \"0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc\",\n });\n\n if (storage == null) {\n throw new FailedToGetStorageSlotError(\n \"0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc\",\n \"Proxy Implementation Address\"\n );\n }\n\n const implementationAddresses = Object.values(\n AccountVersionRegistry[type]\n ).map(\n (x) => x.addresses.overrides?.[chain.id]?.impl ?? x.addresses.default.impl\n );\n\n // only upgrade undeployed accounts (storage 0) or deployed light accounts, error otherwise\n if (\n fromHex(storage, \"number\") !== 0 &&\n !implementationAddresses.some((x) => x === trim(storage))\n ) {\n throw new Error(\n `could not determine if smart account implementation is ${type} ${String(\n version\n )}`\n );\n }\n\n return encodeFunctionData({\n abi,\n functionName: \"upgradeToAndCall\",\n args: [upgradeToAddress, upgradeToInitData],\n });\n };\n\n const signWith1271Wrapper = async (\n hashedMessage: Hex,\n version: string\n ): Promise<Hex> => {\n return signer.signTypedData({\n // EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\n // https://github.com/alchemyplatform/light-account/blob/main/src/LightAccount.sol#L236\n domain: {\n chainId: Number(client.chain.id),\n name: type,\n verifyingContract: accountAddress,\n version,\n },\n types: {\n LightAccountMessage: [{ name: \"message\", type: \"bytes\" }],\n },\n message: {\n message: hashedMessage,\n },\n primaryType: \"LightAccountMessage\",\n });\n };\n\n const account = await toSmartContractAccount({\n transport,\n chain,\n entryPoint,\n accountAddress,\n source: type,\n getAccountInitCode,\n encodeExecute: async ({ target, data, value }) => {\n return encodeFunctionData({\n abi,\n functionName: \"execute\",\n args: [target, value ?? 0n, data],\n });\n },\n encodeBatchExecute: async (txs) => {\n const [targets, values, datas] = txs.reduce(\n (accum, curr) => {\n accum[0].push(curr.target);\n accum[1].push(curr.value ?? 0n);\n accum[2].push(curr.data);\n\n return accum;\n },\n [[], [], []] as [Address[], bigint[], Hex[]]\n );\n return encodeFunctionData({\n abi,\n functionName: \"executeBatch\",\n args: [targets, values, datas],\n });\n },\n signUserOperationHash: async (uoHash: Hex) => {\n const signature = await signer.signMessage({ raw: uoHash });\n switch (version) {\n case \"v2.0.0\":\n // TODO: handle case where signer is an SCA.\n return concat([SignatureType.EOA, signature]);\n default:\n return signature;\n }\n },\n async signMessage({ message }) {\n switch (version as string) {\n case \"v1.0.1\":\n return signer.signMessage(message);\n case \"v1.0.2\":\n throw new Error(`${type} ${String(version)} doesn't support 1271`);\n case \"v1.1.0\":\n return signWith1271Wrapper(hashMessage(message), \"1\");\n case \"v2.0.0\":\n const signature = await signWith1271Wrapper(\n hashMessage(message),\n \"2\"\n );\n // TODO: handle case where signer is an SCA.\n return concat([SignatureType.EOA, signature]);\n default:\n throw new Error(`Unknown version ${type} of ${String(version)}`);\n }\n },\n async signTypedData(params) {\n switch (version as string) {\n case \"v1.0.1\":\n return signer.signTypedData(\n params as unknown as SignTypedDataParameters\n );\n case \"v1.0.2\":\n throw new Error(\n `Version ${String(version)} of LightAccount doesn't support 1271`\n );\n case \"v1.1.0\":\n return signWith1271Wrapper(hashTypedData(params), \"1\");\n case \"v2.0.0\":\n const signature = await signWith1271Wrapper(\n hashTypedData(params),\n \"2\"\n );\n // TODO: handle case where signer is an SCA.\n return concat([SignatureType.EOA, signature]);\n default:\n throw new Error(`Unknown version ${String(version)} of LightAccount`);\n }\n },\n getDummySignature: (): Hex => {\n const signature =\n \"0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c\";\n switch (version as string) {\n case \"v1.0.1\":\n case \"v1.0.2\":\n case \"v1.1.0\":\n return signature;\n case \"v2.0.0\":\n return concat([SignatureType.EOA, signature]);\n default:\n throw new Error(`Unknown version ${type} of ${String(version)}`);\n }\n },\n encodeUpgradeToAndCall,\n });\n\n return {\n ...account,\n source: type,\n getLightAccountVersion: () => version,\n getSigner: () => signer,\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../../src/light-account/accounts/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,GAAG,EACR,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,8BAA8B,EACnC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B,SAAS,mBAAmB,CAAC,iBAAiB,CAAC,EACnE,UAAU,SAAS,SAAS,GAAG,SAAS,EACxC,OAAO,SAAS,kBAAkB,GAAG,kBAAkB,EACvD,EACA,SAAS,EACT,KAAK,EACL,MAAM,EACN,GAAG,EACH,OAAO,EACP,IAAI,EACJ,UAAU,EACV,cAAc,EACd,kBAAkB,GACnB,EAAE,4BAA4B,CAC7B,iBAAiB,EACjB,oBAAoB,EACpB,UAAU,EACV,OAAO,CACR,GAAG,OAAO,CACT,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,CAAC,CACnE,CAwKA"}
1
+ {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../../src/light-account/accounts/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,GAAG,EACR,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,8BAA8B,EACnC,KAAK,4BAA4B,EAElC,MAAM,cAAc,CAAC;AACtB,OAAO,EAOL,KAAK,OAAO,EACZ,KAAK,KAAK,EAGV,KAAK,SAAS,EACf,MAAM,MAAM,CAAC;AACd,OAAO,KAAK,EACV,6BAA6B,EAC7B,gBAAgB,EAChB,mBAAmB,EACpB,MAAM,aAAa,CAAC;AASrB,MAAM,MAAM,gBAAgB,CAC1B,OAAO,SAAS,kBAAkB,GAAG,kBAAkB,EACvD,iBAAiB,SAAS,gBAAgB,GAAG,gBAAgB,EAC7D,oBAAoB,SAAS,mBAAmB,CAAC,iBAAiB,CAAC,GAAG,mBAAmB,CAAC,iBAAiB,CAAC,IAC1G,8BAA8B,CAChC,iBAAiB,EACjB,OAAO,EACP,6BAA6B,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,CACvE,GAAG;IACF,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;CACpD,CAAC;AAGF,MAAM,MAAM,4BAA4B,CACtC,iBAAiB,SAAS,gBAAgB,EAC1C,oBAAoB,SAAS,mBAAmB,CAAC,iBAAiB,CAAC,GAAG,mBAAmB,CAAC,iBAAiB,CAAC,EAC5G,UAAU,SAAS,SAAS,GAAG,SAAS,EACxC,OAAO,SAAS,kBAAkB,GAAG,kBAAkB,IACrD,IAAI,CACN,4BAA4B,CAAC,iBAAiB,EAAE,UAAU,EAAE,KAAK,CAAC,EAClE,WAAW,GAAG,OAAO,GAAG,oBAAoB,CAC7C,GAAG;IACF,GAAG,EAAE,GAAG,CAAC;IACT,MAAM,EAAE,OAAO,CAAC;IAChB,cAAc,EAAE,OAAO,CAAC;IACxB,IAAI,EAAE,iBAAiB,CAAC;IACxB,OAAO,EAAE,oBAAoB,CAAC;IAC9B,UAAU,EAAE,aAAa,CACvB,6BAA6B,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,EACtE,KAAK,CACN,CAAC;CACH,CAAC;AAGF,wBAAsB,sBAAsB,CAC1C,iBAAiB,SAAS,gBAAgB,EAC1C,oBAAoB,SAAS,mBAAmB,CAAC,iBAAiB,CAAC,EACnE,UAAU,SAAS,SAAS,GAAG,SAAS,EACxC,OAAO,SAAS,kBAAkB,GAAG,kBAAkB,EACvD,EACA,SAAS,EACT,KAAK,EACL,MAAM,EACN,GAAG,EACH,OAAO,EACP,IAAI,EACJ,UAAU,EACV,cAAc,EACd,kBAAkB,GACnB,EAAE,4BAA4B,CAC7B,iBAAiB,EACjB,oBAAoB,EACpB,UAAU,EACV,OAAO,CACR,GAAG,OAAO,CACT,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,CAAC,CACnE,CAiLA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@account-kit/smart-contracts",
3
- "version": "4.0.0-beta.2",
3
+ "version": "4.0.0-beta.3",
4
4
  "description": "aa-sdk compatible interfaces for Alchemy Smart Accounts",
5
5
  "author": "Alchemy",
6
6
  "license": "MIT",
@@ -46,7 +46,7 @@
46
46
  "test:run-e2e": "vitest run --config vitest.config.e2e.ts"
47
47
  },
48
48
  "devDependencies": {
49
- "@account-kit/plugingen": "^4.0.0-beta.2",
49
+ "@account-kit/plugingen": "^4.0.0-beta.3",
50
50
  "change-case": "^5.1.2",
51
51
  "dedent": "^1.5.1",
52
52
  "dotenv": "^16.3.1",
@@ -66,10 +66,10 @@
66
66
  "url": "https://github.com/alchemyplatform/aa-sdk/issues"
67
67
  },
68
68
  "homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
69
- "gitHead": "c814690e2cac5d6b4a385730b87a2fcd369377ec",
69
+ "gitHead": "533a73e15838e1c66bdee2fdc278b96c90f00ba7",
70
70
  "dependencies": {
71
- "@aa-sdk/core": "^4.0.0-beta.2",
72
- "@account-kit/infra": "^4.0.0-beta.2"
71
+ "@aa-sdk/core": "^4.0.0-beta.3",
72
+ "@account-kit/infra": "^4.0.0-beta.3"
73
73
  },
74
74
  "peerDependencies": {
75
75
  "viem": "^2.20.0"
@@ -139,7 +139,10 @@ export async function createLightAccountBase<
139
139
  });
140
140
  };
141
141
 
142
- const signWith1271WrapperV1 = async (hashedMessage: Hex): Promise<Hex> => {
142
+ const signWith1271Wrapper = async (
143
+ hashedMessage: Hex,
144
+ version: string
145
+ ): Promise<Hex> => {
143
146
  return signer.signTypedData({
144
147
  // EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)
145
148
  // https://github.com/alchemyplatform/light-account/blob/main/src/LightAccount.sol#L236
@@ -147,7 +150,7 @@ export async function createLightAccountBase<
147
150
  chainId: Number(client.chain.id),
148
151
  name: type,
149
152
  verifyingContract: accountAddress,
150
- version: "1",
153
+ version,
151
154
  },
152
155
  types: {
153
156
  LightAccountMessage: [{ name: "message", type: "bytes" }],
@@ -207,9 +210,12 @@ export async function createLightAccountBase<
207
210
  case "v1.0.2":
208
211
  throw new Error(`${type} ${String(version)} doesn't support 1271`);
209
212
  case "v1.1.0":
210
- return signWith1271WrapperV1(hashMessage(message));
213
+ return signWith1271Wrapper(hashMessage(message), "1");
211
214
  case "v2.0.0":
212
- const signature = await signWith1271WrapperV1(hashMessage(message));
215
+ const signature = await signWith1271Wrapper(
216
+ hashMessage(message),
217
+ "2"
218
+ );
213
219
  // TODO: handle case where signer is an SCA.
214
220
  return concat([SignatureType.EOA, signature]);
215
221
  default:
@@ -227,9 +233,12 @@ export async function createLightAccountBase<
227
233
  `Version ${String(version)} of LightAccount doesn't support 1271`
228
234
  );
229
235
  case "v1.1.0":
230
- return signWith1271WrapperV1(hashTypedData(params));
236
+ return signWith1271Wrapper(hashTypedData(params), "1");
231
237
  case "v2.0.0":
232
- const signature = await signWith1271WrapperV1(hashTypedData(params));
238
+ const signature = await signWith1271Wrapper(
239
+ hashTypedData(params),
240
+ "2"
241
+ );
233
242
  // TODO: handle case where signer is an SCA.
234
243
  return concat([SignatureType.EOA, signature]);
235
244
  default: