Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
howydev committed Dec 18, 2024
1 parent 0e4ee07 commit ceff675
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
35 changes: 24 additions & 11 deletions account-kit/smart-contracts/src/ma-v2/account/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,19 @@ export async function createSMAV2Account(
});

const getExecutionData = async (args: ExecutionDataParams) => {
if (!(await baseAccount.isAccountDeployed())) {
return {} as ExecutionDataView;
}

const { selector } = args;
return await accountContract.read.getExecutionData([selector]);
};

const getValidationData = async (args: ValidationDataParams) => {
if (!(await baseAccount.isAccountDeployed())) {
return {} as ValidationDataView;
}

const { validationModuleAddress, entityId } = args;
return await accountContract.read.getValidationData([
serializeModuleEntity({
Expand All @@ -209,23 +217,28 @@ export async function createSMAV2Account(
entityId: Number(entityId),
});

return validationData.executionHooks.length
? concatHex([executeUserOpSelector, callData])
: callData;
const numHooks = validationData?.executionHooks?.length ?? 0;

return numHooks ? concatHex([executeUserOpSelector, callData]) : callData;
};

const encodeExecute: (tx: AccountOp) => Promise<Hex> = async ({
target,
data,
value,
}) =>
encodeCallData(
encodeFunctionData({
abi: modularAccountAbi,
functionName: "execute",
args: [target, value ?? 0n, data],
})
);
}) => {
let callData = encodeFunctionData({
abi: modularAccountAbi,
functionName: "execute",
args: [target, value ?? 0n, data],
});

callData = (await baseAccount.isAccountDeployed())
? await encodeCallData(callData)
: callData;

return callData;
};

const encodeBatchExecute: (txs: AccountOp[]) => Promise<Hex> = async (txs) =>
encodeCallData(
Expand Down
4 changes: 2 additions & 2 deletions account-kit/smart-contracts/src/ma-v2/client/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe("MA v2 Tests", async () => {
const target = "0x000000000000000000000000000000000000dEaD";
const sendAmount = parseEther("1");

const getTargetBalance = async (): Promise<number> => {
const getTargetBalance = async (): Promise<bigint> => {
return client.getBalance({
address: target,
});
Expand Down Expand Up @@ -99,7 +99,7 @@ describe("MA v2 Tests", async () => {
signer: sessionKey,
transport: custom(instance.getClient()),
accountAddress: provider.getAddress(),
entityId: 1n,
entityId: 1,
isGlobalValidation: true,
});

Expand Down

0 comments on commit ceff675

Please sign in to comment.