Skip to content

Commit

Permalink
fix: removes signer from create client function name
Browse files Browse the repository at this point in the history
  • Loading branch information
linnall authored and howydev committed Dec 13, 2024
1 parent 54fb3da commit d9aa83d
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 82 deletions.
136 changes: 58 additions & 78 deletions account-kit/smart-contracts/src/ma-v2/client/client.test.ts
Original file line number Diff line number Diff line change
@@ -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,

Check warning on line 3 in account-kit/smart-contracts/src/ma-v2/client/client.test.ts

View workflow job for this annotation

GitHub Actions / Lint

'keccak256' is defined but never used
parseEther,
publicActions,
toHex,

Check warning on line 6 in account-kit/smart-contracts/src/ma-v2/client/client.test.ts

View workflow job for this annotation

GitHub Actions / Lint

'toHex' is defined but never used
type Address,

Check warning on line 7 in account-kit/smart-contracts/src/ma-v2/client/client.test.ts

View workflow job for this annotation

GitHub Actions / Lint

'Address' is defined but never used
} from "viem";
import { privateKeyToAccount } from "viem/accounts";

Check warning on line 9 in account-kit/smart-contracts/src/ma-v2/client/client.test.ts

View workflow job for this annotation

GitHub Actions / Lint

'privateKeyToAccount' is defined but never used

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);

Check failure on line 21 in account-kit/smart-contracts/src/ma-v2/client/client.test.ts

View workflow job for this annotation

GitHub Actions / Build and Test

src/ma-v2/client/client.test.ts

TypeError: Cannot read properties of undefined (reading 'getClient') ❯ src/ma-v2/client/client.test.ts:21:27

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({

Check warning on line 42 in account-kit/smart-contracts/src/ma-v2/client/client.test.ts

View workflow job for this annotation

GitHub Actions / Lint

'startBalance' is assigned a value but never used
address: target,
});

const result2 = provider.sendUserOperation({

Check warning on line 46 in account-kit/smart-contracts/src/ma-v2/client/client.test.ts

View workflow job for this annotation

GitHub Actions / Lint

'result2' is assigned a value but never used
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: {
Expand All @@ -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,
Expand All @@ -105,46 +94,37 @@ 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,
// accountAddress,
// 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,
// value: parseEther("0.5"),
// 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()),
});
});
});
8 changes: 4 additions & 4 deletions account-kit/smart-contracts/src/ma-v2/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export type CreateSMAV2AccountClientParams<
"transport" | "account" | "chain"
>;

export function createSMAV2SignerAccountClient<
export function createSMAV2AccountClient<
TChain extends Chain = Chain,
TSigner extends SmartAccountSigner = SmartAccountSigner
>(
Expand Down Expand Up @@ -59,15 +59,15 @@ export function createSMAV2SignerAccountClient<
* @param {CreateSMAV2AccountClientParams} config The configuration parameters required to create the MAv2 account client
* @returns {Promise<SmartAccountClient>} A promise that resolves to a `SmartAccountClient` instance
*/
export async function createSMAV2SignerAccountClient({
export async function createSMAV2AccountClient({
...config
}: CreateSMAV2AccountClientParams): Promise<SmartAccountClient> {
const maV2SignerAccount = await createSMAV2Account({
const maV2Account = await createSMAV2Account({
...config,
});

return createSmartAccountClient({
...config,
account: maV2SignerAccount,
account: maV2Account,
});
}

0 comments on commit d9aa83d

Please sign in to comment.