From 101c00dcc06634e28b43d9db0aa1b21f9d593dd7 Mon Sep 17 00:00:00 2001 From: linna Date: Fri, 13 Dec 2024 15:24:36 -0500 Subject: [PATCH] fix: removes signer from create client function name --- .../src/ma-v2/client/client.test.ts | 136 ++++++++---------- .../src/ma-v2/client/client.ts | 8 +- 2 files changed, 62 insertions(+), 82 deletions(-) diff --git a/account-kit/smart-contracts/src/ma-v2/client/client.test.ts b/account-kit/smart-contracts/src/ma-v2/client/client.test.ts index e26d7e09ff..2f03427dcd 100644 --- a/account-kit/smart-contracts/src/ma-v2/client/client.test.ts +++ b/account-kit/smart-contracts/src/ma-v2/client/client.test.ts @@ -1,77 +1,70 @@ import { - custom, - keccak256, - parseEther, - publicActions, - toHex, - type Address, - } from "viem"; - import { privateKeyToAccount } from "viem/accounts"; - - import { LocalAccountSigner, type SmartAccountSigner } from "@aa-sdk/core"; - - import { - createSMAV2SignerAccountClient, - } from "./client.js"; - - import { local070InstanceOptSep } from "~test/instances.js"; - import { setBalance } from "viem/actions"; - import { accounts } from "~test/constants.js"; - - describe("6900 RI installValidation Tests", async () => { - const instance = local070InstanceOptSep; - const client = instance.getClient().extend(publicActions); + custom, + keccak256, + parseEther, + publicActions, + toHex, + type Address, +} from "viem"; +import { privateKeyToAccount } from "viem/accounts"; - const signer: SmartAccountSigner = new LocalAccountSigner( - accounts.fundedAccountOwner - ); - - it("should send a UO", async () => { - // Generate and add the secondary signer - - const provider = await givenConnectedProvider({ signer }) - - console.log(signer); - console.log("provider: ", provider.getAddress()); +import { LocalAccountSigner, type SmartAccountSigner } from "@aa-sdk/core"; - await setBalance(instance.getClient(), { - address: provider.getAddress(), - value: parseEther("2"), - }); - - const target = "0x000000000000000000000000000000000000dEaD"; +import { createSMAV2AccountClient } from "./client.js"; - const startBalance = await client.getBalance({ - address: target, - }) +import { local070InstanceOptSep } from "~test/instances.js"; +import { setBalance } from "viem/actions"; +import { accounts } from "~test/constants.js"; - const result2 = provider.sendUserOperation({ - uo: { +describe("6900 RI installValidation Tests", async () => { + const instance = local070InstanceOptSep; + const client = instance.getClient().extend(publicActions); + + const signer: SmartAccountSigner = new LocalAccountSigner( + accounts.fundedAccountOwner + ); + + it("should send a UO", async () => { + // Generate and add the secondary signer + + const provider = await givenConnectedProvider({ signer }); + + console.log(signer); + console.log("provider: ", provider.getAddress()); + + await setBalance(instance.getClient(), { + address: provider.getAddress(), + value: parseEther("2"), + }); + + const target = "0x000000000000000000000000000000000000dEaD"; + + const startBalance = await client.getBalance({ + address: target, + }); + + const result2 = provider.sendUserOperation({ + uo: { target: target, value: parseEther("1"), - data: '0x', - }}) - + data: "0x", + }, }); - - it("should fail after uninstalling the secondary signer", async () => { + }); + + it("should fail after uninstalling the secondary signer", async () => { // // Generate and add the secondary signer - // const secondarySigner = new LocalAccountSigner( // privateKeyToAccount(keccak256(toHex("secondarySigner2"))) // ); - // const provider = (await givenConnectedProvider({ signer })).extend( // installValidationActions // ); - // await setBalance(instance.getClient(), { // address: provider.getAddress(), // value: parseEther("2"), // }); - // const entityId = 2; - // const result1 = await provider.installValidation({ // args: { // validationConfig: { @@ -88,13 +81,9 @@ import { // hooks: [], // }, // }); - // const txnHash1 = provider.waitForUserOperationTransaction(result1); - // await expect(txnHash1).resolves.not.toThrowError(); - // // Now the new validation is installed, uninstall it - // const result2 = await provider.uninstallValidation({ // args: { // moduleAddress: SingleSignerValidationModule.meta.addresses.default, @@ -105,15 +94,10 @@ import { // hookUninstallDatas: [], // }, // }); - // const txnHash2 = provider.waitForUserOperationTransaction(result2); - // await expect(txnHash2).resolves.not.toThrowError(); - // // Now the validation is uninstalled, attempt to use it to execute. - // const accountAddress = provider.getAddress(); - // const newValidationAccountClient = await createSingleSignerRIAccountClient({ // chain: instance.chain, // signer: secondarySigner, @@ -121,11 +105,8 @@ import { // entityId, // transport: custom(instance.getClient()), // }); - // // Attempt to execute a transfer of 1 ETH from the account to a dead address. - // const targetAddress = "0x000000000000000000000000000000000000dEaD"; - // const result3 = newValidationAccountClient.sendUserOperation({ // uo: { // target: targetAddress, @@ -133,18 +114,17 @@ import { // data: "0x", // }, // }); - // await expect(result3).rejects.toThrowError(); - }); - - const givenConnectedProvider = async ({ + }); + + const givenConnectedProvider = async ({ + signer, + }: { + signer: SmartAccountSigner; + }) => + createSMAV2AccountClient({ + chain: instance.chain, signer, - }: { - signer: SmartAccountSigner; - }) => - createSMAV2SignerAccountClient({ - chain: instance.chain, - signer, - transport: custom(instance.getClient()), + transport: custom(instance.getClient()), }); - }); \ No newline at end of file +}); diff --git a/account-kit/smart-contracts/src/ma-v2/client/client.ts b/account-kit/smart-contracts/src/ma-v2/client/client.ts index f3d693e55f..28267d920d 100644 --- a/account-kit/smart-contracts/src/ma-v2/client/client.ts +++ b/account-kit/smart-contracts/src/ma-v2/client/client.ts @@ -23,7 +23,7 @@ export type CreateSMAV2AccountClientParams< "transport" | "account" | "chain" >; -export function createSMAV2SignerAccountClient< +export function createSMAV2AccountClient< TChain extends Chain = Chain, TSigner extends SmartAccountSigner = SmartAccountSigner >( @@ -59,15 +59,15 @@ export function createSMAV2SignerAccountClient< * @param {CreateSMAV2AccountClientParams} config The configuration parameters required to create the MAv2 account client * @returns {Promise} A promise that resolves to a `SmartAccountClient` instance */ -export async function createSMAV2SignerAccountClient({ +export async function createSMAV2AccountClient({ ...config }: CreateSMAV2AccountClientParams): Promise { - const maV2SignerAccount = await createSMAV2Account({ + const maV2Account = await createSMAV2Account({ ...config, }); return createSmartAccountClient({ ...config, - account: maV2SignerAccount, + account: maV2Account, }); }