Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions aa-sdk/core/src/errors/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,20 +118,6 @@ export class InvalidModularAccountV2Mode extends BaseError {
}
}

/**
* Error class denoting that the deferred action mode used is invalid.
*/
export class InvalidDeferredActionMode extends BaseError {
override name = "InvalidDeferredActionMode";

/**
* Initializes a new instance of the error message with a default message indicating that the provided deferred action mode is invalid.
*/
constructor() {
super(`The provided deferred action mode is invalid`);
}
}

/**
* Error class denoting that the deferred action nonce used is invalid.
*/
Expand Down
1 change: 0 additions & 1 deletion aa-sdk/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ export {
InvalidNonceKeyError,
EntityIdOverrideError,
InvalidModularAccountV2Mode,
InvalidDeferredActionMode,
InvalidDeferredActionNonce,
} from "./errors/client.js";
export {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import {
InvalidEntityIdError,
InvalidNonceKeyError,
InvalidDeferredActionNonce,
InvalidDeferredActionMode,
toSmartContractAccount,
type AccountOp,
type SmartAccountSigner,
type SmartContractAccountWithSigner,
type ToSmartContractAccountParams,
} from "@aa-sdk/core";
import { DEFAULT_OWNER_ENTITY_ID } from "../../utils.js";
import { DEFAULT_OWNER_ENTITY_ID, parseDeferredAction } from "../../utils.js";
import {
type Hex,
type Address,
Expand Down Expand Up @@ -136,9 +135,9 @@ export async function createMAv2Base<
let hasAssociatedExecHooks: boolean = false;

if (deferredAction) {
if (deferredAction.slice(2, 4) !== "00") {
throw new InvalidDeferredActionMode();
}
({ nonce, deferredActionData, hasAssociatedExecHooks } =
parseDeferredAction(deferredAction));

// Set these values if the deferred action has not been consumed. We check this with the EP
const nextNonceForDeferredAction: bigint =
(await entryPointContract.read.getNonce([
Expand All @@ -148,10 +147,7 @@ export async function createMAv2Base<

// we only add the deferred action in if the nonce has not been consumed
if (nonce === nextNonceForDeferredAction) {
nonce = BigInt(`0x${deferredAction.slice(6, 70)}`);
useDeferredAction = true;
deferredActionData = `0x${deferredAction.slice(70)}`;
hasAssociatedExecHooks = deferredAction[5] === "1";
} else if (nonce > nextNonceForDeferredAction) {
throw new InvalidDeferredActionNonce();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ describe("MA v2 Tests", async () => {

// version 00, preExecHooks 00, nonce, deferredActionDigest
const fullDeferredAction = concatHex([
"0x0000",
"0x00",
toHex(nonce, { size: 32 }),
deferredActionDigest,
]);
Expand Down
4 changes: 2 additions & 2 deletions account-kit/smart-contracts/src/ma-v2/permissionBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,8 @@ export class PermissionBuilder {
).buildPreSignatureDeferredActionDigest({ typedData });

// Encode additional information to build the full pre-signature digest
const fullPreSignatureDeferredActionDigest: `0x${string}` = `0x00${
this.hasAssociatedExecHooks ? "01" : "00"
const fullPreSignatureDeferredActionDigest: `0x${string}` = `0x0${
this.hasAssociatedExecHooks ? "1" : "0"
}${toHex(this.nonce, {
size: 32,
}).slice(2)}${preSignatureDigest.slice(2)}`;
Expand Down
15 changes: 15 additions & 0 deletions account-kit/smart-contracts/src/ma-v2/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,3 +263,18 @@ export const buildFullNonceKey = ({
(isGlobalValidation ? 1n : 0n)
);
};

// Parses out the 3 components from a deferred action
export const parseDeferredAction = (
deferredAction: Hex
): {
nonce: bigint;
deferredActionData: Hex;
hasAssociatedExecHooks: boolean;
} => {
return {
nonce: BigInt(`0x${deferredAction.slice(4, 68)}`),
deferredActionData: `0x${deferredAction.slice(68)}`,
hasAssociatedExecHooks: deferredAction[3] === "1",
};
};

This file was deleted.

Loading