Skip to content

Commit

Permalink
chore: attempts to call directly into entrypoint, always reverts
Browse files Browse the repository at this point in the history
  • Loading branch information
linnall committed Feb 26, 2025
1 parent 082111b commit 712de2f
Showing 1 changed file with 98 additions and 18 deletions.
116 changes: 98 additions & 18 deletions account-kit/smart-contracts/src/ma-v2/client/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
erc7677Middleware,
LocalAccountSigner,
type SmartAccountSigner,
type UserOperationRequest_v7,
} from "@aa-sdk/core";
import {
custom,
Expand All @@ -14,6 +15,10 @@ import {
hashMessage,
hashTypedData,
type Address,
encodeFunctionData,
fromHex,
isAddress,
concat,
} from "viem";
import { HookType } from "../actions/common/types.js";
import {
Expand All @@ -39,6 +44,10 @@ import { setBalance } from "viem/actions";
import { accounts } from "~test/constants.js";
import { paymaster070 } from "~test/paymaster/paymaster070.js";
import { alchemy, arbitrumSepolia } from "@account-kit/infra";
import {
packAccountGasLimits,
packPaymasterData,
} from "../../../../../aa-sdk/core/src/entrypoint/0.7.js";

describe("MA v2 Tests", async () => {
const instance = local070Instance;
Expand Down Expand Up @@ -998,42 +1007,113 @@ describe("MA v2 Tests", async () => {

testClient.setAutomine(false);

// force block timestamp to be outside of range
// // force block timestamp to be outside of range
await testClient.setNextBlockTimestamp({
timestamp: 2_200_000_000n,
timestamp: 2_000_000_000n,
});

console.log((await client.getBlock()).timestamp);

await testClient.mine({
blocks: 1,
});
console.log((await client.getBlock()).timestamp);
// send transaction outside of time range
const uoResult = await sessionKeyProvider.sendUserOperation({
// console.log((await client.getBlock()).timestamp);
// // send transaction outside of time range
// const uoResult = await sessionKeyProvider.sendUserOperation({
// uo: {
// target: zeroAddress,
// value: parseEther("0"),
// data: "0x",
// },
// });

// console.log("TRANSACTION LANDED: IT SHOULDN'T");
// // console.log({ uoResult });
// // console.log(await client.getBlock());
// // console.log({ uoResult });
// console.log((await client.getBlock()).timestamp);

// const timeRangeModule = getContract({
// address: getDefaultTimeRangeModuleAddress(provider.chain),
// abi: TimeRangeModule.abi,
// client: provider,
// });

// console.log(
// await timeRangeModule.read.timeRanges([1, provider.account.address])
// );

const uo = await sessionKeyProvider.buildUserOperation({
uo: {
target: zeroAddress,
value: parseEther("0"),
target,
data: "0x",
},
});

console.log("TRANSACTION LANDED: IT SHOULDN'T");
// console.log({ uoResult });
// console.log(await client.getBlock());
// console.log({ uoResult });
console.log((await client.getBlock()).timestamp);

const timeRangeModule = getContract({
address: getDefaultTimeRangeModuleAddress(provider.chain),
abi: TimeRangeModule.abi,
client: provider,
const signedUO = (await sessionKeyProvider.signUserOperation({
uoStruct: uo,
})) as UserOperationRequest_v7;

console.log("SIGNED USER OP");

const epCallData = encodeFunctionData({
abi: AACoreModule.EntryPointAbi_v7,
functionName: "handleOps",
args: [
[
{
...signedUO,
initCode:
signedUO.factory && signedUO.factoryData
? concat([signedUO.factory, signedUO.factoryData])
: "0x",
nonce: fromHex(signedUO.callGasLimit, "bigint"),
preVerificationGas: fromHex(signedUO.preVerificationGas, "bigint"),
accountGasLimits: packAccountGasLimits(
(({ verificationGasLimit, callGasLimit }) => ({
verificationGasLimit,
callGasLimit,
}))(signedUO)
),
gasFees: packAccountGasLimits(
(({ maxPriorityFeePerGas, maxFeePerGas }) => ({
maxPriorityFeePerGas,
maxFeePerGas,
}))(signedUO)
),
paymasterAndData:
signedUO.paymaster && isAddress(signedUO.paymaster)
? packPaymasterData(
(({
paymaster,
paymasterVerificationGasLimit,
paymasterPostOpGasLimit,
paymasterData,
}) => ({
paymaster,
paymasterVerificationGasLimit,
paymasterPostOpGasLimit,
paymasterData,
}))(signedUO)
)
: "0x",
},
],
await sessionKeyProvider.account.getSigner().getAddress(),
],
});

console.log("ENCODED UO");

console.log(
await timeRangeModule.read.timeRanges([1, provider.account.address])
await sessionKeyProvider.sendTransaction({
to: sessionKeyProvider.account.getEntryPoint().address,
data: epCallData,
})
);

console.log("UO LANDED????????");

const hookUninstallData = TimeRangeModule.encodeOnUninstallData({
entityId: 1,
});
Expand Down

0 comments on commit 712de2f

Please sign in to comment.