@account-kit/smart-contracts 4.0.0-beta.0 → 4.0.0-beta.10
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.
- package/dist/esm/src/light-account/accounts/base.js +6 -6
- package/dist/esm/src/light-account/accounts/base.js.map +1 -1
- package/dist/esm/src/light-account/clients/alchemyClient.d.ts +3 -3
- package/dist/esm/src/light-account/clients/alchemyClient.js +10 -13
- package/dist/esm/src/light-account/clients/alchemyClient.js.map +1 -1
- package/dist/esm/src/light-account/clients/multiOwnerAlchemyClient.d.ts +3 -3
- package/dist/esm/src/light-account/clients/multiOwnerAlchemyClient.js +13 -14
- package/dist/esm/src/light-account/clients/multiOwnerAlchemyClient.js.map +1 -1
- package/dist/esm/src/msca/client/alchemyClient.d.ts +3 -3
- package/dist/esm/src/msca/client/alchemyClient.js +8 -12
- package/dist/esm/src/msca/client/alchemyClient.js.map +1 -1
- package/dist/esm/src/msca/client/multiSigAlchemyClient.d.ts +3 -3
- package/dist/esm/src/msca/client/multiSigAlchemyClient.js +7 -11
- package/dist/esm/src/msca/client/multiSigAlchemyClient.js.map +1 -1
- package/dist/esm/src/msca/plugins/session-key/signer.d.ts +1 -1
- package/dist/esm/src/msca/plugins/session-key/signer.js.map +1 -1
- package/dist/types/src/light-account/accounts/base.d.ts.map +1 -1
- package/dist/types/src/light-account/clients/alchemyClient.d.ts +3 -3
- package/dist/types/src/light-account/clients/alchemyClient.d.ts.map +1 -1
- package/dist/types/src/light-account/clients/multiOwnerAlchemyClient.d.ts +3 -3
- package/dist/types/src/light-account/clients/multiOwnerAlchemyClient.d.ts.map +1 -1
- package/dist/types/src/msca/client/alchemyClient.d.ts +3 -3
- package/dist/types/src/msca/client/alchemyClient.d.ts.map +1 -1
- package/dist/types/src/msca/client/multiSigAlchemyClient.d.ts +3 -3
- package/dist/types/src/msca/client/multiSigAlchemyClient.d.ts.map +1 -1
- package/dist/types/src/msca/plugins/session-key/signer.d.ts +1 -1
- package/dist/types/src/msca/plugins/session-key/signer.d.ts.map +1 -1
- package/package.json +7 -10
- package/src/light-account/accounts/base.ts +15 -6
- package/src/light-account/clients/alchemyClient.ts +17 -26
- package/src/light-account/clients/multiOwnerAlchemyClient.ts +20 -28
- package/src/msca/client/alchemyClient.ts +10 -25
- package/src/msca/client/multiSigAlchemyClient.ts +8 -29
- package/src/msca/plugins/session-key/signer.ts +1 -1
|
@@ -34,7 +34,7 @@ export async function createLightAccountBase({ transport, chain, signer, abi, ve
|
|
|
34
34
|
args: [upgradeToAddress, upgradeToInitData],
|
|
35
35
|
});
|
|
36
36
|
};
|
|
37
|
-
const
|
|
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
|
|
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
|
|
100
|
+
return signWith1271Wrapper(hashMessage(message), "1");
|
|
101
101
|
case "v2.0.0":
|
|
102
|
-
const signature = await
|
|
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
|
|
116
|
+
return signWith1271Wrapper(hashTypedData(params), "1");
|
|
117
117
|
case "v2.0.0":
|
|
118
|
-
const signature = await
|
|
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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,CACb,WAAW,MAAM,CAAC,OAAO,CAAC,uCAAuC,CAClE,CAAC;gBACJ,KAAK,QAAQ;oBACX,OAAO,qBAAqB,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;gBACtD,KAAK,QAAQ;oBACX,MAAM,SAAS,GAAG,MAAM,qBAAqB,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;oBACrE,4CAA4C;oBAC5C,OAAO,MAAM,CAAC,CAAC,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,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,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zD,KAAK,QAAQ;oBACX,MAAM,SAAS,GAAG,MAAM,mBAAmB,CACzC,aAAa,CAAC,MAAM,CAAC,EACrB,GAAG,CACJ,CAAC;oBACF,4CAA4C;oBAC5C,OAAO,MAAM,CAAC,CAAC,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 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,6 +1,6 @@
|
|
|
1
1
|
import type { HttpTransport, SmartAccountSigner } from "@aa-sdk/core";
|
|
2
2
|
import { type AlchemySmartAccountClient, type AlchemySmartAccountClientConfig } from "@account-kit/infra";
|
|
3
3
|
import { type CreateLightAccountParams, type LightAccount, type LightAccountClientActions } from "@account-kit/smart-contracts";
|
|
4
|
-
import { type Chain
|
|
5
|
-
export type AlchemyLightAccountClientConfig<TSigner extends SmartAccountSigner = SmartAccountSigner> = Omit<CreateLightAccountParams<HttpTransport, TSigner>, "transport"
|
|
6
|
-
export declare function createLightAccountAlchemyClient<TSigner extends SmartAccountSigner = SmartAccountSigner>(params: AlchemyLightAccountClientConfig<TSigner>): Promise<AlchemySmartAccountClient<
|
|
4
|
+
import { type Chain } from "viem";
|
|
5
|
+
export type AlchemyLightAccountClientConfig<TSigner extends SmartAccountSigner = SmartAccountSigner> = Omit<CreateLightAccountParams<HttpTransport, TSigner>, "transport"> & Omit<AlchemySmartAccountClientConfig<Chain, LightAccount<TSigner>>, "account">;
|
|
6
|
+
export declare function createLightAccountAlchemyClient<TSigner extends SmartAccountSigner = SmartAccountSigner>(params: AlchemyLightAccountClientConfig<TSigner>): Promise<AlchemySmartAccountClient<Chain | undefined, LightAccount<TSigner>, LightAccountClientActions<TSigner>>>;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createAlchemySmartAccountClient, } from "@account-kit/infra";
|
|
2
2
|
import { createLightAccount, lightAccountClientActions, } from "@account-kit/smart-contracts";
|
|
3
|
-
import {
|
|
3
|
+
import {} from "viem";
|
|
4
4
|
/**
|
|
5
5
|
* Creates an Alchemy smart account client connected to a Light Account instance.
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
8
|
* ```ts
|
|
9
9
|
* import { createLightAccountAlchemyClient } from "@account-kit/smart-contracts";
|
|
10
|
-
* import { sepolia } from "@account-kit/infra";
|
|
10
|
+
* import { sepolia, alchemy } from "@account-kit/infra";
|
|
11
11
|
* import { LocalAccountSigner } from "@aa-sdk/core";
|
|
12
12
|
* import { generatePrivateKey } from "viem"
|
|
13
13
|
*
|
|
14
14
|
* const lightAccountClient = await createLightAccountAlchemyClient({
|
|
15
|
-
* apiKey: "your-api-key",
|
|
15
|
+
* transport: alchemy({ apiKey: "your-api-key" }),
|
|
16
16
|
* chain: sepolia,
|
|
17
17
|
* signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey())
|
|
18
18
|
* });
|
|
@@ -21,19 +21,16 @@ import { custom } from "viem";
|
|
|
21
21
|
* @param {AlchemyLightAccountClientConfig} config The configuration for setting up the Alchemy Light Account Client
|
|
22
22
|
* @returns {Promise<AlchemySmartAccountClient>} A promise that resolves to an `AlchemySmartAccountClient` object containing the created client
|
|
23
23
|
*/
|
|
24
|
-
export async function createLightAccountAlchemyClient(config) {
|
|
25
|
-
const { chain, opts, ...connectionConfig } = AlchemyProviderConfigSchema.parse(config);
|
|
26
|
-
const client = createAlchemyPublicRpcClient({
|
|
27
|
-
chain,
|
|
28
|
-
connectionConfig,
|
|
29
|
-
});
|
|
24
|
+
export async function createLightAccountAlchemyClient({ opts, transport, chain, ...config }) {
|
|
30
25
|
const account = await createLightAccount({
|
|
31
|
-
transport: custom(client),
|
|
32
26
|
...config,
|
|
27
|
+
transport,
|
|
28
|
+
chain,
|
|
33
29
|
});
|
|
34
|
-
return
|
|
30
|
+
return createAlchemySmartAccountClient({
|
|
35
31
|
...config,
|
|
36
|
-
|
|
32
|
+
transport,
|
|
33
|
+
chain,
|
|
37
34
|
account,
|
|
38
35
|
opts,
|
|
39
36
|
}).extend(lightAccountClientActions);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alchemyClient.js","sourceRoot":"","sources":["../../../../../src/light-account/clients/alchemyClient.ts"],"names":[],"mappings":"AACA,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"alchemyClient.js","sourceRoot":"","sources":["../../../../../src/light-account/clients/alchemyClient.ts"],"names":[],"mappings":"AACA,OAAO,EACL,+BAA+B,GAGhC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,kBAAkB,EAClB,yBAAyB,GAI1B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAc,MAAM,MAAM,CAAC;AAsBlC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,KAAK,UAAU,+BAA+B,CAAC,EACpD,IAAI,EACJ,SAAS,EACT,KAAK,EACL,GAAG,MAAM,EACuB;IAChC,MAAM,OAAO,GAAG,MAAM,kBAAkB,CAAC;QACvC,GAAG,MAAM;QACT,SAAS;QACT,KAAK;KACN,CAAC,CAAC;IAEH,OAAO,+BAA+B,CAAC;QACrC,GAAG,MAAM;QACT,SAAS;QACT,KAAK;QACL,OAAO;QACP,IAAI;KACL,CAAC,CAAC,MAAM,CAAC,yBAAyB,CAAC,CAAC;AACvC,CAAC","sourcesContent":["import type { HttpTransport, SmartAccountSigner } from \"@aa-sdk/core\";\nimport {\n createAlchemySmartAccountClient,\n type AlchemySmartAccountClient,\n type AlchemySmartAccountClientConfig,\n} from \"@account-kit/infra\";\nimport {\n createLightAccount,\n lightAccountClientActions,\n type CreateLightAccountParams,\n type LightAccount,\n type LightAccountClientActions,\n} from \"@account-kit/smart-contracts\";\nimport { type Chain } from \"viem\";\n\nexport type AlchemyLightAccountClientConfig<\n TSigner extends SmartAccountSigner = SmartAccountSigner\n> = Omit<CreateLightAccountParams<HttpTransport, TSigner>, \"transport\"> &\n Omit<\n AlchemySmartAccountClientConfig<Chain, LightAccount<TSigner>>,\n \"account\"\n >;\n\nexport async function createLightAccountAlchemyClient<\n TSigner extends SmartAccountSigner = SmartAccountSigner\n>(\n params: AlchemyLightAccountClientConfig<TSigner>\n): Promise<\n AlchemySmartAccountClient<\n Chain | undefined,\n LightAccount<TSigner>,\n LightAccountClientActions<TSigner>\n >\n>;\n\n/**\n * Creates an Alchemy smart account client connected to a Light Account instance.\n *\n * @example\n * ```ts\n * import { createLightAccountAlchemyClient } from \"@account-kit/smart-contracts\";\n * import { sepolia, alchemy } from \"@account-kit/infra\";\n * import { LocalAccountSigner } from \"@aa-sdk/core\";\n * import { generatePrivateKey } from \"viem\"\n *\n * const lightAccountClient = await createLightAccountAlchemyClient({\n * transport: alchemy({ apiKey: \"your-api-key\" }),\n * chain: sepolia,\n * signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey())\n * });\n * ```\n *\n * @param {AlchemyLightAccountClientConfig} config The configuration for setting up the Alchemy Light Account Client\n * @returns {Promise<AlchemySmartAccountClient>} A promise that resolves to an `AlchemySmartAccountClient` object containing the created client\n */\nexport async function createLightAccountAlchemyClient({\n opts,\n transport,\n chain,\n ...config\n}: AlchemyLightAccountClientConfig): Promise<AlchemySmartAccountClient> {\n const account = await createLightAccount({\n ...config,\n transport,\n chain,\n });\n\n return createAlchemySmartAccountClient({\n ...config,\n transport,\n chain,\n account,\n opts,\n }).extend(lightAccountClientActions);\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { HttpTransport, SmartAccountSigner } from "@aa-sdk/core";
|
|
2
2
|
import { type AlchemySmartAccountClient, type AlchemySmartAccountClientConfig } from "@account-kit/infra";
|
|
3
3
|
import { type CreateMultiOwnerLightAccountParams, type MultiOwnerLightAccount, type MultiOwnerLightAccountClientActions } from "@account-kit/smart-contracts";
|
|
4
|
-
import { type Chain
|
|
5
|
-
export type AlchemyMultiOwnerLightAccountClientConfig<TSigner extends SmartAccountSigner = SmartAccountSigner> = Omit<CreateMultiOwnerLightAccountParams<HttpTransport, TSigner>, "transport" | "
|
|
6
|
-
export declare function createMultiOwnerLightAccountAlchemyClient<TSigner extends SmartAccountSigner = SmartAccountSigner>(params: AlchemyMultiOwnerLightAccountClientConfig<TSigner>): Promise<AlchemySmartAccountClient<
|
|
4
|
+
import { type Chain } from "viem";
|
|
5
|
+
export type AlchemyMultiOwnerLightAccountClientConfig<TSigner extends SmartAccountSigner = SmartAccountSigner> = Omit<CreateMultiOwnerLightAccountParams<HttpTransport, TSigner>, "transport" | "type"> & Omit<AlchemySmartAccountClientConfig<Chain, MultiOwnerLightAccount<TSigner>>, "account">;
|
|
6
|
+
export declare function createMultiOwnerLightAccountAlchemyClient<TSigner extends SmartAccountSigner = SmartAccountSigner>(params: AlchemyMultiOwnerLightAccountClientConfig<TSigner>): Promise<AlchemySmartAccountClient<Chain | undefined, MultiOwnerLightAccount<TSigner>, MultiOwnerLightAccountClientActions<TSigner>>>;
|
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createAlchemySmartAccountClient, } from "@account-kit/infra";
|
|
2
2
|
import { createMultiOwnerLightAccount, multiOwnerLightAccountClientActions, } from "@account-kit/smart-contracts";
|
|
3
|
-
import {
|
|
3
|
+
import {} from "viem";
|
|
4
4
|
/**
|
|
5
5
|
* Creates a multi-owner light account Alchemy client using the provided configuration.
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
8
|
* ```ts
|
|
9
9
|
* import { createMultiOwnerLightAccountAlchemyClient } from "@account-kit/smart-contracts";
|
|
10
|
-
* import { sepolia } from "@account-kit/infra";
|
|
10
|
+
* import { sepolia, alchemy } from "@account-kit/infra";
|
|
11
11
|
* import { LocalAccountSigner } from "@aa-sdk/core";
|
|
12
12
|
* import { generatePrivateKey } from "viem"
|
|
13
13
|
*
|
|
14
14
|
* const lightAccountClient = await createMultiOwnerLightAccountAlchemyClient({
|
|
15
|
-
*
|
|
16
|
-
*
|
|
15
|
+
* transport: alchemy({
|
|
16
|
+
* apiKey: "your-api-key",
|
|
17
|
+
* }),
|
|
18
|
+
* chain: sepolia
|
|
17
19
|
* signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey())
|
|
18
20
|
* });
|
|
19
21
|
* ```
|
|
@@ -21,19 +23,16 @@ import { custom } from "viem";
|
|
|
21
23
|
* @param {AlchemyMultiOwnerLightAccountClientConfig} config The configuration for creating the Alchemy client
|
|
22
24
|
* @returns {Promise<AlchemySmartAccountClient>} A promise that resolves to an `AlchemySmartAccountClient` object containing the created account information and methods
|
|
23
25
|
*/
|
|
24
|
-
export async function createMultiOwnerLightAccountAlchemyClient(config) {
|
|
25
|
-
const { chain, opts, ...connectionConfig } = AlchemyProviderConfigSchema.parse(config);
|
|
26
|
-
const client = createAlchemyPublicRpcClient({
|
|
27
|
-
chain,
|
|
28
|
-
connectionConfig,
|
|
29
|
-
});
|
|
26
|
+
export async function createMultiOwnerLightAccountAlchemyClient({ opts, transport, chain, ...config }) {
|
|
30
27
|
const account = await createMultiOwnerLightAccount({
|
|
31
|
-
transport: custom(client),
|
|
32
28
|
...config,
|
|
29
|
+
transport,
|
|
30
|
+
chain,
|
|
33
31
|
});
|
|
34
|
-
return
|
|
32
|
+
return createAlchemySmartAccountClient({
|
|
35
33
|
...config,
|
|
36
|
-
|
|
34
|
+
transport,
|
|
35
|
+
chain,
|
|
37
36
|
account,
|
|
38
37
|
opts,
|
|
39
38
|
}).extend(multiOwnerLightAccountClientActions);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multiOwnerAlchemyClient.js","sourceRoot":"","sources":["../../../../../src/light-account/clients/multiOwnerAlchemyClient.ts"],"names":[],"mappings":"AACA,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"multiOwnerAlchemyClient.js","sourceRoot":"","sources":["../../../../../src/light-account/clients/multiOwnerAlchemyClient.ts"],"names":[],"mappings":"AACA,OAAO,EACL,+BAA+B,GAGhC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,4BAA4B,EAC5B,mCAAmC,GAIpC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAc,MAAM,MAAM,CAAC;AAyBlC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,KAAK,UAAU,yCAAyC,CAAC,EAC9D,IAAI,EACJ,SAAS,EACT,KAAK,EACL,GAAG,MAAM,EACiC;IAC1C,MAAM,OAAO,GAAG,MAAM,4BAA4B,CAAC;QACjD,GAAG,MAAM;QACT,SAAS;QACT,KAAK;KACN,CAAC,CAAC;IAEH,OAAO,+BAA+B,CAAC;QACrC,GAAG,MAAM;QACT,SAAS;QACT,KAAK;QACL,OAAO;QACP,IAAI;KACL,CAAC,CAAC,MAAM,CAAC,mCAAmC,CAAC,CAAC;AACjD,CAAC","sourcesContent":["import type { HttpTransport, SmartAccountSigner } from \"@aa-sdk/core\";\nimport {\n createAlchemySmartAccountClient,\n type AlchemySmartAccountClient,\n type AlchemySmartAccountClientConfig,\n} from \"@account-kit/infra\";\nimport {\n createMultiOwnerLightAccount,\n multiOwnerLightAccountClientActions,\n type CreateMultiOwnerLightAccountParams,\n type MultiOwnerLightAccount,\n type MultiOwnerLightAccountClientActions,\n} from \"@account-kit/smart-contracts\";\nimport { type Chain } from \"viem\";\n\nexport type AlchemyMultiOwnerLightAccountClientConfig<\n TSigner extends SmartAccountSigner = SmartAccountSigner\n> = Omit<\n CreateMultiOwnerLightAccountParams<HttpTransport, TSigner>,\n \"transport\" | \"type\"\n> &\n Omit<\n AlchemySmartAccountClientConfig<Chain, MultiOwnerLightAccount<TSigner>>,\n \"account\"\n >;\n\nexport async function createMultiOwnerLightAccountAlchemyClient<\n TSigner extends SmartAccountSigner = SmartAccountSigner\n>(\n params: AlchemyMultiOwnerLightAccountClientConfig<TSigner>\n): Promise<\n AlchemySmartAccountClient<\n Chain | undefined,\n MultiOwnerLightAccount<TSigner>,\n MultiOwnerLightAccountClientActions<TSigner>\n >\n>;\n\n/**\n * Creates a multi-owner light account Alchemy client using the provided configuration.\n *\n * @example\n * ```ts\n * import { createMultiOwnerLightAccountAlchemyClient } from \"@account-kit/smart-contracts\";\n * import { sepolia, alchemy } from \"@account-kit/infra\";\n * import { LocalAccountSigner } from \"@aa-sdk/core\";\n * import { generatePrivateKey } from \"viem\"\n *\n * const lightAccountClient = await createMultiOwnerLightAccountAlchemyClient({\n * transport: alchemy({\n * apiKey: \"your-api-key\",\n * }),\n * chain: sepolia\n * signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey())\n * });\n * ```\n *\n * @param {AlchemyMultiOwnerLightAccountClientConfig} config The configuration for creating the Alchemy client\n * @returns {Promise<AlchemySmartAccountClient>} A promise that resolves to an `AlchemySmartAccountClient` object containing the created account information and methods\n */\nexport async function createMultiOwnerLightAccountAlchemyClient({\n opts,\n transport,\n chain,\n ...config\n}: AlchemyMultiOwnerLightAccountClientConfig): Promise<AlchemySmartAccountClient> {\n const account = await createMultiOwnerLightAccount({\n ...config,\n transport,\n chain,\n });\n\n return createAlchemySmartAccountClient({\n ...config,\n transport,\n chain,\n account,\n opts,\n }).extend(multiOwnerLightAccountClientActions);\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SmartAccountSigner } from "@aa-sdk/core";
|
|
2
2
|
import { type AlchemySmartAccountClient, type AlchemySmartAccountClientConfig } from "@account-kit/infra";
|
|
3
3
|
import { type AccountLoupeActions, type CreateMultiOwnerModularAccountParams, type LightAccount, type MultiOwnerModularAccount, type MultiOwnerPluginActions, type PluginManagerActions } from "@account-kit/smart-contracts";
|
|
4
|
-
import { type Chain, type
|
|
5
|
-
export type AlchemyModularAccountClientConfig<TSigner extends SmartAccountSigner = SmartAccountSigner> = Omit<CreateMultiOwnerModularAccountParams<HttpTransport, TSigner>, "transport"
|
|
6
|
-
export declare function createModularAccountAlchemyClient<TSigner extends SmartAccountSigner = SmartAccountSigner>(params: AlchemyModularAccountClientConfig<TSigner>): Promise<AlchemySmartAccountClient<
|
|
4
|
+
import { type Chain, type HttpTransport } from "viem";
|
|
5
|
+
export type AlchemyModularAccountClientConfig<TSigner extends SmartAccountSigner = SmartAccountSigner> = Omit<CreateMultiOwnerModularAccountParams<HttpTransport, TSigner>, "transport"> & Omit<AlchemySmartAccountClientConfig<Chain, LightAccount<TSigner>>, "account">;
|
|
6
|
+
export declare function createModularAccountAlchemyClient<TSigner extends SmartAccountSigner = SmartAccountSigner>(params: AlchemyModularAccountClientConfig<TSigner>): Promise<AlchemySmartAccountClient<Chain | undefined, MultiOwnerModularAccount<TSigner>, MultiOwnerPluginActions<MultiOwnerModularAccount<TSigner>> & PluginManagerActions<MultiOwnerModularAccount<TSigner>> & AccountLoupeActions<MultiOwnerModularAccount<TSigner>>>>;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createAlchemySmartAccountClient, } from "@account-kit/infra";
|
|
2
2
|
import { accountLoupeActions, createMultiOwnerModularAccount, multiOwnerPluginActions, pluginManagerActions, } from "@account-kit/smart-contracts";
|
|
3
|
-
import {
|
|
3
|
+
import {} from "viem";
|
|
4
4
|
/**
|
|
5
5
|
* Creates a modular account Alchemy client with the provided configuration.
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
8
|
* ```ts
|
|
9
9
|
* import { createModularAccountAlchemyClient } from "@account-kit/smart-contracts";
|
|
10
|
-
* import { sepolia } from "@account-kit/infra";
|
|
10
|
+
* import { sepolia, alchemy } from "@account-kit/infra";
|
|
11
11
|
* import { LocalAccountSigner } from "@aa-sdk/core";
|
|
12
12
|
* import { generatePrivateKey } from "viem"
|
|
13
13
|
*
|
|
14
14
|
* const alchemyAccountClient = await createModularAccountAlchemyClient({
|
|
15
|
-
* apiKey: "your-api-key",
|
|
15
|
+
* transport: alchemy({ apiKey: "your-api-key" }),
|
|
16
16
|
* chain: sepolia,
|
|
17
17
|
* signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey())
|
|
18
18
|
* });
|
|
@@ -22,18 +22,14 @@ import { custom, } from "viem";
|
|
|
22
22
|
* @returns {Promise<AlchemySmartAccountClient>} A promise that resolves to an `AlchemySmartAccountClient` configured with the desired plugins and actions
|
|
23
23
|
*/
|
|
24
24
|
export async function createModularAccountAlchemyClient(config) {
|
|
25
|
-
const { chain, opts
|
|
26
|
-
const client = createAlchemyPublicRpcClient({
|
|
27
|
-
chain,
|
|
28
|
-
connectionConfig,
|
|
29
|
-
});
|
|
25
|
+
const { transport, chain, opts } = config;
|
|
30
26
|
const account = await createMultiOwnerModularAccount({
|
|
31
|
-
transport: custom(client),
|
|
32
27
|
...config,
|
|
28
|
+
transport,
|
|
29
|
+
chain,
|
|
33
30
|
});
|
|
34
|
-
return
|
|
31
|
+
return createAlchemySmartAccountClient({
|
|
35
32
|
...config,
|
|
36
|
-
client,
|
|
37
33
|
account,
|
|
38
34
|
opts,
|
|
39
35
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alchemyClient.js","sourceRoot":"","sources":["../../../../../src/msca/client/alchemyClient.ts"],"names":[],"mappings":"AACA,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"alchemyClient.js","sourceRoot":"","sources":["../../../../../src/msca/client/alchemyClient.ts"],"names":[],"mappings":"AACA,OAAO,EACL,+BAA+B,GAGhC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,mBAAmB,EACnB,8BAA8B,EAC9B,uBAAuB,EACvB,oBAAoB,GAOrB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAkC,MAAM,MAAM,CAAC;AA2BtD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,KAAK,UAAU,iCAAiC,CACrD,MAAyC;IAEzC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC;IAE1C,MAAM,OAAO,GAAG,MAAM,8BAA8B,CAAC;QACnD,GAAG,MAAM;QACT,SAAS;QACT,KAAK;KACN,CAAC,CAAC;IAEH,OAAO,+BAA+B,CAAC;QACrC,GAAG,MAAM;QACT,OAAO;QACP,IAAI;KACL,CAAC;SACC,MAAM,CAAC,uBAAuB,CAAC;SAC/B,MAAM,CAAC,oBAAoB,CAAC;SAC5B,MAAM,CAAC,mBAAmB,CAAC,CAAC;AACjC,CAAC","sourcesContent":["import type { SmartAccountSigner } from \"@aa-sdk/core\";\nimport {\n createAlchemySmartAccountClient,\n type AlchemySmartAccountClient,\n type AlchemySmartAccountClientConfig,\n} from \"@account-kit/infra\";\nimport {\n accountLoupeActions,\n createMultiOwnerModularAccount,\n multiOwnerPluginActions,\n pluginManagerActions,\n type AccountLoupeActions,\n type CreateMultiOwnerModularAccountParams,\n type LightAccount,\n type MultiOwnerModularAccount,\n type MultiOwnerPluginActions,\n type PluginManagerActions,\n} from \"@account-kit/smart-contracts\";\nimport { type Chain, type HttpTransport } from \"viem\";\n\nexport type AlchemyModularAccountClientConfig<\n TSigner extends SmartAccountSigner = SmartAccountSigner\n> = Omit<\n CreateMultiOwnerModularAccountParams<HttpTransport, TSigner>,\n \"transport\"\n> &\n Omit<\n AlchemySmartAccountClientConfig<Chain, LightAccount<TSigner>>,\n \"account\"\n >;\n\nexport function createModularAccountAlchemyClient<\n TSigner extends SmartAccountSigner = SmartAccountSigner\n>(\n params: AlchemyModularAccountClientConfig<TSigner>\n): Promise<\n AlchemySmartAccountClient<\n Chain | undefined,\n MultiOwnerModularAccount<TSigner>,\n MultiOwnerPluginActions<MultiOwnerModularAccount<TSigner>> &\n PluginManagerActions<MultiOwnerModularAccount<TSigner>> &\n AccountLoupeActions<MultiOwnerModularAccount<TSigner>>\n >\n>;\n\n/**\n * Creates a modular account Alchemy client with the provided configuration.\n *\n * @example\n * ```ts\n * import { createModularAccountAlchemyClient } from \"@account-kit/smart-contracts\";\n * import { sepolia, alchemy } from \"@account-kit/infra\";\n * import { LocalAccountSigner } from \"@aa-sdk/core\";\n * import { generatePrivateKey } from \"viem\"\n *\n * const alchemyAccountClient = await createModularAccountAlchemyClient({\n * transport: alchemy({ apiKey: \"your-api-key\" }),\n * chain: sepolia,\n * signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey())\n * });\n * ```\n *\n * @param {AlchemyModularAccountClientConfig} config The configuration for creating the Alchemy client\n * @returns {Promise<AlchemySmartAccountClient>} A promise that resolves to an `AlchemySmartAccountClient` configured with the desired plugins and actions\n */\nexport async function createModularAccountAlchemyClient(\n config: AlchemyModularAccountClientConfig\n): Promise<AlchemySmartAccountClient> {\n const { transport, chain, opts } = config;\n\n const account = await createMultiOwnerModularAccount({\n ...config,\n transport,\n chain,\n });\n\n return createAlchemySmartAccountClient({\n ...config,\n account,\n opts,\n })\n .extend(multiOwnerPluginActions)\n .extend(pluginManagerActions)\n .extend(accountLoupeActions);\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type SmartAccountSigner } from "@aa-sdk/core";
|
|
2
2
|
import { type AlchemySmartAccountClient, type AlchemySmartAccountClientConfig } from "@account-kit/infra";
|
|
3
3
|
import { type AccountLoupeActions, type CreateMultisigModularAccountParams, type LightAccount, type MultisigModularAccount, type MultisigPluginActions, type MultisigUserOperationContext, type PluginManagerActions } from "@account-kit/smart-contracts";
|
|
4
|
-
import { type Chain, type
|
|
5
|
-
export type AlchemyMultisigAccountClientConfig<TSigner extends SmartAccountSigner = SmartAccountSigner> = Omit<CreateMultisigModularAccountParams<HttpTransport, TSigner>, "transport"
|
|
6
|
-
export declare function createMultisigAccountAlchemyClient<TSigner extends SmartAccountSigner = SmartAccountSigner>(params: AlchemyMultisigAccountClientConfig<TSigner>): Promise<AlchemySmartAccountClient<
|
|
4
|
+
import { type Chain, type HttpTransport } from "viem";
|
|
5
|
+
export type AlchemyMultisigAccountClientConfig<TSigner extends SmartAccountSigner = SmartAccountSigner> = Omit<CreateMultisigModularAccountParams<HttpTransport, TSigner>, "transport"> & Omit<AlchemySmartAccountClientConfig<Chain, LightAccount<TSigner>, MultisigUserOperationContext>, "account">;
|
|
6
|
+
export declare function createMultisigAccountAlchemyClient<TSigner extends SmartAccountSigner = SmartAccountSigner>(params: AlchemyMultisigAccountClientConfig<TSigner>): Promise<AlchemySmartAccountClient<Chain | undefined, MultisigModularAccount<TSigner>, MultisigPluginActions<MultisigModularAccount<TSigner>> & PluginManagerActions<MultisigModularAccount<TSigner>> & AccountLoupeActions<MultisigModularAccount<TSigner>>, MultisigUserOperationContext>>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { smartAccountClientActions, } from "@aa-sdk/core";
|
|
2
|
-
import {
|
|
2
|
+
import { createAlchemySmartAccountClient, } from "@account-kit/infra";
|
|
3
3
|
import { accountLoupeActions, createMultisigModularAccount, multisigPluginActions, multisigSignatureMiddleware, pluginManagerActions, } from "@account-kit/smart-contracts";
|
|
4
|
-
import {
|
|
4
|
+
import {} from "viem";
|
|
5
5
|
/**
|
|
6
6
|
* Creates an Alchemy client for a multisig account using the provided configuration.
|
|
7
7
|
*
|
|
@@ -13,7 +13,7 @@ import { custom, } from "viem";
|
|
|
13
13
|
* import { generatePrivateKey } from "viem"
|
|
14
14
|
*
|
|
15
15
|
* const alchemyAccountClient = await createMultisigAccountAlchemyClient({
|
|
16
|
-
* apiKey: "your-api-key",
|
|
16
|
+
* transport: alchemy({ apiKey: "your-api-key" }),
|
|
17
17
|
* chain: sepolia,
|
|
18
18
|
* signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey()),
|
|
19
19
|
* owners: [...], // other owners on the account
|
|
@@ -25,18 +25,14 @@ import { custom, } from "viem";
|
|
|
25
25
|
* @returns {Promise<AlchemySmartAccountClient<Transport, Chain | undefined, MultisigModularAccount<SmartAccountSigner>, MultisigPluginActions<MultisigModularAccount<SmartAccountSigner>> & PluginManagerActions<MultisigModularAccount<SmartAccountSigner>> & AccountLoupeActions<MultisigModularAccount<SmartAccountSigner>>, MultisigUserOperationContext>>} A promise that resolves to an Alchemy Smart Account Client for multisig accounts with extended functionalities.
|
|
26
26
|
*/
|
|
27
27
|
export async function createMultisigAccountAlchemyClient(config) {
|
|
28
|
-
const {
|
|
29
|
-
const client = createAlchemyPublicRpcClient({
|
|
30
|
-
chain,
|
|
31
|
-
connectionConfig,
|
|
32
|
-
});
|
|
28
|
+
const { transport, opts, chain } = config;
|
|
33
29
|
const account = await createMultisigModularAccount({
|
|
34
|
-
transport: custom(client),
|
|
35
30
|
...config,
|
|
31
|
+
transport,
|
|
32
|
+
chain,
|
|
36
33
|
});
|
|
37
|
-
return
|
|
34
|
+
return createAlchemySmartAccountClient({
|
|
38
35
|
...config,
|
|
39
|
-
client,
|
|
40
36
|
account,
|
|
41
37
|
opts,
|
|
42
38
|
signUserOperation: multisigSignatureMiddleware,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multiSigAlchemyClient.js","sourceRoot":"","sources":["../../../../../src/msca/client/multiSigAlchemyClient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,GAE1B,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"multiSigAlchemyClient.js","sourceRoot":"","sources":["../../../../../src/msca/client/multiSigAlchemyClient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,GAE1B,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,+BAA+B,GAGhC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,mBAAmB,EACnB,4BAA4B,EAC5B,qBAAqB,EACrB,2BAA2B,EAC3B,oBAAoB,GAQrB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAkC,MAAM,MAAM,CAAC;AAkCtD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,KAAK,UAAU,kCAAkC,CACtD,MAA0C;IAW1C,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;IAE1C,MAAM,OAAO,GAAG,MAAM,4BAA4B,CAAC;QACjD,GAAG,MAAM;QACT,SAAS;QACT,KAAK;KACN,CAAC,CAAC;IAEH,OAAO,+BAA+B,CAAC;QACrC,GAAG,MAAM;QACT,OAAO;QACP,IAAI;QACJ,iBAAiB,EAAE,2BAA2B;KAC/C,CAAC;SACC,MAAM,CAAC,yBAAyB,CAAC;SACjC,MAAM,CAAC,qBAAqB,CAAC;SAC7B,MAAM,CAAC,oBAAoB,CAAC;SAC5B,MAAM,CAAC,mBAAmB,CAAC,CAAC;AACjC,CAAC","sourcesContent":["import {\n smartAccountClientActions,\n type SmartAccountSigner,\n} from \"@aa-sdk/core\";\nimport {\n createAlchemySmartAccountClient,\n type AlchemySmartAccountClient,\n type AlchemySmartAccountClientConfig,\n} from \"@account-kit/infra\";\nimport {\n accountLoupeActions,\n createMultisigModularAccount,\n multisigPluginActions,\n multisigSignatureMiddleware,\n pluginManagerActions,\n type AccountLoupeActions,\n type CreateMultisigModularAccountParams,\n type LightAccount,\n type MultisigModularAccount,\n type MultisigPluginActions,\n type MultisigUserOperationContext,\n type PluginManagerActions,\n} from \"@account-kit/smart-contracts\";\nimport { type Chain, type HttpTransport } from \"viem\";\n\n// todo: this file seems somewhat duplicated with ./modularAccountClient.ts, but that file has some multi-owner specific fields. Is there a way to refactor these two to de-dupe?\n\nexport type AlchemyMultisigAccountClientConfig<\n TSigner extends SmartAccountSigner = SmartAccountSigner\n> = Omit<\n CreateMultisigModularAccountParams<HttpTransport, TSigner>,\n \"transport\"\n> &\n Omit<\n AlchemySmartAccountClientConfig<\n Chain,\n LightAccount<TSigner>,\n MultisigUserOperationContext\n >,\n \"account\"\n >;\n\nexport function createMultisigAccountAlchemyClient<\n TSigner extends SmartAccountSigner = SmartAccountSigner\n>(\n params: AlchemyMultisigAccountClientConfig<TSigner>\n): Promise<\n AlchemySmartAccountClient<\n Chain | undefined,\n MultisigModularAccount<TSigner>,\n MultisigPluginActions<MultisigModularAccount<TSigner>> &\n PluginManagerActions<MultisigModularAccount<TSigner>> &\n AccountLoupeActions<MultisigModularAccount<TSigner>>,\n MultisigUserOperationContext\n >\n>;\n\n/**\n * Creates an Alchemy client for a multisig account using the provided configuration.\n *\n * @example\n * ```ts\n * import { createMultisigAccountAlchemyClient } from \"@account-kit/smart-contracts\";\n * import { sepolia } from \"@account-kit/infra\";\n * import { LocalAccountSigner } from \"@aa-sdk/core\";\n * import { generatePrivateKey } from \"viem\"\n *\n * const alchemyAccountClient = await createMultisigAccountAlchemyClient({\n * transport: alchemy({ apiKey: \"your-api-key\" }),\n * chain: sepolia,\n * signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey()),\n * owners: [...], // other owners on the account\n * threshold: 2, // 2 of N signatures\n * });\n * ```\n *\n * @param {AlchemyMultisigAccountClientConfig} config The configuration for the Alchemy multisig account client\n * @returns {Promise<AlchemySmartAccountClient<Transport, Chain | undefined, MultisigModularAccount<SmartAccountSigner>, MultisigPluginActions<MultisigModularAccount<SmartAccountSigner>> & PluginManagerActions<MultisigModularAccount<SmartAccountSigner>> & AccountLoupeActions<MultisigModularAccount<SmartAccountSigner>>, MultisigUserOperationContext>>} A promise that resolves to an Alchemy Smart Account Client for multisig accounts with extended functionalities.\n */\nexport async function createMultisigAccountAlchemyClient(\n config: AlchemyMultisigAccountClientConfig\n): Promise<\n AlchemySmartAccountClient<\n Chain | undefined,\n MultisigModularAccount<SmartAccountSigner>,\n MultisigPluginActions<MultisigModularAccount<SmartAccountSigner>> &\n PluginManagerActions<MultisigModularAccount<SmartAccountSigner>> &\n AccountLoupeActions<MultisigModularAccount<SmartAccountSigner>>,\n MultisigUserOperationContext\n >\n> {\n const { transport, opts, chain } = config;\n\n const account = await createMultisigModularAccount({\n ...config,\n transport,\n chain,\n });\n\n return createAlchemySmartAccountClient({\n ...config,\n account,\n opts,\n signUserOperation: multisigSignatureMiddleware,\n })\n .extend(smartAccountClientActions)\n .extend(multisigPluginActions)\n .extend(pluginManagerActions)\n .extend(accountLoupeActions);\n}\n"]}
|
|
@@ -295,7 +295,7 @@ export declare class SessionKeySigner implements SmartAccountSigner<LocalAccount
|
|
|
295
295
|
uint248?: undefined;
|
|
296
296
|
} | {
|
|
297
297
|
[key: string]: unknown;
|
|
298
|
-
}, TPrimaryType extends
|
|
298
|
+
}, TPrimaryType extends "EIP712Domain" | keyof TTypedData = keyof TTypedData>(params: TypedDataDefinition<TTypedData, TPrimaryType>) => Promise<`0x${string}`>;
|
|
299
299
|
/**
|
|
300
300
|
* Generates a new private key and stores it in the storage.
|
|
301
301
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signer.js","sourceRoot":"","sources":["../../../../../../src/msca/plugins/session-key/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAA2B,MAAM,cAAc,CAAC;AAQ3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7C,WAAW,EAAE,CAAC;SACX,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC;SACjE,EAAE,CAAC,CAAC,CAAC,MAAM,EAAW,CAAC;SACvB,OAAO,CAAC,eAAe,CAAC;IAC3B,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,gCAAgC,CAAC;CACjE,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,2BAA2B,GAAG,qBAAqB,CAAC;AAEjE;;;;GAIG;AACH,MAAM,OAAO,gBAAgB;IAQ3B;;;;;;;;;;;OAWG;IACH,YAAY,UAAkC,EAAE;QAjBhD;;;;;WAAmB;QACnB;;;;;WAA6C;QACrC;;;;;WAA2D;QAC3D;;;;;WAAmB;QAyC3B;;;;;;;;;;;;WAYG;QACH;;;;mBAA2C,KAAK,IAAI,EAAE;gBACpD,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;YACjC,CAAC;WAAC;QAEF;;;;;;;;;;;;;WAaG;QACH;;;;mBAAgE,KAAK,EACnE,GAAG,EACH,EAAE;gBACF,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,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BACR,OAAO,GAAG,CAAC;YACb,CAAC;iBAAM,CAAC;gBACN,MAAM,MAAM,GAAG,kBAAkB,EAAE,CAAC;gBACpC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;gBACzC,OAAO,MAAM,CAAC;YAChB,CAAC;QACH,CAAC,CAAC,EAAS,CAAC;QAEZ,IAAI,CAAC,KAAK,GAAG,kBAAkB,CAAC,yBAAyB,CAAC,UAAU,CAAC,CAAC;IACxE,CAAC;CA8FF","sourcesContent":["import { LocalAccountSigner, type SmartAccountSigner } from \"@aa-sdk/core\";\nimport type {\n Hex,\n PrivateKeyAccount,\n SignableMessage,\n TypedData,\n TypedDataDefinition,\n} from \"viem\";\nimport { generatePrivateKey } from \"viem/accounts\";\nimport { z } from \"zod\";\n\nexport const SessionKeySignerSchema = z.object({\n storageType: z\n .union([z.literal(\"local-storage\"), z.literal(\"session-storage\")])\n .or(z.custom<Storage>())\n .default(\"local-storage\"),\n storageKey: z.string().default(\"session-key-signer:session-key\"),\n});\n\nexport type SessionKeySignerConfig = z.input<typeof SessionKeySignerSchema>;\nexport const SESSION_KEY_SIGNER_TYPE_PFX = \"alchemy:session-key\";\n\n/**\n * A simple session key signer that uses localStorage or sessionStorage to store\n * a private key. If the key is not found, it will generate a new one and store\n * it in the storage.\n */\nexport class SessionKeySigner\n implements SmartAccountSigner<LocalAccountSigner<PrivateKeyAccount>>\n{\n signerType: string;\n inner: LocalAccountSigner<PrivateKeyAccount>;\n private storageType: \"local-storage\" | \"session-storage\" | Storage;\n private storageKey: string;\n\n /**\n * Initializes a new instance of a session key signer with the provided configuration. This will set the `signerType`, `storageKey`, and `storageType`. It will also manage the session key, either fetching it from storage or generating a new one if it doesn't exist.\n *\n * @example\n * ```ts\n * import { SessionKeySigner } from \"@account-kit/smart-contracts\";\n *\n * const signer = new SessionKeySigner();\n * ```\n *\n * @param {SessionKeySignerConfig} config_ the configuration for initializing the session key signer\n */\n constructor(config_: SessionKeySignerConfig = {}) {\n const config = SessionKeySignerSchema.parse(config_);\n this.signerType = `${SESSION_KEY_SIGNER_TYPE_PFX}`;\n this.storageKey = config.storageKey;\n this.storageType = config.storageType;\n\n const sessionKey = (() => {\n const storage =\n typeof this.storageType !== \"string\"\n ? this.storageType\n : this.storageType === \"session-storage\"\n ? sessionStorage\n : localStorage;\n const key = storage.getItem(this.storageKey);\n\n if (key) {\n return key;\n } else {\n const newKey = generatePrivateKey();\n storage.setItem(this.storageKey, newKey);\n return newKey;\n }\n })() as Hex;\n\n this.inner = LocalAccountSigner.privateKeyToAccountSigner(sessionKey);\n }\n\n /**\n * An async function that retrieves the address using the inner object's `getAddress` method.\n *\n * @example\n * ```ts\n * import { SessionKeySigner } from \"@account-kit/smart-contracts\";\n *\n * const signer = new SessionKeySigner();\n * const sessionKeyAddress = await signer.getAddress();\n * ```\n *\n * @returns {Promise<string>} A promise that resolves to the address as a string\n */\n getAddress: () => Promise<`0x${string}`> = async () => {\n return this.inner.getAddress();\n };\n\n /**\n * Signs a message using the inner signer.\n *\n * @example\n * ```ts\n * import { SessionKeySigner } from \"@account-kit/smart-contracts\";\n *\n * const signer = new SessionKeySigner();\n * const sessionKeyAddress = await signer.signMessage(\"hello\");\n * ```\n *\n * @param {SignableMessage} msg The message to sign\n * @returns {Promise<Hex>} A promise that resolves to the signed message\n */\n signMessage: (msg: SignableMessage) => Promise<`0x${string}`> = async (\n msg\n ) => {\n return this.inner.signMessage(msg);\n };\n\n /**\n * Signs the provided typed data using the inner signer.\n *\n * @example\n * ```ts\n * import { SessionKeySigner } from \"@account-kit/smart-contracts\";\n *\n * const signer = new SessionKeySigner();\n * console.log(await signer.signTypedData({\n * types: {\n * \"Message\": [{ name: \"content\", type: \"string\" }]\n * },\n * primaryType: \"Message\",\n * message: { content: \"Hello\" },\n * }));\n * ```\n *\n * @template TTypedData - The typed data type, which extends `TypedData` or a record of unknown keys to unknown values.\n * @template TPrimaryType - The primary type of the typed data.\n *\n * @param {TypedDataDefinition<TTypedData, TPrimaryType>} params The parameters containing the typed data definition and primary type.\n * @returns {Promise<string>} A promise that resolves to the signed typed data as a string.\n */\n signTypedData = async <\n const TTypedData extends TypedData | { [key: string]: unknown },\n TPrimaryType extends
|
|
1
|
+
{"version":3,"file":"signer.js","sourceRoot":"","sources":["../../../../../../src/msca/plugins/session-key/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAA2B,MAAM,cAAc,CAAC;AAQ3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7C,WAAW,EAAE,CAAC;SACX,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC;SACjE,EAAE,CAAC,CAAC,CAAC,MAAM,EAAW,CAAC;SACvB,OAAO,CAAC,eAAe,CAAC;IAC3B,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,gCAAgC,CAAC;CACjE,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,2BAA2B,GAAG,qBAAqB,CAAC;AAEjE;;;;GAIG;AACH,MAAM,OAAO,gBAAgB;IAQ3B;;;;;;;;;;;OAWG;IACH,YAAY,UAAkC,EAAE;QAjBhD;;;;;WAAmB;QACnB;;;;;WAA6C;QACrC;;;;;WAA2D;QAC3D;;;;;WAAmB;QAyC3B;;;;;;;;;;;;WAYG;QACH;;;;mBAA2C,KAAK,IAAI,EAAE;gBACpD,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;YACjC,CAAC;WAAC;QAEF;;;;;;;;;;;;;WAaG;QACH;;;;mBAAgE,KAAK,EACnE,GAAG,EACH,EAAE;gBACF,OAAO,IAAI,CAAC,KAAK,CAAC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IAAI,GAAG,EAAE,CAAC;gBACR,OAAO,GAAG,CAAC;YACb,CAAC;iBAAM,CAAC;gBACN,MAAM,MAAM,GAAG,kBAAkB,EAAE,CAAC;gBACpC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;gBACzC,OAAO,MAAM,CAAC;YAChB,CAAC;QACH,CAAC,CAAC,EAAS,CAAC;QAEZ,IAAI,CAAC,KAAK,GAAG,kBAAkB,CAAC,yBAAyB,CAAC,UAAU,CAAC,CAAC;IACxE,CAAC;CA8FF","sourcesContent":["import { LocalAccountSigner, type SmartAccountSigner } from \"@aa-sdk/core\";\nimport type {\n Hex,\n PrivateKeyAccount,\n SignableMessage,\n TypedData,\n TypedDataDefinition,\n} from \"viem\";\nimport { generatePrivateKey } from \"viem/accounts\";\nimport { z } from \"zod\";\n\nexport const SessionKeySignerSchema = z.object({\n storageType: z\n .union([z.literal(\"local-storage\"), z.literal(\"session-storage\")])\n .or(z.custom<Storage>())\n .default(\"local-storage\"),\n storageKey: z.string().default(\"session-key-signer:session-key\"),\n});\n\nexport type SessionKeySignerConfig = z.input<typeof SessionKeySignerSchema>;\nexport const SESSION_KEY_SIGNER_TYPE_PFX = \"alchemy:session-key\";\n\n/**\n * A simple session key signer that uses localStorage or sessionStorage to store\n * a private key. If the key is not found, it will generate a new one and store\n * it in the storage.\n */\nexport class SessionKeySigner\n implements SmartAccountSigner<LocalAccountSigner<PrivateKeyAccount>>\n{\n signerType: string;\n inner: LocalAccountSigner<PrivateKeyAccount>;\n private storageType: \"local-storage\" | \"session-storage\" | Storage;\n private storageKey: string;\n\n /**\n * Initializes a new instance of a session key signer with the provided configuration. This will set the `signerType`, `storageKey`, and `storageType`. It will also manage the session key, either fetching it from storage or generating a new one if it doesn't exist.\n *\n * @example\n * ```ts\n * import { SessionKeySigner } from \"@account-kit/smart-contracts\";\n *\n * const signer = new SessionKeySigner();\n * ```\n *\n * @param {SessionKeySignerConfig} config_ the configuration for initializing the session key signer\n */\n constructor(config_: SessionKeySignerConfig = {}) {\n const config = SessionKeySignerSchema.parse(config_);\n this.signerType = `${SESSION_KEY_SIGNER_TYPE_PFX}`;\n this.storageKey = config.storageKey;\n this.storageType = config.storageType;\n\n const sessionKey = (() => {\n const storage =\n typeof this.storageType !== \"string\"\n ? this.storageType\n : this.storageType === \"session-storage\"\n ? sessionStorage\n : localStorage;\n const key = storage.getItem(this.storageKey);\n\n if (key) {\n return key;\n } else {\n const newKey = generatePrivateKey();\n storage.setItem(this.storageKey, newKey);\n return newKey;\n }\n })() as Hex;\n\n this.inner = LocalAccountSigner.privateKeyToAccountSigner(sessionKey);\n }\n\n /**\n * An async function that retrieves the address using the inner object's `getAddress` method.\n *\n * @example\n * ```ts\n * import { SessionKeySigner } from \"@account-kit/smart-contracts\";\n *\n * const signer = new SessionKeySigner();\n * const sessionKeyAddress = await signer.getAddress();\n * ```\n *\n * @returns {Promise<string>} A promise that resolves to the address as a string\n */\n getAddress: () => Promise<`0x${string}`> = async () => {\n return this.inner.getAddress();\n };\n\n /**\n * Signs a message using the inner signer.\n *\n * @example\n * ```ts\n * import { SessionKeySigner } from \"@account-kit/smart-contracts\";\n *\n * const signer = new SessionKeySigner();\n * const sessionKeyAddress = await signer.signMessage(\"hello\");\n * ```\n *\n * @param {SignableMessage} msg The message to sign\n * @returns {Promise<Hex>} A promise that resolves to the signed message\n */\n signMessage: (msg: SignableMessage) => Promise<`0x${string}`> = async (\n msg\n ) => {\n return this.inner.signMessage(msg);\n };\n\n /**\n * Signs the provided typed data using the inner signer.\n *\n * @example\n * ```ts\n * import { SessionKeySigner } from \"@account-kit/smart-contracts\";\n *\n * const signer = new SessionKeySigner();\n * console.log(await signer.signTypedData({\n * types: {\n * \"Message\": [{ name: \"content\", type: \"string\" }]\n * },\n * primaryType: \"Message\",\n * message: { content: \"Hello\" },\n * }));\n * ```\n *\n * @template TTypedData - The typed data type, which extends `TypedData` or a record of unknown keys to unknown values.\n * @template TPrimaryType - The primary type of the typed data.\n *\n * @param {TypedDataDefinition<TTypedData, TPrimaryType>} params The parameters containing the typed data definition and primary type.\n * @returns {Promise<string>} A promise that resolves to the signed typed data as a string.\n */\n signTypedData = async <\n const TTypedData extends TypedData | { [key: string]: unknown },\n TPrimaryType extends keyof TTypedData | \"EIP712Domain\" = keyof TTypedData\n >(\n params: TypedDataDefinition<TTypedData, TPrimaryType>\n ) => {\n return this.inner.signTypedData(params);\n };\n\n /**\n * Generates a new private key and stores it in the storage.\n *\n * @example\n * ```ts\n * import { SessionKeySigner } from \"@account-kit/smart-contracts\";\n *\n * const signer = new SessionKeySigner();\n * const newSessionKey = signer.generateNewKey();\n * ```\n *\n * @returns {Address} The public address of the new key.\n */\n generateNewKey = () => {\n const storage =\n this.storageType === \"session-storage\" ? sessionStorage : localStorage;\n\n const newKey = generatePrivateKey();\n storage.setItem(this.storageKey, newKey);\n this.inner = LocalAccountSigner.privateKeyToAccountSigner(newKey);\n\n return this.inner.inner.address;\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,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,CAA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,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"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { HttpTransport, SmartAccountSigner } from "@aa-sdk/core";
|
|
2
2
|
import { type AlchemySmartAccountClient, type AlchemySmartAccountClientConfig } from "@account-kit/infra";
|
|
3
3
|
import { type CreateLightAccountParams, type LightAccount, type LightAccountClientActions } from "@account-kit/smart-contracts";
|
|
4
|
-
import { type Chain
|
|
5
|
-
export type AlchemyLightAccountClientConfig<TSigner extends SmartAccountSigner = SmartAccountSigner> = Omit<CreateLightAccountParams<HttpTransport, TSigner>, "transport"
|
|
6
|
-
export declare function createLightAccountAlchemyClient<TSigner extends SmartAccountSigner = SmartAccountSigner>(params: AlchemyLightAccountClientConfig<TSigner>): Promise<AlchemySmartAccountClient<
|
|
4
|
+
import { type Chain } from "viem";
|
|
5
|
+
export type AlchemyLightAccountClientConfig<TSigner extends SmartAccountSigner = SmartAccountSigner> = Omit<CreateLightAccountParams<HttpTransport, TSigner>, "transport"> & Omit<AlchemySmartAccountClientConfig<Chain, LightAccount<TSigner>>, "account">;
|
|
6
|
+
export declare function createLightAccountAlchemyClient<TSigner extends SmartAccountSigner = SmartAccountSigner>(params: AlchemyLightAccountClientConfig<TSigner>): Promise<AlchemySmartAccountClient<Chain | undefined, LightAccount<TSigner>, LightAccountClientActions<TSigner>>>;
|
|
7
7
|
//# sourceMappingURL=alchemyClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alchemyClient.d.ts","sourceRoot":"","sources":["../../../../../src/light-account/clients/alchemyClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,
|
|
1
|
+
{"version":3,"file":"alchemyClient.d.ts","sourceRoot":"","sources":["../../../../../src/light-account/clients/alchemyClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EAEL,KAAK,yBAAyB,EAC9B,KAAK,+BAA+B,EACrC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAGL,KAAK,wBAAwB,EAC7B,KAAK,YAAY,EACjB,KAAK,yBAAyB,EAC/B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,MAAM,CAAC;AAElC,MAAM,MAAM,+BAA+B,CACzC,OAAO,SAAS,kBAAkB,GAAG,kBAAkB,IACrD,IAAI,CAAC,wBAAwB,CAAC,aAAa,EAAE,OAAO,CAAC,EAAE,WAAW,CAAC,GACrE,IAAI,CACF,+BAA+B,CAAC,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC,EAC7D,SAAS,CACV,CAAC;AAEJ,wBAAsB,+BAA+B,CACnD,OAAO,SAAS,kBAAkB,GAAG,kBAAkB,EAEvD,MAAM,EAAE,+BAA+B,CAAC,OAAO,CAAC,GAC/C,OAAO,CACR,yBAAyB,CACvB,KAAK,GAAG,SAAS,EACjB,YAAY,CAAC,OAAO,CAAC,EACrB,yBAAyB,CAAC,OAAO,CAAC,CACnC,CACF,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { HttpTransport, SmartAccountSigner } from "@aa-sdk/core";
|
|
2
2
|
import { type AlchemySmartAccountClient, type AlchemySmartAccountClientConfig } from "@account-kit/infra";
|
|
3
3
|
import { type CreateMultiOwnerLightAccountParams, type MultiOwnerLightAccount, type MultiOwnerLightAccountClientActions } from "@account-kit/smart-contracts";
|
|
4
|
-
import { type Chain
|
|
5
|
-
export type AlchemyMultiOwnerLightAccountClientConfig<TSigner extends SmartAccountSigner = SmartAccountSigner> = Omit<CreateMultiOwnerLightAccountParams<HttpTransport, TSigner>, "transport" | "
|
|
6
|
-
export declare function createMultiOwnerLightAccountAlchemyClient<TSigner extends SmartAccountSigner = SmartAccountSigner>(params: AlchemyMultiOwnerLightAccountClientConfig<TSigner>): Promise<AlchemySmartAccountClient<
|
|
4
|
+
import { type Chain } from "viem";
|
|
5
|
+
export type AlchemyMultiOwnerLightAccountClientConfig<TSigner extends SmartAccountSigner = SmartAccountSigner> = Omit<CreateMultiOwnerLightAccountParams<HttpTransport, TSigner>, "transport" | "type"> & Omit<AlchemySmartAccountClientConfig<Chain, MultiOwnerLightAccount<TSigner>>, "account">;
|
|
6
|
+
export declare function createMultiOwnerLightAccountAlchemyClient<TSigner extends SmartAccountSigner = SmartAccountSigner>(params: AlchemyMultiOwnerLightAccountClientConfig<TSigner>): Promise<AlchemySmartAccountClient<Chain | undefined, MultiOwnerLightAccount<TSigner>, MultiOwnerLightAccountClientActions<TSigner>>>;
|
|
7
7
|
//# sourceMappingURL=multiOwnerAlchemyClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multiOwnerAlchemyClient.d.ts","sourceRoot":"","sources":["../../../../../src/light-account/clients/multiOwnerAlchemyClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,
|
|
1
|
+
{"version":3,"file":"multiOwnerAlchemyClient.d.ts","sourceRoot":"","sources":["../../../../../src/light-account/clients/multiOwnerAlchemyClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EAEL,KAAK,yBAAyB,EAC9B,KAAK,+BAA+B,EACrC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAGL,KAAK,kCAAkC,EACvC,KAAK,sBAAsB,EAC3B,KAAK,mCAAmC,EACzC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,MAAM,CAAC;AAElC,MAAM,MAAM,yCAAyC,CACnD,OAAO,SAAS,kBAAkB,GAAG,kBAAkB,IACrD,IAAI,CACN,kCAAkC,CAAC,aAAa,EAAE,OAAO,CAAC,EAC1D,WAAW,GAAG,MAAM,CACrB,GACC,IAAI,CACF,+BAA+B,CAAC,KAAK,EAAE,sBAAsB,CAAC,OAAO,CAAC,CAAC,EACvE,SAAS,CACV,CAAC;AAEJ,wBAAsB,yCAAyC,CAC7D,OAAO,SAAS,kBAAkB,GAAG,kBAAkB,EAEvD,MAAM,EAAE,yCAAyC,CAAC,OAAO,CAAC,GACzD,OAAO,CACR,yBAAyB,CACvB,KAAK,GAAG,SAAS,EACjB,sBAAsB,CAAC,OAAO,CAAC,EAC/B,mCAAmC,CAAC,OAAO,CAAC,CAC7C,CACF,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SmartAccountSigner } from "@aa-sdk/core";
|
|
2
2
|
import { type AlchemySmartAccountClient, type AlchemySmartAccountClientConfig } from "@account-kit/infra";
|
|
3
3
|
import { type AccountLoupeActions, type CreateMultiOwnerModularAccountParams, type LightAccount, type MultiOwnerModularAccount, type MultiOwnerPluginActions, type PluginManagerActions } from "@account-kit/smart-contracts";
|
|
4
|
-
import { type Chain, type
|
|
5
|
-
export type AlchemyModularAccountClientConfig<TSigner extends SmartAccountSigner = SmartAccountSigner> = Omit<CreateMultiOwnerModularAccountParams<HttpTransport, TSigner>, "transport"
|
|
6
|
-
export declare function createModularAccountAlchemyClient<TSigner extends SmartAccountSigner = SmartAccountSigner>(params: AlchemyModularAccountClientConfig<TSigner>): Promise<AlchemySmartAccountClient<
|
|
4
|
+
import { type Chain, type HttpTransport } from "viem";
|
|
5
|
+
export type AlchemyModularAccountClientConfig<TSigner extends SmartAccountSigner = SmartAccountSigner> = Omit<CreateMultiOwnerModularAccountParams<HttpTransport, TSigner>, "transport"> & Omit<AlchemySmartAccountClientConfig<Chain, LightAccount<TSigner>>, "account">;
|
|
6
|
+
export declare function createModularAccountAlchemyClient<TSigner extends SmartAccountSigner = SmartAccountSigner>(params: AlchemyModularAccountClientConfig<TSigner>): Promise<AlchemySmartAccountClient<Chain | undefined, MultiOwnerModularAccount<TSigner>, MultiOwnerPluginActions<MultiOwnerModularAccount<TSigner>> & PluginManagerActions<MultiOwnerModularAccount<TSigner>> & AccountLoupeActions<MultiOwnerModularAccount<TSigner>>>>;
|
|
7
7
|
//# sourceMappingURL=alchemyClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alchemyClient.d.ts","sourceRoot":"","sources":["../../../../../src/msca/client/alchemyClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,
|
|
1
|
+
{"version":3,"file":"alchemyClient.d.ts","sourceRoot":"","sources":["../../../../../src/msca/client/alchemyClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAEL,KAAK,yBAAyB,EAC9B,KAAK,+BAA+B,EACrC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAKL,KAAK,mBAAmB,EACxB,KAAK,oCAAoC,EACzC,KAAK,YAAY,EACjB,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EAC1B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,aAAa,EAAE,MAAM,MAAM,CAAC;AAEtD,MAAM,MAAM,iCAAiC,CAC3C,OAAO,SAAS,kBAAkB,GAAG,kBAAkB,IACrD,IAAI,CACN,oCAAoC,CAAC,aAAa,EAAE,OAAO,CAAC,EAC5D,WAAW,CACZ,GACC,IAAI,CACF,+BAA+B,CAAC,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC,EAC7D,SAAS,CACV,CAAC;AAEJ,wBAAgB,iCAAiC,CAC/C,OAAO,SAAS,kBAAkB,GAAG,kBAAkB,EAEvD,MAAM,EAAE,iCAAiC,CAAC,OAAO,CAAC,GACjD,OAAO,CACR,yBAAyB,CACvB,KAAK,GAAG,SAAS,EACjB,wBAAwB,CAAC,OAAO,CAAC,EACjC,uBAAuB,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAC,GACxD,oBAAoB,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAC,GACvD,mBAAmB,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAC,CACzD,CACF,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type SmartAccountSigner } from "@aa-sdk/core";
|
|
2
2
|
import { type AlchemySmartAccountClient, type AlchemySmartAccountClientConfig } from "@account-kit/infra";
|
|
3
3
|
import { type AccountLoupeActions, type CreateMultisigModularAccountParams, type LightAccount, type MultisigModularAccount, type MultisigPluginActions, type MultisigUserOperationContext, type PluginManagerActions } from "@account-kit/smart-contracts";
|
|
4
|
-
import { type Chain, type
|
|
5
|
-
export type AlchemyMultisigAccountClientConfig<TSigner extends SmartAccountSigner = SmartAccountSigner> = Omit<CreateMultisigModularAccountParams<HttpTransport, TSigner>, "transport"
|
|
6
|
-
export declare function createMultisigAccountAlchemyClient<TSigner extends SmartAccountSigner = SmartAccountSigner>(params: AlchemyMultisigAccountClientConfig<TSigner>): Promise<AlchemySmartAccountClient<
|
|
4
|
+
import { type Chain, type HttpTransport } from "viem";
|
|
5
|
+
export type AlchemyMultisigAccountClientConfig<TSigner extends SmartAccountSigner = SmartAccountSigner> = Omit<CreateMultisigModularAccountParams<HttpTransport, TSigner>, "transport"> & Omit<AlchemySmartAccountClientConfig<Chain, LightAccount<TSigner>, MultisigUserOperationContext>, "account">;
|
|
6
|
+
export declare function createMultisigAccountAlchemyClient<TSigner extends SmartAccountSigner = SmartAccountSigner>(params: AlchemyMultisigAccountClientConfig<TSigner>): Promise<AlchemySmartAccountClient<Chain | undefined, MultisigModularAccount<TSigner>, MultisigPluginActions<MultisigModularAccount<TSigner>> & PluginManagerActions<MultisigModularAccount<TSigner>> & AccountLoupeActions<MultisigModularAccount<TSigner>>, MultisigUserOperationContext>>;
|
|
7
7
|
//# sourceMappingURL=multiSigAlchemyClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multiSigAlchemyClient.d.ts","sourceRoot":"","sources":["../../../../../src/msca/client/multiSigAlchemyClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,cAAc,CAAC;AACtB,OAAO,
|
|
1
|
+
{"version":3,"file":"multiSigAlchemyClient.d.ts","sourceRoot":"","sources":["../../../../../src/msca/client/multiSigAlchemyClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,cAAc,CAAC;AACtB,OAAO,EAEL,KAAK,yBAAyB,EAC9B,KAAK,+BAA+B,EACrC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAML,KAAK,mBAAmB,EACxB,KAAK,kCAAkC,EACvC,KAAK,YAAY,EACjB,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,4BAA4B,EACjC,KAAK,oBAAoB,EAC1B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,aAAa,EAAE,MAAM,MAAM,CAAC;AAItD,MAAM,MAAM,kCAAkC,CAC5C,OAAO,SAAS,kBAAkB,GAAG,kBAAkB,IACrD,IAAI,CACN,kCAAkC,CAAC,aAAa,EAAE,OAAO,CAAC,EAC1D,WAAW,CACZ,GACC,IAAI,CACF,+BAA+B,CAC7B,KAAK,EACL,YAAY,CAAC,OAAO,CAAC,EACrB,4BAA4B,CAC7B,EACD,SAAS,CACV,CAAC;AAEJ,wBAAgB,kCAAkC,CAChD,OAAO,SAAS,kBAAkB,GAAG,kBAAkB,EAEvD,MAAM,EAAE,kCAAkC,CAAC,OAAO,CAAC,GAClD,OAAO,CACR,yBAAyB,CACvB,KAAK,GAAG,SAAS,EACjB,sBAAsB,CAAC,OAAO,CAAC,EAC/B,qBAAqB,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC,GACpD,oBAAoB,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC,GACrD,mBAAmB,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC,EACtD,4BAA4B,CAC7B,CACF,CAAC"}
|
|
@@ -295,7 +295,7 @@ export declare class SessionKeySigner implements SmartAccountSigner<LocalAccount
|
|
|
295
295
|
uint248?: undefined;
|
|
296
296
|
} | {
|
|
297
297
|
[key: string]: unknown;
|
|
298
|
-
}, TPrimaryType extends
|
|
298
|
+
}, TPrimaryType extends "EIP712Domain" | keyof TTypedData = keyof TTypedData>(params: TypedDataDefinition<TTypedData, TPrimaryType>) => Promise<`0x${string}`>;
|
|
299
299
|
/**
|
|
300
300
|
* Generates a new private key and stores it in the storage.
|
|
301
301
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../../../../../src/msca/plugins/session-key/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,KAAK,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,KAAK,EAEV,iBAAiB,EACjB,eAAe,EAEf,mBAAmB,EACpB,MAAM,MA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0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.10",
|
|
4
4
|
"description": "aa-sdk compatible interfaces for Alchemy Smart Accounts",
|
|
5
5
|
"author": "Alchemy",
|
|
6
6
|
"license": "MIT",
|
|
@@ -42,12 +42,10 @@
|
|
|
42
42
|
"docs:gen": "npx ak-docgen generate --in ./src/index.ts --out ../../site/pages/reference/account-kit/smart-contracts",
|
|
43
43
|
"clean": "rm -rf ./dist",
|
|
44
44
|
"test": "vitest",
|
|
45
|
-
"test:run": "vitest run"
|
|
46
|
-
"test:run-e2e": "vitest run --config vitest.config.e2e.ts"
|
|
45
|
+
"test:run": "vitest run"
|
|
47
46
|
},
|
|
48
47
|
"devDependencies": {
|
|
49
|
-
"@account-kit/plugingen": "^4.0.0-beta.
|
|
50
|
-
"@wagmi/cli": "^1.5.2",
|
|
48
|
+
"@account-kit/plugingen": "^4.0.0-beta.10",
|
|
51
49
|
"change-case": "^5.1.2",
|
|
52
50
|
"dedent": "^1.5.1",
|
|
53
51
|
"dotenv": "^16.3.1",
|
|
@@ -67,13 +65,12 @@
|
|
|
67
65
|
"url": "https://github.com/alchemyplatform/aa-sdk/issues"
|
|
68
66
|
},
|
|
69
67
|
"homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
|
|
70
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "3429eb6a07e6a929a1c2069839a525135d081d3e",
|
|
71
69
|
"dependencies": {
|
|
72
|
-
"@aa-sdk/core": "^4.0.0-beta.
|
|
73
|
-
"@account-kit/infra": "^4.0.0-beta.
|
|
74
|
-
"viem": "2.20.0"
|
|
70
|
+
"@aa-sdk/core": "^4.0.0-beta.10",
|
|
71
|
+
"@account-kit/infra": "^4.0.0-beta.10"
|
|
75
72
|
},
|
|
76
73
|
"peerDependencies": {
|
|
77
|
-
"viem": "2.20.0"
|
|
74
|
+
"viem": "^2.20.0"
|
|
78
75
|
}
|
|
79
76
|
}
|
|
@@ -139,7 +139,10 @@ export async function createLightAccountBase<
|
|
|
139
139
|
});
|
|
140
140
|
};
|
|
141
141
|
|
|
142
|
-
const
|
|
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
|
|
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
|
|
213
|
+
return signWith1271Wrapper(hashMessage(message), "1");
|
|
211
214
|
case "v2.0.0":
|
|
212
|
-
const signature = await
|
|
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
|
|
236
|
+
return signWith1271Wrapper(hashTypedData(params), "1");
|
|
231
237
|
case "v2.0.0":
|
|
232
|
-
const signature = await
|
|
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:
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { HttpTransport, SmartAccountSigner } from "@aa-sdk/core";
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
createAlchemyPublicRpcClient,
|
|
5
|
-
createAlchemySmartAccountClientFromExisting,
|
|
3
|
+
createAlchemySmartAccountClient,
|
|
6
4
|
type AlchemySmartAccountClient,
|
|
7
5
|
type AlchemySmartAccountClientConfig,
|
|
8
6
|
} from "@account-kit/infra";
|
|
@@ -13,16 +11,13 @@ import {
|
|
|
13
11
|
type LightAccount,
|
|
14
12
|
type LightAccountClientActions,
|
|
15
13
|
} from "@account-kit/smart-contracts";
|
|
16
|
-
import {
|
|
14
|
+
import { type Chain } from "viem";
|
|
17
15
|
|
|
18
16
|
export type AlchemyLightAccountClientConfig<
|
|
19
17
|
TSigner extends SmartAccountSigner = SmartAccountSigner
|
|
20
|
-
> = Omit<
|
|
21
|
-
CreateLightAccountParams<HttpTransport, TSigner>,
|
|
22
|
-
"transport" | "chain"
|
|
23
|
-
> &
|
|
18
|
+
> = Omit<CreateLightAccountParams<HttpTransport, TSigner>, "transport"> &
|
|
24
19
|
Omit<
|
|
25
|
-
AlchemySmartAccountClientConfig<
|
|
20
|
+
AlchemySmartAccountClientConfig<Chain, LightAccount<TSigner>>,
|
|
26
21
|
"account"
|
|
27
22
|
>;
|
|
28
23
|
|
|
@@ -32,7 +27,6 @@ export async function createLightAccountAlchemyClient<
|
|
|
32
27
|
params: AlchemyLightAccountClientConfig<TSigner>
|
|
33
28
|
): Promise<
|
|
34
29
|
AlchemySmartAccountClient<
|
|
35
|
-
CustomTransport,
|
|
36
30
|
Chain | undefined,
|
|
37
31
|
LightAccount<TSigner>,
|
|
38
32
|
LightAccountClientActions<TSigner>
|
|
@@ -45,12 +39,12 @@ export async function createLightAccountAlchemyClient<
|
|
|
45
39
|
* @example
|
|
46
40
|
* ```ts
|
|
47
41
|
* import { createLightAccountAlchemyClient } from "@account-kit/smart-contracts";
|
|
48
|
-
* import { sepolia } from "@account-kit/infra";
|
|
42
|
+
* import { sepolia, alchemy } from "@account-kit/infra";
|
|
49
43
|
* import { LocalAccountSigner } from "@aa-sdk/core";
|
|
50
44
|
* import { generatePrivateKey } from "viem"
|
|
51
45
|
*
|
|
52
46
|
* const lightAccountClient = await createLightAccountAlchemyClient({
|
|
53
|
-
* apiKey: "your-api-key",
|
|
47
|
+
* transport: alchemy({ apiKey: "your-api-key" }),
|
|
54
48
|
* chain: sepolia,
|
|
55
49
|
* signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey())
|
|
56
50
|
* });
|
|
@@ -59,25 +53,22 @@ export async function createLightAccountAlchemyClient<
|
|
|
59
53
|
* @param {AlchemyLightAccountClientConfig} config The configuration for setting up the Alchemy Light Account Client
|
|
60
54
|
* @returns {Promise<AlchemySmartAccountClient>} A promise that resolves to an `AlchemySmartAccountClient` object containing the created client
|
|
61
55
|
*/
|
|
62
|
-
export async function createLightAccountAlchemyClient(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const client = createAlchemyPublicRpcClient({
|
|
69
|
-
chain,
|
|
70
|
-
connectionConfig,
|
|
71
|
-
});
|
|
72
|
-
|
|
56
|
+
export async function createLightAccountAlchemyClient({
|
|
57
|
+
opts,
|
|
58
|
+
transport,
|
|
59
|
+
chain,
|
|
60
|
+
...config
|
|
61
|
+
}: AlchemyLightAccountClientConfig): Promise<AlchemySmartAccountClient> {
|
|
73
62
|
const account = await createLightAccount({
|
|
74
|
-
transport: custom(client),
|
|
75
63
|
...config,
|
|
64
|
+
transport,
|
|
65
|
+
chain,
|
|
76
66
|
});
|
|
77
67
|
|
|
78
|
-
return
|
|
68
|
+
return createAlchemySmartAccountClient({
|
|
79
69
|
...config,
|
|
80
|
-
|
|
70
|
+
transport,
|
|
71
|
+
chain,
|
|
81
72
|
account,
|
|
82
73
|
opts,
|
|
83
74
|
}).extend(lightAccountClientActions);
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { HttpTransport, SmartAccountSigner } from "@aa-sdk/core";
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
createAlchemyPublicRpcClient,
|
|
5
|
-
createAlchemySmartAccountClientFromExisting,
|
|
3
|
+
createAlchemySmartAccountClient,
|
|
6
4
|
type AlchemySmartAccountClient,
|
|
7
5
|
type AlchemySmartAccountClientConfig,
|
|
8
6
|
} from "@account-kit/infra";
|
|
@@ -13,20 +11,16 @@ import {
|
|
|
13
11
|
type MultiOwnerLightAccount,
|
|
14
12
|
type MultiOwnerLightAccountClientActions,
|
|
15
13
|
} from "@account-kit/smart-contracts";
|
|
16
|
-
import {
|
|
14
|
+
import { type Chain } from "viem";
|
|
17
15
|
|
|
18
16
|
export type AlchemyMultiOwnerLightAccountClientConfig<
|
|
19
17
|
TSigner extends SmartAccountSigner = SmartAccountSigner
|
|
20
18
|
> = Omit<
|
|
21
19
|
CreateMultiOwnerLightAccountParams<HttpTransport, TSigner>,
|
|
22
|
-
"transport" | "
|
|
20
|
+
"transport" | "type"
|
|
23
21
|
> &
|
|
24
22
|
Omit<
|
|
25
|
-
AlchemySmartAccountClientConfig<
|
|
26
|
-
Transport,
|
|
27
|
-
Chain,
|
|
28
|
-
MultiOwnerLightAccount<TSigner>
|
|
29
|
-
>,
|
|
23
|
+
AlchemySmartAccountClientConfig<Chain, MultiOwnerLightAccount<TSigner>>,
|
|
30
24
|
"account"
|
|
31
25
|
>;
|
|
32
26
|
|
|
@@ -36,7 +30,6 @@ export async function createMultiOwnerLightAccountAlchemyClient<
|
|
|
36
30
|
params: AlchemyMultiOwnerLightAccountClientConfig<TSigner>
|
|
37
31
|
): Promise<
|
|
38
32
|
AlchemySmartAccountClient<
|
|
39
|
-
CustomTransport,
|
|
40
33
|
Chain | undefined,
|
|
41
34
|
MultiOwnerLightAccount<TSigner>,
|
|
42
35
|
MultiOwnerLightAccountClientActions<TSigner>
|
|
@@ -49,13 +42,15 @@ export async function createMultiOwnerLightAccountAlchemyClient<
|
|
|
49
42
|
* @example
|
|
50
43
|
* ```ts
|
|
51
44
|
* import { createMultiOwnerLightAccountAlchemyClient } from "@account-kit/smart-contracts";
|
|
52
|
-
* import { sepolia } from "@account-kit/infra";
|
|
45
|
+
* import { sepolia, alchemy } from "@account-kit/infra";
|
|
53
46
|
* import { LocalAccountSigner } from "@aa-sdk/core";
|
|
54
47
|
* import { generatePrivateKey } from "viem"
|
|
55
48
|
*
|
|
56
49
|
* const lightAccountClient = await createMultiOwnerLightAccountAlchemyClient({
|
|
57
|
-
*
|
|
58
|
-
*
|
|
50
|
+
* transport: alchemy({
|
|
51
|
+
* apiKey: "your-api-key",
|
|
52
|
+
* }),
|
|
53
|
+
* chain: sepolia
|
|
59
54
|
* signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey())
|
|
60
55
|
* });
|
|
61
56
|
* ```
|
|
@@ -63,25 +58,22 @@ export async function createMultiOwnerLightAccountAlchemyClient<
|
|
|
63
58
|
* @param {AlchemyMultiOwnerLightAccountClientConfig} config The configuration for creating the Alchemy client
|
|
64
59
|
* @returns {Promise<AlchemySmartAccountClient>} A promise that resolves to an `AlchemySmartAccountClient` object containing the created account information and methods
|
|
65
60
|
*/
|
|
66
|
-
export async function createMultiOwnerLightAccountAlchemyClient(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const client = createAlchemyPublicRpcClient({
|
|
73
|
-
chain,
|
|
74
|
-
connectionConfig,
|
|
75
|
-
});
|
|
76
|
-
|
|
61
|
+
export async function createMultiOwnerLightAccountAlchemyClient({
|
|
62
|
+
opts,
|
|
63
|
+
transport,
|
|
64
|
+
chain,
|
|
65
|
+
...config
|
|
66
|
+
}: AlchemyMultiOwnerLightAccountClientConfig): Promise<AlchemySmartAccountClient> {
|
|
77
67
|
const account = await createMultiOwnerLightAccount({
|
|
78
|
-
transport: custom(client),
|
|
79
68
|
...config,
|
|
69
|
+
transport,
|
|
70
|
+
chain,
|
|
80
71
|
});
|
|
81
72
|
|
|
82
|
-
return
|
|
73
|
+
return createAlchemySmartAccountClient({
|
|
83
74
|
...config,
|
|
84
|
-
|
|
75
|
+
transport,
|
|
76
|
+
chain,
|
|
85
77
|
account,
|
|
86
78
|
opts,
|
|
87
79
|
}).extend(multiOwnerLightAccountClientActions);
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { SmartAccountSigner } from "@aa-sdk/core";
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
createAlchemyPublicRpcClient,
|
|
5
|
-
createAlchemySmartAccountClientFromExisting,
|
|
3
|
+
createAlchemySmartAccountClient,
|
|
6
4
|
type AlchemySmartAccountClient,
|
|
7
5
|
type AlchemySmartAccountClientConfig,
|
|
8
6
|
} from "@account-kit/infra";
|
|
@@ -18,22 +16,16 @@ import {
|
|
|
18
16
|
type MultiOwnerPluginActions,
|
|
19
17
|
type PluginManagerActions,
|
|
20
18
|
} from "@account-kit/smart-contracts";
|
|
21
|
-
import {
|
|
22
|
-
custom,
|
|
23
|
-
type Chain,
|
|
24
|
-
type CustomTransport,
|
|
25
|
-
type HttpTransport,
|
|
26
|
-
type Transport,
|
|
27
|
-
} from "viem";
|
|
19
|
+
import { type Chain, type HttpTransport } from "viem";
|
|
28
20
|
|
|
29
21
|
export type AlchemyModularAccountClientConfig<
|
|
30
22
|
TSigner extends SmartAccountSigner = SmartAccountSigner
|
|
31
23
|
> = Omit<
|
|
32
24
|
CreateMultiOwnerModularAccountParams<HttpTransport, TSigner>,
|
|
33
|
-
"transport"
|
|
25
|
+
"transport"
|
|
34
26
|
> &
|
|
35
27
|
Omit<
|
|
36
|
-
AlchemySmartAccountClientConfig<
|
|
28
|
+
AlchemySmartAccountClientConfig<Chain, LightAccount<TSigner>>,
|
|
37
29
|
"account"
|
|
38
30
|
>;
|
|
39
31
|
|
|
@@ -43,7 +35,6 @@ export function createModularAccountAlchemyClient<
|
|
|
43
35
|
params: AlchemyModularAccountClientConfig<TSigner>
|
|
44
36
|
): Promise<
|
|
45
37
|
AlchemySmartAccountClient<
|
|
46
|
-
CustomTransport,
|
|
47
38
|
Chain | undefined,
|
|
48
39
|
MultiOwnerModularAccount<TSigner>,
|
|
49
40
|
MultiOwnerPluginActions<MultiOwnerModularAccount<TSigner>> &
|
|
@@ -58,12 +49,12 @@ export function createModularAccountAlchemyClient<
|
|
|
58
49
|
* @example
|
|
59
50
|
* ```ts
|
|
60
51
|
* import { createModularAccountAlchemyClient } from "@account-kit/smart-contracts";
|
|
61
|
-
* import { sepolia } from "@account-kit/infra";
|
|
52
|
+
* import { sepolia, alchemy } from "@account-kit/infra";
|
|
62
53
|
* import { LocalAccountSigner } from "@aa-sdk/core";
|
|
63
54
|
* import { generatePrivateKey } from "viem"
|
|
64
55
|
*
|
|
65
56
|
* const alchemyAccountClient = await createModularAccountAlchemyClient({
|
|
66
|
-
* apiKey: "your-api-key",
|
|
57
|
+
* transport: alchemy({ apiKey: "your-api-key" }),
|
|
67
58
|
* chain: sepolia,
|
|
68
59
|
* signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey())
|
|
69
60
|
* });
|
|
@@ -75,22 +66,16 @@ export function createModularAccountAlchemyClient<
|
|
|
75
66
|
export async function createModularAccountAlchemyClient(
|
|
76
67
|
config: AlchemyModularAccountClientConfig
|
|
77
68
|
): Promise<AlchemySmartAccountClient> {
|
|
78
|
-
const { chain, opts
|
|
79
|
-
AlchemyProviderConfigSchema.parse(config);
|
|
80
|
-
|
|
81
|
-
const client = createAlchemyPublicRpcClient({
|
|
82
|
-
chain,
|
|
83
|
-
connectionConfig,
|
|
84
|
-
});
|
|
69
|
+
const { transport, chain, opts } = config;
|
|
85
70
|
|
|
86
71
|
const account = await createMultiOwnerModularAccount({
|
|
87
|
-
transport: custom(client),
|
|
88
72
|
...config,
|
|
73
|
+
transport,
|
|
74
|
+
chain,
|
|
89
75
|
});
|
|
90
76
|
|
|
91
|
-
return
|
|
77
|
+
return createAlchemySmartAccountClient({
|
|
92
78
|
...config,
|
|
93
|
-
client,
|
|
94
79
|
account,
|
|
95
80
|
opts,
|
|
96
81
|
})
|
|
@@ -3,9 +3,7 @@ import {
|
|
|
3
3
|
type SmartAccountSigner,
|
|
4
4
|
} from "@aa-sdk/core";
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
createAlchemyPublicRpcClient,
|
|
8
|
-
createAlchemySmartAccountClientFromExisting,
|
|
6
|
+
createAlchemySmartAccountClient,
|
|
9
7
|
type AlchemySmartAccountClient,
|
|
10
8
|
type AlchemySmartAccountClientConfig,
|
|
11
9
|
} from "@account-kit/infra";
|
|
@@ -23,13 +21,7 @@ import {
|
|
|
23
21
|
type MultisigUserOperationContext,
|
|
24
22
|
type PluginManagerActions,
|
|
25
23
|
} from "@account-kit/smart-contracts";
|
|
26
|
-
import {
|
|
27
|
-
custom,
|
|
28
|
-
type Chain,
|
|
29
|
-
type CustomTransport,
|
|
30
|
-
type HttpTransport,
|
|
31
|
-
type Transport,
|
|
32
|
-
} from "viem";
|
|
24
|
+
import { type Chain, type HttpTransport } from "viem";
|
|
33
25
|
|
|
34
26
|
// todo: this file seems somewhat duplicated with ./modularAccountClient.ts, but that file has some multi-owner specific fields. Is there a way to refactor these two to de-dupe?
|
|
35
27
|
|
|
@@ -37,11 +29,10 @@ export type AlchemyMultisigAccountClientConfig<
|
|
|
37
29
|
TSigner extends SmartAccountSigner = SmartAccountSigner
|
|
38
30
|
> = Omit<
|
|
39
31
|
CreateMultisigModularAccountParams<HttpTransport, TSigner>,
|
|
40
|
-
"transport"
|
|
32
|
+
"transport"
|
|
41
33
|
> &
|
|
42
34
|
Omit<
|
|
43
35
|
AlchemySmartAccountClientConfig<
|
|
44
|
-
Transport,
|
|
45
36
|
Chain,
|
|
46
37
|
LightAccount<TSigner>,
|
|
47
38
|
MultisigUserOperationContext
|
|
@@ -55,7 +46,6 @@ export function createMultisigAccountAlchemyClient<
|
|
|
55
46
|
params: AlchemyMultisigAccountClientConfig<TSigner>
|
|
56
47
|
): Promise<
|
|
57
48
|
AlchemySmartAccountClient<
|
|
58
|
-
CustomTransport,
|
|
59
49
|
Chain | undefined,
|
|
60
50
|
MultisigModularAccount<TSigner>,
|
|
61
51
|
MultisigPluginActions<MultisigModularAccount<TSigner>> &
|
|
@@ -76,7 +66,7 @@ export function createMultisigAccountAlchemyClient<
|
|
|
76
66
|
* import { generatePrivateKey } from "viem"
|
|
77
67
|
*
|
|
78
68
|
* const alchemyAccountClient = await createMultisigAccountAlchemyClient({
|
|
79
|
-
* apiKey: "your-api-key",
|
|
69
|
+
* transport: alchemy({ apiKey: "your-api-key" }),
|
|
80
70
|
* chain: sepolia,
|
|
81
71
|
* signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey()),
|
|
82
72
|
* owners: [...], // other owners on the account
|
|
@@ -91,7 +81,6 @@ export async function createMultisigAccountAlchemyClient(
|
|
|
91
81
|
config: AlchemyMultisigAccountClientConfig
|
|
92
82
|
): Promise<
|
|
93
83
|
AlchemySmartAccountClient<
|
|
94
|
-
Transport,
|
|
95
84
|
Chain | undefined,
|
|
96
85
|
MultisigModularAccount<SmartAccountSigner>,
|
|
97
86
|
MultisigPluginActions<MultisigModularAccount<SmartAccountSigner>> &
|
|
@@ -100,26 +89,16 @@ export async function createMultisigAccountAlchemyClient(
|
|
|
100
89
|
MultisigUserOperationContext
|
|
101
90
|
>
|
|
102
91
|
> {
|
|
103
|
-
const {
|
|
104
|
-
AlchemyProviderConfigSchema.parse(config);
|
|
105
|
-
|
|
106
|
-
const client = createAlchemyPublicRpcClient({
|
|
107
|
-
chain,
|
|
108
|
-
connectionConfig,
|
|
109
|
-
});
|
|
92
|
+
const { transport, opts, chain } = config;
|
|
110
93
|
|
|
111
94
|
const account = await createMultisigModularAccount({
|
|
112
|
-
transport: custom(client),
|
|
113
95
|
...config,
|
|
96
|
+
transport,
|
|
97
|
+
chain,
|
|
114
98
|
});
|
|
115
99
|
|
|
116
|
-
return
|
|
117
|
-
Chain | undefined,
|
|
118
|
-
MultisigModularAccount<SmartAccountSigner>,
|
|
119
|
-
MultisigUserOperationContext
|
|
120
|
-
>({
|
|
100
|
+
return createAlchemySmartAccountClient({
|
|
121
101
|
...config,
|
|
122
|
-
client,
|
|
123
102
|
account,
|
|
124
103
|
opts,
|
|
125
104
|
signUserOperation: multisigSignatureMiddleware,
|
|
@@ -134,7 +134,7 @@ export class SessionKeySigner
|
|
|
134
134
|
*/
|
|
135
135
|
signTypedData = async <
|
|
136
136
|
const TTypedData extends TypedData | { [key: string]: unknown },
|
|
137
|
-
TPrimaryType extends
|
|
137
|
+
TPrimaryType extends keyof TTypedData | "EIP712Domain" = keyof TTypedData
|
|
138
138
|
>(
|
|
139
139
|
params: TypedDataDefinition<TTypedData, TPrimaryType>
|
|
140
140
|
) => {
|