Socket
Socket
Sign inDemoInstall

@alchemy/aa-accounts

Package Overview
Dependencies
17
Maintainers
2
Versions
93
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.11.0 to 3.11.1

8

dist/cjs/plugindefs/multisig/abi.d.ts

@@ -40,3 +40,3 @@ export declare const MultisigPluginAbi: readonly [{

readonly outputs: readonly [{
readonly name: "failed";
readonly name: "success";
readonly type: "bool";

@@ -722,3 +722,3 @@ readonly internalType: "bool";

readonly type: "error";
readonly name: "InvalidGasValues";
readonly name: "InvalidAddress";
readonly inputs: readonly [];

@@ -735,2 +735,6 @@ }, {

readonly type: "error";
readonly name: "InvalidNumSigsOnActualGas";
readonly inputs: readonly [];
}, {
readonly type: "error";
readonly name: "InvalidOwner";

@@ -737,0 +741,0 @@ readonly inputs: readonly [{

@@ -56,3 +56,3 @@ "use strict";

{
name: "failed",
name: "success",
type: "bool",

@@ -939,3 +939,3 @@ internalType: "bool",

type: "error",
name: "InvalidGasValues",
name: "InvalidAddress",
inputs: [],

@@ -955,2 +955,7 @@ },

type: "error",
name: "InvalidNumSigsOnActualGas",
inputs: [],
},
{
type: "error",
name: "InvalidOwner",

@@ -957,0 +962,0 @@ inputs: [

@@ -91,4 +91,4 @@ export declare const MultisigModularAccountFactoryAbi: readonly [{

readonly name: "threshold";
readonly type: "uint256";
readonly internalType: "uint256";
readonly type: "uint128";
readonly internalType: "uint128";
}];

@@ -95,0 +95,0 @@ readonly outputs: readonly [{

@@ -120,4 +120,4 @@ "use strict";

name: "threshold",
type: "uint256",
internalType: "uint256",
type: "uint128",
internalType: "uint128",
},

@@ -124,0 +124,0 @@ ],

import { type Address, type EntryPointParameter, type SmartAccountSigner, type SmartContractAccount, type SmartContractAccountWithSigner, type ToSmartContractAccountParams } from "@alchemy/aa-core";
import { type Chain, type Hex, type Transport } from "viem";
export declare const MULTISIG_ACCOUNT_SOURCE = "MultisigModularAccount";
export type MultisigModularAccount<TSigner extends SmartAccountSigner = SmartAccountSigner> = SmartContractAccountWithSigner<typeof MULTISIG_ACCOUNT_SOURCE, TSigner> & {
export type MultisigModularAccount<TSigner extends SmartAccountSigner = SmartAccountSigner> = SmartContractAccountWithSigner<typeof MULTISIG_ACCOUNT_SOURCE, TSigner, "0.6.0"> & {
getLocalThreshold: () => bigint;

@@ -6,0 +6,0 @@ };

@@ -30,23 +30,16 @@ "use strict";

account,
context: {
userOpSignatureType: "UPPERLIMIT",
},
});
const signerType = await (0, index_js_1.getSignerType)({
client,
signature: request.signature,
signer: account.getSigner(),
const splitSignatures = await (0, index_js_1.splitAggregatedSignature)({
request,
aggregatedSignature: request.signature,
account,
threshold: 2,
});
const signatureObj = {
signature: request.signature,
signer: await account.getSigner().getAddress(),
signerType,
userOpSigType: "UPPERLIMIT",
};
return {
request,
signatureObj,
aggregatedSignature: (0, index_js_1.combineSignatures)({
signatures: [signatureObj],
upperLimitMaxFeePerGas: request.maxFeePerGas,
upperLimitMaxPriorityFeePerGas: request.maxPriorityFeePerGas,
upperLimitPvg: request.preVerificationGas,
}),
signatureObj: splitSignatures.signatures[0],
aggregatedSignature: request.signature,
};

@@ -53,0 +46,0 @@ }

@@ -21,26 +21,32 @@ "use strict";

}
const ep = account.getEntryPoint();
const uoHash = ep.getUserOperationHash(userOperationRequest);
const signature = await account.signUserOperationHash(uoHash);
const signerAddress = await account.getSigner().getAddress();
const signerType = await (0, index_js_1.getSignerType)({
client,
signature,
signer: account.getSigner(),
const signedRequest = await client.signUserOperation({
account,
uoStruct: userOperationRequest,
context: {
aggregatedSignature: (0, index_js_1.combineSignatures)({
signatures,
upperLimitMaxFeePerGas: userOperationRequest.maxFeePerGas,
upperLimitMaxPriorityFeePerGas: userOperationRequest.maxPriorityFeePerGas,
upperLimitPvg: userOperationRequest.preVerificationGas,
usingMaxValues: false,
}),
signatures,
userOpSignatureType: "UPPERLIMIT",
},
});
const signatureObj = {
signerType,
signer: signerAddress,
signature,
userOpSigType: "UPPERLIMIT",
};
const splitSignatures = await (0, index_js_1.splitAggregatedSignature)({
account,
request: signedRequest,
aggregatedSignature: signedRequest.signature,
threshold: signatures.length + 2,
});
const signatureObj = splitSignatures.signatures.find((x) => x.signer === signerAddress);
if (!signatureObj) {
throw new Error("INTERNAL ERROR: signature not found in split signatures, this is an internal bug please report");
}
return {
signatureObj,
signature,
aggregatedSignature: (0, index_js_1.combineSignatures)({
signatures: [...signatures, signatureObj],
upperLimitMaxFeePerGas: userOperationRequest.maxFeePerGas,
upperLimitMaxPriorityFeePerGas: userOperationRequest.maxPriorityFeePerGas,
upperLimitPvg: userOperationRequest.preVerificationGas,
}),
signature: signatureObj.signature,
aggregatedSignature: signedRequest.signature,
};

@@ -47,0 +53,0 @@ }

@@ -1,2 +0,2 @@

import { type GetAccountParameter, type IsUndefined, type SendUserOperationParameters, type SmartContractAccount } from "@alchemy/aa-core";
import { type GetAccountParameter, type GetEntryPointFromAccount, type IsUndefined, type SendUserOperationParameters, type SmartContractAccount } from "@alchemy/aa-core";
import { type Address, type Chain, type Client, type Transport } from "viem";

@@ -12,3 +12,3 @@ import type { GetPluginAddressParameter } from "../types.js";

getThreshold: (params: GetPluginAddressParameter & GetAccountParameter<TAccount>) => Promise<bigint>;
proposeUserOperation: (params: SendUserOperationParameters<TAccount, undefined>) => Promise<ProposeUserOperationResult<TAccount>>;
proposeUserOperation: (params: SendUserOperationParameters<TAccount, undefined>) => Promise<ProposeUserOperationResult<TAccount, GetEntryPointFromAccount<TAccount>>>;
signMultisigUserOperation: (params: SignMultisigUserOperationParams<TAccount>) => Promise<SignMultisigUserOperationResult>;

@@ -15,0 +15,0 @@ } & (IsUndefined<TAccount> extends false ? {

import { type ClientMiddlewareFn } from "@alchemy/aa-core";
import { type Hex } from "viem";
export declare const multisigSignatureMiddleware: ClientMiddlewareFn<{
signature: Hex;
}>;
import { type MultisigUserOperationContext } from "./index.js";
export declare const multisigSignatureMiddleware: ClientMiddlewareFn<MultisigUserOperationContext>;

@@ -5,8 +5,12 @@ "use strict";

const aa_core_1 = require("@alchemy/aa-core");
const viem_1 = require("viem");
const multisigAccount_js_1 = require("../../account/multisigAccount.js");
const errors_js_1 = require("../../errors.js");
const getThreshold_js_1 = require("./actions/getThreshold.js");
const index_js_1 = require("./index.js");
const multisigSignatureMiddleware = async (struct, { account, client, context }) => {
if (!context ||
(context.userOpSignatureType === "ACTUAL" &&
!context.signatures &&
!context.aggregatedSignature)) {
throw new errors_js_1.InvalidContextSignatureError();
}
if (!(0, aa_core_1.isSmartAccountWithSigner)(account)) {

@@ -29,15 +33,29 @@ throw new aa_core_1.SmartAccountWithSignerRequiredError();

});
const threshold = await (0, getThreshold_js_1.getThreshold)(client, { account });
if (context?.signature == null) {
if (context.userOpSignatureType === "UPPERLIMIT" &&
context?.signatures?.length == null &&
context?.aggregatedSignature == null) {
return {
...resolvedStruct,
signature: await account.getDummySignature(),
signature: (0, index_js_1.combineSignatures)({
signatures: [
{
signature,
signer: await account.getSigner().getAddress(),
signerType,
userOpSigType: context.userOpSignatureType,
},
],
upperLimitMaxFeePerGas: request.maxFeePerGas,
upperLimitMaxPriorityFeePerGas: request.maxPriorityFeePerGas,
upperLimitPvg: request.preVerificationGas,
usingMaxValues: false,
}),
};
}
if (!(0, viem_1.isHex)(context.signature)) {
if (context.aggregatedSignature == null || context.signatures == null) {
throw new errors_js_1.InvalidContextSignatureError();
}
const { upperLimitPvg, upperLimitMaxFeePerGas, upperLimitMaxPriorityFeePerGas, signatures, } = await (0, index_js_1.splitAggregatedSignature)({
aggregatedSignature: context.signature,
threshold: Number(threshold),
const { upperLimitPvg, upperLimitMaxFeePerGas, upperLimitMaxPriorityFeePerGas, } = await (0, index_js_1.splitAggregatedSignature)({
aggregatedSignature: context.aggregatedSignature,
threshold: context.signatures.length + 1,
account,

@@ -47,4 +65,4 @@ request,

const finalSignature = (0, index_js_1.combineSignatures)({
signatures: signatures.concat({
userOpSigType: "ACTUAL",
signatures: context.signatures.concat({
userOpSigType: context.userOpSignatureType,
signerType,

@@ -57,2 +75,7 @@ signature,

upperLimitMaxPriorityFeePerGas,
usingMaxValues: isUsingMaxValues(request, {
upperLimitPvg,
upperLimitMaxFeePerGas,
upperLimitMaxPriorityFeePerGas,
}),
});

@@ -65,2 +88,15 @@ return {

exports.multisigSignatureMiddleware = multisigSignatureMiddleware;
const isUsingMaxValues = (request, upperLimits) => {
if (BigInt(request.preVerificationGas) !== BigInt(upperLimits.upperLimitPvg)) {
return false;
}
if (BigInt(request.maxFeePerGas) !== BigInt(upperLimits.upperLimitMaxFeePerGas)) {
return false;
}
if (BigInt(request.maxPriorityFeePerGas) !==
BigInt(upperLimits.upperLimitMaxPriorityFeePerGas)) {
return false;
}
return true;
};
//# sourceMappingURL=middleware.js.map

@@ -142,3 +142,3 @@ import { encodeAbiParameters, type Address, type Transport, type Client, type EncodeFunctionDataParameters, type Chain, type Hex, type ReadContractReturnType } from 'viem';

readonly outputs: readonly [{
readonly name: "failed";
readonly name: "success";
readonly internalType: "bool";

@@ -824,3 +824,3 @@ readonly type: "bool";

readonly inputs: readonly [];
readonly name: "InvalidGasValues";
readonly name: "InvalidAddress";
}, {

@@ -836,2 +836,6 @@ readonly type: "error";

readonly type: "error";
readonly inputs: readonly [];
readonly name: "InvalidNumSigsOnActualGas";
}, {
readonly type: "error";
readonly inputs: readonly [{

@@ -838,0 +842,0 @@ readonly name: "owner";

@@ -191,3 +191,3 @@ "use strict";

outputs: [
{ name: 'failed', internalType: 'bool', type: 'bool' },
{ name: 'success', internalType: 'bool', type: 'bool' },
{ name: 'firstFailure', internalType: 'uint256', type: 'uint256' },

@@ -708,5 +708,6 @@ ],

{ type: 'error', inputs: [], name: 'InvalidAction' },
{ type: 'error', inputs: [], name: 'InvalidGasValues' },
{ type: 'error', inputs: [], name: 'InvalidAddress' },
{ type: 'error', inputs: [], name: 'InvalidMaxFeePerGas' },
{ type: 'error', inputs: [], name: 'InvalidMaxPriorityFeePerGas' },
{ type: 'error', inputs: [], name: 'InvalidNumSigsOnActualGas' },
{

@@ -713,0 +714,0 @@ type: 'error',

@@ -27,3 +27,9 @@ import type { GetAccountParameter, GetEntryPointFromAccount, SmartContractAccount, UserOperationRequest } from "@alchemy/aa-core";

export type MultisigUserOperationContext = {
signature: Hex;
userOpSignatureType: Extract<UserOpSignatureType, "UPPERLIMIT">;
aggregatedSignature?: Hex;
signatures?: Signature[];
} | {
aggregatedSignature: Hex;
signatures: Signature[];
userOpSignatureType: Extract<UserOpSignatureType, "ACTUAL">;
};
import { type Hex } from "viem";
import type { Signature } from "../types.js";
export declare const combineSignatures: ({ signatures, upperLimitMaxFeePerGas, upperLimitMaxPriorityFeePerGas, upperLimitPvg, }: {
export declare const combineSignatures: ({ signatures, upperLimitMaxFeePerGas, upperLimitMaxPriorityFeePerGas, upperLimitPvg, usingMaxValues, }: {
upperLimitPvg: Hex;

@@ -8,2 +8,3 @@ upperLimitMaxFeePerGas: Hex;

signatures: Signature[];
usingMaxValues: boolean;
}) => `0x${string}`;

@@ -6,3 +6,3 @@ "use strict";

const formatSignatures_js_1 = require("./formatSignatures.js");
const combineSignatures = ({ signatures, upperLimitMaxFeePerGas, upperLimitMaxPriorityFeePerGas, upperLimitPvg, }) => {
const combineSignatures = ({ signatures, upperLimitMaxFeePerGas, upperLimitMaxPriorityFeePerGas, upperLimitPvg, usingMaxValues, }) => {
return (0, viem_1.concat)([

@@ -12,3 +12,3 @@ (0, viem_1.pad)(upperLimitPvg),

(0, viem_1.pad)(upperLimitMaxPriorityFeePerGas),
(0, formatSignatures_js_1.formatSignatures)(signatures),
(0, formatSignatures_js_1.formatSignatures)(signatures, usingMaxValues),
]);

@@ -15,0 +15,0 @@ };

import type { Signature } from "../types";
export declare const formatSignatures: (signatures: Signature[]) => `0x${string}`;
export declare const formatSignatures: (signatures: Signature[], usingMaxValues?: boolean) => `0x${string}`;

@@ -6,3 +6,3 @@ "use strict";

const viem_1 = require("viem");
const formatSignatures = (signatures) => {
const formatSignatures = (signatures, usingMaxValues = false) => {
let eoaSigs = "";

@@ -18,3 +18,3 @@ let contractSigs = "";

.forEach((sig) => {
const addV = sig.userOpSigType === "ACTUAL" ? 32 : 0;
const addV = sig.userOpSigType === "ACTUAL" && !usingMaxValues ? 32 : 0;
if (sig.signerType === "EOA") {

@@ -21,0 +21,0 @@ let v = parseInt((0, aa_core_1.takeBytes)(sig.signature, { count: 1, offset: 64 })) + addV;

@@ -40,3 +40,3 @@ export declare const MultisigPluginAbi: readonly [{

readonly outputs: readonly [{
readonly name: "failed";
readonly name: "success";
readonly type: "bool";

@@ -722,3 +722,3 @@ readonly internalType: "bool";

readonly type: "error";
readonly name: "InvalidGasValues";
readonly name: "InvalidAddress";
readonly inputs: readonly [];

@@ -735,2 +735,6 @@ }, {

readonly type: "error";
readonly name: "InvalidNumSigsOnActualGas";
readonly inputs: readonly [];
}, {
readonly type: "error";
readonly name: "InvalidOwner";

@@ -737,0 +741,0 @@ readonly inputs: readonly [{

@@ -53,3 +53,3 @@ export const MultisigPluginAbi = [

{
name: "failed",
name: "success",
type: "bool",

@@ -936,3 +936,3 @@ internalType: "bool",

type: "error",
name: "InvalidGasValues",
name: "InvalidAddress",
inputs: [],

@@ -952,2 +952,7 @@ },

type: "error",
name: "InvalidNumSigsOnActualGas",
inputs: [],
},
{
type: "error",
name: "InvalidOwner",

@@ -954,0 +959,0 @@ inputs: [

@@ -91,4 +91,4 @@ export declare const MultisigModularAccountFactoryAbi: readonly [{

readonly name: "threshold";
readonly type: "uint256";
readonly internalType: "uint256";
readonly type: "uint128";
readonly internalType: "uint128";
}];

@@ -95,0 +95,0 @@ readonly outputs: readonly [{

@@ -117,4 +117,4 @@ export const MultisigModularAccountFactoryAbi = [

name: "threshold",
type: "uint256",
internalType: "uint256",
type: "uint128",
internalType: "uint128",
},

@@ -121,0 +121,0 @@ ],

import { type Address, type EntryPointParameter, type SmartAccountSigner, type SmartContractAccount, type SmartContractAccountWithSigner, type ToSmartContractAccountParams } from "@alchemy/aa-core";
import { type Chain, type Hex, type Transport } from "viem";
export declare const MULTISIG_ACCOUNT_SOURCE = "MultisigModularAccount";
export type MultisigModularAccount<TSigner extends SmartAccountSigner = SmartAccountSigner> = SmartContractAccountWithSigner<typeof MULTISIG_ACCOUNT_SOURCE, TSigner> & {
export type MultisigModularAccount<TSigner extends SmartAccountSigner = SmartAccountSigner> = SmartContractAccountWithSigner<typeof MULTISIG_ACCOUNT_SOURCE, TSigner, "0.6.0"> & {
getLocalThreshold: () => bigint;

@@ -6,0 +6,0 @@ };

import { AccountNotFoundError, IncompatibleClientError, isSmartAccountClient, isSmartAccountWithSigner, SmartAccountWithSignerRequiredError, } from "@alchemy/aa-core";
import {} from "viem";
import { combineSignatures, getSignerType } from "../index.js";
import { splitAggregatedSignature } from "../index.js";
import {} from "../types.js";

@@ -29,25 +29,18 @@ export async function proposeUserOperation(client, { uo, account = client.account, overrides: overrides_, }) {

account,
context: {
userOpSignatureType: "UPPERLIMIT",
},
});
const signerType = await getSignerType({
client,
signature: request.signature,
signer: account.getSigner(),
const splitSignatures = await splitAggregatedSignature({
request,
aggregatedSignature: request.signature,
account,
threshold: 2,
});
const signatureObj = {
signature: request.signature,
signer: await account.getSigner().getAddress(),
signerType,
userOpSigType: "UPPERLIMIT",
};
return {
request,
signatureObj,
aggregatedSignature: combineSignatures({
signatures: [signatureObj],
upperLimitMaxFeePerGas: request.maxFeePerGas,
upperLimitMaxPriorityFeePerGas: request.maxPriorityFeePerGas,
upperLimitPvg: request.preVerificationGas,
}),
signatureObj: splitSignatures.signatures[0],
aggregatedSignature: request.signature,
};
}
//# sourceMappingURL=proposeUserOperation.js.map
import { AccountNotFoundError, IncompatibleClientError, SmartAccountWithSignerRequiredError, isSmartAccountClient, isSmartAccountWithSigner, } from "@alchemy/aa-core";
import {} from "viem";
import { MultisigMissingSignatureError } from "../../../errors.js";
import { combineSignatures, getSignerType } from "../index.js";
import { combineSignatures, splitAggregatedSignature } from "../index.js";
import {} from "../types.js";

@@ -20,28 +20,34 @@ export async function signMultisigUserOperation(client, params) {

}
const ep = account.getEntryPoint();
const uoHash = ep.getUserOperationHash(userOperationRequest);
const signature = await account.signUserOperationHash(uoHash);
const signerAddress = await account.getSigner().getAddress();
const signerType = await getSignerType({
client,
signature,
signer: account.getSigner(),
const signedRequest = await client.signUserOperation({
account,
uoStruct: userOperationRequest,
context: {
aggregatedSignature: combineSignatures({
signatures,
upperLimitMaxFeePerGas: userOperationRequest.maxFeePerGas,
upperLimitMaxPriorityFeePerGas: userOperationRequest.maxPriorityFeePerGas,
upperLimitPvg: userOperationRequest.preVerificationGas,
usingMaxValues: false,
}),
signatures,
userOpSignatureType: "UPPERLIMIT",
},
});
const signatureObj = {
signerType,
signer: signerAddress,
signature,
userOpSigType: "UPPERLIMIT",
};
const splitSignatures = await splitAggregatedSignature({
account,
request: signedRequest,
aggregatedSignature: signedRequest.signature,
threshold: signatures.length + 2,
});
const signatureObj = splitSignatures.signatures.find((x) => x.signer === signerAddress);
if (!signatureObj) {
throw new Error("INTERNAL ERROR: signature not found in split signatures, this is an internal bug please report");
}
return {
signatureObj,
signature,
aggregatedSignature: combineSignatures({
signatures: [...signatures, signatureObj],
upperLimitMaxFeePerGas: userOperationRequest.maxFeePerGas,
upperLimitMaxPriorityFeePerGas: userOperationRequest.maxPriorityFeePerGas,
upperLimitPvg: userOperationRequest.preVerificationGas,
}),
signature: signatureObj.signature,
aggregatedSignature: signedRequest.signature,
};
}
//# sourceMappingURL=signMultisigUserOperation.js.map

@@ -1,2 +0,2 @@

import { type GetAccountParameter, type IsUndefined, type SendUserOperationParameters, type SmartContractAccount } from "@alchemy/aa-core";
import { type GetAccountParameter, type GetEntryPointFromAccount, type IsUndefined, type SendUserOperationParameters, type SmartContractAccount } from "@alchemy/aa-core";
import { type Address, type Chain, type Client, type Transport } from "viem";

@@ -12,3 +12,3 @@ import type { GetPluginAddressParameter } from "../types.js";

getThreshold: (params: GetPluginAddressParameter & GetAccountParameter<TAccount>) => Promise<bigint>;
proposeUserOperation: (params: SendUserOperationParameters<TAccount, undefined>) => Promise<ProposeUserOperationResult<TAccount>>;
proposeUserOperation: (params: SendUserOperationParameters<TAccount, undefined>) => Promise<ProposeUserOperationResult<TAccount, GetEntryPointFromAccount<TAccount>>>;
signMultisigUserOperation: (params: SignMultisigUserOperationParams<TAccount>) => Promise<SignMultisigUserOperationResult>;

@@ -15,0 +15,0 @@ } & (IsUndefined<TAccount> extends false ? {

import { type ClientMiddlewareFn } from "@alchemy/aa-core";
import { type Hex } from "viem";
export declare const multisigSignatureMiddleware: ClientMiddlewareFn<{
signature: Hex;
}>;
import { type MultisigUserOperationContext } from "./index.js";
export declare const multisigSignatureMiddleware: ClientMiddlewareFn<MultisigUserOperationContext>;
import { InvalidUserOperationError, SmartAccountWithSignerRequiredError, deepHexlify, isSmartAccountWithSigner, isValidRequest, resolveProperties, } from "@alchemy/aa-core";
import { isHex } from "viem";
import {} from "viem";
import { isMultisigModularAccount } from "../../account/multisigAccount.js";
import { InvalidContextSignatureError, MultisigAccountExpectedError, } from "../../errors.js";
import { getThreshold } from "./actions/getThreshold.js";
import { combineSignatures, getSignerType, splitAggregatedSignature, } from "./index.js";
export const multisigSignatureMiddleware = async (struct, { account, client, context }) => {
if (!context ||
(context.userOpSignatureType === "ACTUAL" &&
!context.signatures &&
!context.aggregatedSignature)) {
throw new InvalidContextSignatureError();
}
if (!isSmartAccountWithSigner(account)) {

@@ -25,15 +30,29 @@ throw new SmartAccountWithSignerRequiredError();

});
const threshold = await getThreshold(client, { account });
if (context?.signature == null) {
if (context.userOpSignatureType === "UPPERLIMIT" &&
context?.signatures?.length == null &&
context?.aggregatedSignature == null) {
return {
...resolvedStruct,
signature: await account.getDummySignature(),
signature: combineSignatures({
signatures: [
{
signature,
signer: await account.getSigner().getAddress(),
signerType,
userOpSigType: context.userOpSignatureType,
},
],
upperLimitMaxFeePerGas: request.maxFeePerGas,
upperLimitMaxPriorityFeePerGas: request.maxPriorityFeePerGas,
upperLimitPvg: request.preVerificationGas,
usingMaxValues: false,
}),
};
}
if (!isHex(context.signature)) {
if (context.aggregatedSignature == null || context.signatures == null) {
throw new InvalidContextSignatureError();
}
const { upperLimitPvg, upperLimitMaxFeePerGas, upperLimitMaxPriorityFeePerGas, signatures, } = await splitAggregatedSignature({
aggregatedSignature: context.signature,
threshold: Number(threshold),
const { upperLimitPvg, upperLimitMaxFeePerGas, upperLimitMaxPriorityFeePerGas, } = await splitAggregatedSignature({
aggregatedSignature: context.aggregatedSignature,
threshold: context.signatures.length + 1,
account,

@@ -43,4 +62,4 @@ request,

const finalSignature = combineSignatures({
signatures: signatures.concat({
userOpSigType: "ACTUAL",
signatures: context.signatures.concat({
userOpSigType: context.userOpSignatureType,
signerType,

@@ -53,2 +72,7 @@ signature,

upperLimitMaxPriorityFeePerGas,
usingMaxValues: isUsingMaxValues(request, {
upperLimitPvg,
upperLimitMaxFeePerGas,
upperLimitMaxPriorityFeePerGas,
}),
});

@@ -60,2 +84,15 @@ return {

};
const isUsingMaxValues = (request, upperLimits) => {
if (BigInt(request.preVerificationGas) !== BigInt(upperLimits.upperLimitPvg)) {
return false;
}
if (BigInt(request.maxFeePerGas) !== BigInt(upperLimits.upperLimitMaxFeePerGas)) {
return false;
}
if (BigInt(request.maxPriorityFeePerGas) !==
BigInt(upperLimits.upperLimitMaxPriorityFeePerGas)) {
return false;
}
return true;
};
//# sourceMappingURL=middleware.js.map

@@ -142,3 +142,3 @@ import { encodeAbiParameters, type Address, type Transport, type Client, type EncodeFunctionDataParameters, type Chain, type Hex, type ReadContractReturnType } from 'viem';

readonly outputs: readonly [{
readonly name: "failed";
readonly name: "success";
readonly internalType: "bool";

@@ -824,3 +824,3 @@ readonly type: "bool";

readonly inputs: readonly [];
readonly name: "InvalidGasValues";
readonly name: "InvalidAddress";
}, {

@@ -836,2 +836,6 @@ readonly type: "error";

readonly type: "error";
readonly inputs: readonly [];
readonly name: "InvalidNumSigsOnActualGas";
}, {
readonly type: "error";
readonly inputs: readonly [{

@@ -838,0 +842,0 @@ readonly name: "owner";

@@ -189,3 +189,3 @@ import { getContract, encodeAbiParameters, encodeFunctionData, } from 'viem';

outputs: [
{ name: 'failed', internalType: 'bool', type: 'bool' },
{ name: 'success', internalType: 'bool', type: 'bool' },
{ name: 'firstFailure', internalType: 'uint256', type: 'uint256' },

@@ -706,5 +706,6 @@ ],

{ type: 'error', inputs: [], name: 'InvalidAction' },
{ type: 'error', inputs: [], name: 'InvalidGasValues' },
{ type: 'error', inputs: [], name: 'InvalidAddress' },
{ type: 'error', inputs: [], name: 'InvalidMaxFeePerGas' },
{ type: 'error', inputs: [], name: 'InvalidMaxPriorityFeePerGas' },
{ type: 'error', inputs: [], name: 'InvalidNumSigsOnActualGas' },
{

@@ -711,0 +712,0 @@ type: 'error',

@@ -27,3 +27,9 @@ import type { GetAccountParameter, GetEntryPointFromAccount, SmartContractAccount, UserOperationRequest } from "@alchemy/aa-core";

export type MultisigUserOperationContext = {
signature: Hex;
userOpSignatureType: Extract<UserOpSignatureType, "UPPERLIMIT">;
aggregatedSignature?: Hex;
signatures?: Signature[];
} | {
aggregatedSignature: Hex;
signatures: Signature[];
userOpSignatureType: Extract<UserOpSignatureType, "ACTUAL">;
};
import { type Hex } from "viem";
import type { Signature } from "../types.js";
export declare const combineSignatures: ({ signatures, upperLimitMaxFeePerGas, upperLimitMaxPriorityFeePerGas, upperLimitPvg, }: {
export declare const combineSignatures: ({ signatures, upperLimitMaxFeePerGas, upperLimitMaxPriorityFeePerGas, upperLimitPvg, usingMaxValues, }: {
upperLimitPvg: Hex;

@@ -8,2 +8,3 @@ upperLimitMaxFeePerGas: Hex;

signatures: Signature[];
usingMaxValues: boolean;
}) => `0x${string}`;
import { concat, pad } from "viem";
import { formatSignatures } from "./formatSignatures.js";
export const combineSignatures = ({ signatures, upperLimitMaxFeePerGas, upperLimitMaxPriorityFeePerGas, upperLimitPvg, }) => {
export const combineSignatures = ({ signatures, upperLimitMaxFeePerGas, upperLimitMaxPriorityFeePerGas, upperLimitPvg, usingMaxValues, }) => {
return concat([

@@ -8,5 +8,5 @@ pad(upperLimitPvg),

pad(upperLimitMaxPriorityFeePerGas),
formatSignatures(signatures),
formatSignatures(signatures, usingMaxValues),
]);
};
//# sourceMappingURL=combineSignatures.js.map
import type { Signature } from "../types";
export declare const formatSignatures: (signatures: Signature[]) => `0x${string}`;
export declare const formatSignatures: (signatures: Signature[], usingMaxValues?: boolean) => `0x${string}`;
import { takeBytes } from "@alchemy/aa-core";
import { hexToBigInt, concat, toHex, pad } from "viem";
export const formatSignatures = (signatures) => {
import { concat, hexToBigInt, pad, toHex } from "viem";
export const formatSignatures = (signatures, usingMaxValues = false) => {
let eoaSigs = "";

@@ -14,3 +14,3 @@ let contractSigs = "";

.forEach((sig) => {
const addV = sig.userOpSigType === "ACTUAL" ? 32 : 0;
const addV = sig.userOpSigType === "ACTUAL" && !usingMaxValues ? 32 : 0;
if (sig.signerType === "EOA") {

@@ -17,0 +17,0 @@ let v = parseInt(takeBytes(sig.signature, { count: 1, offset: 64 })) + addV;

@@ -40,3 +40,3 @@ export declare const MultisigPluginAbi: readonly [{

readonly outputs: readonly [{
readonly name: "failed";
readonly name: "success";
readonly type: "bool";

@@ -722,3 +722,3 @@ readonly internalType: "bool";

readonly type: "error";
readonly name: "InvalidGasValues";
readonly name: "InvalidAddress";
readonly inputs: readonly [];

@@ -735,2 +735,6 @@ }, {

readonly type: "error";
readonly name: "InvalidNumSigsOnActualGas";
readonly inputs: readonly [];
}, {
readonly type: "error";
readonly name: "InvalidOwner";

@@ -737,0 +741,0 @@ readonly inputs: readonly [{

@@ -91,4 +91,4 @@ export declare const MultisigModularAccountFactoryAbi: readonly [{

readonly name: "threshold";
readonly type: "uint256";
readonly internalType: "uint256";
readonly type: "uint128";
readonly internalType: "uint128";
}];

@@ -95,0 +95,0 @@ readonly outputs: readonly [{

import { type Address, type EntryPointParameter, type SmartAccountSigner, type SmartContractAccount, type SmartContractAccountWithSigner, type ToSmartContractAccountParams } from "@alchemy/aa-core";
import { type Chain, type Hex, type Transport } from "viem";
export declare const MULTISIG_ACCOUNT_SOURCE = "MultisigModularAccount";
export type MultisigModularAccount<TSigner extends SmartAccountSigner = SmartAccountSigner> = SmartContractAccountWithSigner<typeof MULTISIG_ACCOUNT_SOURCE, TSigner> & {
export type MultisigModularAccount<TSigner extends SmartAccountSigner = SmartAccountSigner> = SmartContractAccountWithSigner<typeof MULTISIG_ACCOUNT_SOURCE, TSigner, "0.6.0"> & {
getLocalThreshold: () => bigint;

@@ -6,0 +6,0 @@ };

@@ -1,2 +0,2 @@

import { type GetAccountParameter, type IsUndefined, type SendUserOperationParameters, type SmartContractAccount } from "@alchemy/aa-core";
import { type GetAccountParameter, type GetEntryPointFromAccount, type IsUndefined, type SendUserOperationParameters, type SmartContractAccount } from "@alchemy/aa-core";
import { type Address, type Chain, type Client, type Transport } from "viem";

@@ -12,3 +12,3 @@ import type { GetPluginAddressParameter } from "../types.js";

getThreshold: (params: GetPluginAddressParameter & GetAccountParameter<TAccount>) => Promise<bigint>;
proposeUserOperation: (params: SendUserOperationParameters<TAccount, undefined>) => Promise<ProposeUserOperationResult<TAccount>>;
proposeUserOperation: (params: SendUserOperationParameters<TAccount, undefined>) => Promise<ProposeUserOperationResult<TAccount, GetEntryPointFromAccount<TAccount>>>;
signMultisigUserOperation: (params: SignMultisigUserOperationParams<TAccount>) => Promise<SignMultisigUserOperationResult>;

@@ -15,0 +15,0 @@ } & (IsUndefined<TAccount> extends false ? {

import { type ClientMiddlewareFn } from "@alchemy/aa-core";
import { type Hex } from "viem";
export declare const multisigSignatureMiddleware: ClientMiddlewareFn<{
signature: Hex;
}>;
import { type MultisigUserOperationContext } from "./index.js";
/**
* A signer middleware to be used with Multisig Account Clients.
* This middleware handles correctly aggregating signatures passed through
* as context when sending UserOperations, proposing UserOperations, or adding signatures to a UserOperation.
*
* @param struct the user operation struct to be signed
* @param param the parameters to be passed to the middleware
* @param param.account the account to be used for signing
* @param param.client the smart account client that will be used for RPC requests
* @param param.context the context object containing the signatures to be aggregated {@link MultisigUserOperationContext}
* @returns a Promise containing a UserOperation with an aggregated signature in the `signature` field
*/
export declare const multisigSignatureMiddleware: ClientMiddlewareFn<MultisigUserOperationContext>;
//# sourceMappingURL=middleware.d.ts.map

@@ -142,3 +142,3 @@ import { encodeAbiParameters, type Address, type Transport, type Client, type EncodeFunctionDataParameters, type Chain, type Hex, type ReadContractReturnType } from 'viem';

readonly outputs: readonly [{
readonly name: "failed";
readonly name: "success";
readonly internalType: "bool";

@@ -824,3 +824,3 @@ readonly type: "bool";

readonly inputs: readonly [];
readonly name: "InvalidGasValues";
readonly name: "InvalidAddress";
}, {

@@ -836,2 +836,6 @@ readonly type: "error";

readonly type: "error";
readonly inputs: readonly [];
readonly name: "InvalidNumSigsOnActualGas";
}, {
readonly type: "error";
readonly inputs: readonly [{

@@ -838,0 +842,0 @@ readonly name: "owner";

@@ -27,4 +27,10 @@ import type { GetAccountParameter, GetEntryPointFromAccount, SmartContractAccount, UserOperationRequest } from "@alchemy/aa-core";

export type MultisigUserOperationContext = {
signature: Hex;
userOpSignatureType: Extract<UserOpSignatureType, "UPPERLIMIT">;
aggregatedSignature?: Hex;
signatures?: Signature[];
} | {
aggregatedSignature: Hex;
signatures: Signature[];
userOpSignatureType: Extract<UserOpSignatureType, "ACTUAL">;
};
//# sourceMappingURL=types.d.ts.map
import { type Hex } from "viem";
import type { Signature } from "../types.js";
export declare const combineSignatures: ({ signatures, upperLimitMaxFeePerGas, upperLimitMaxPriorityFeePerGas, upperLimitPvg, }: {
export declare const combineSignatures: ({ signatures, upperLimitMaxFeePerGas, upperLimitMaxPriorityFeePerGas, upperLimitPvg, usingMaxValues, }: {
upperLimitPvg: Hex;

@@ -8,3 +8,4 @@ upperLimitMaxFeePerGas: Hex;

signatures: Signature[];
usingMaxValues: boolean;
}) => `0x${string}`;
//# sourceMappingURL=combineSignatures.d.ts.map
import type { Signature } from "../types";
export declare const formatSignatures: (signatures: Signature[]) => `0x${string}`;
/**
* Formats a collection of Signature objects into a single aggregated signature.
* The format is in the form of EOA_SIGS | CONTRACT_SIG_DATAS. The signatures are ordered
* by signer address. The EOA SIGS contain the 65 signautre data for EOA signers and 65 bytes containing SIGNER | OFFSET | V for contract signers.
* The OFFSET is used to fetch the signature data from the CONTRACT_SIG_DATAS.
*
* @param signatures the array of {@link Signature} objects to combine into the correct aggregated signature format excluding the upper limits
* @param usingMaxValues a boolean indicating wether or not the UserOperation is using the UPPER_LIMIT for the gas and fee values
* @returns the Hex representation of the signature
*/
export declare const formatSignatures: (signatures: Signature[], usingMaxValues?: boolean) => `0x${string}`;
//# sourceMappingURL=formatSignatures.d.ts.map
{
"name": "@alchemy/aa-accounts",
"version": "3.11.0",
"version": "3.11.1",
"description": "A collection of ERC-4337 compliant smart contract account interfaces",

@@ -75,5 +75,5 @@ "author": "Alchemy",

"homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
"gitHead": "fd8fbfb70453e6e16e6566f334dafcb22371cba7",
"gitHead": "7f8e7f9283497f9e5b47dde02c7d5bad42c7335e",
"dependencies": {
"@alchemy/aa-core": "^3.11.0",
"@alchemy/aa-core": "^3.11.1",
"viem": "2.8.6"

@@ -80,0 +80,0 @@ },

@@ -53,3 +53,3 @@ export const MultisigPluginAbi = [

{
name: "failed",
name: "success",
type: "bool",

@@ -936,3 +936,3 @@ internalType: "bool",

type: "error",
name: "InvalidGasValues",
name: "InvalidAddress",
inputs: [],

@@ -952,2 +952,7 @@ },

type: "error",
name: "InvalidNumSigsOnActualGas",
inputs: [],
},
{
type: "error",
name: "InvalidOwner",

@@ -954,0 +959,0 @@ inputs: [

@@ -117,4 +117,4 @@ export const MultisigModularAccountFactoryAbi = [

name: "threshold",
type: "uint256",
internalType: "uint256",
type: "uint128",
internalType: "uint128",
},

@@ -121,0 +121,0 @@ ],

@@ -30,3 +30,7 @@ import {

TSigner extends SmartAccountSigner = SmartAccountSigner
> = SmartContractAccountWithSigner<typeof MULTISIG_ACCOUNT_SOURCE, TSigner> & {
> = SmartContractAccountWithSigner<
typeof MULTISIG_ACCOUNT_SOURCE,
TSigner,
"0.6.0"
> & {
getLocalThreshold: () => bigint;

@@ -33,0 +37,0 @@ };

@@ -13,4 +13,4 @@ import {

import { type Chain, type Client, type Transport } from "viem";
import { combineSignatures, getSignerType } from "../index.js";
import { type ProposeUserOperationResult, type Signature } from "../types.js";
import { splitAggregatedSignature } from "../index.js";
import { type ProposeUserOperationResult } from "../types.js";

@@ -65,27 +65,20 @@ export async function proposeUserOperation<

account,
context: {
userOpSignatureType: "UPPERLIMIT",
},
});
const signerType = await getSignerType({
client,
signature: request.signature,
signer: account.getSigner(),
const splitSignatures = await splitAggregatedSignature({
request,
aggregatedSignature: request.signature,
account,
// split works on the assumption that we have t - 1 signatures
threshold: 2,
});
const signatureObj: Signature = {
signature: request.signature,
signer: await account.getSigner().getAddress(),
signerType,
userOpSigType: "UPPERLIMIT",
};
return {
request,
signatureObj,
aggregatedSignature: combineSignatures({
signatures: [signatureObj],
upperLimitMaxFeePerGas: request.maxFeePerGas,
upperLimitMaxPriorityFeePerGas: request.maxPriorityFeePerGas,
upperLimitPvg: request.preVerificationGas,
}),
signatureObj: splitSignatures.signatures[0],
aggregatedSignature: request.signature,
};
}

@@ -11,7 +11,6 @@ import {

import { MultisigMissingSignatureError } from "../../../errors.js";
import { combineSignatures, getSignerType } from "../index.js";
import { combineSignatures, splitAggregatedSignature } from "../index.js";
import {
type SignMultisigUserOperationParams,
type SignMultisigUserOperationResult,
type Signature,
} from "../types.js";

@@ -51,29 +50,46 @@

const ep = account.getEntryPoint();
const uoHash = ep.getUserOperationHash(userOperationRequest);
const signature = await account.signUserOperationHash(uoHash);
const signerAddress = await account.getSigner().getAddress();
const signerType = await getSignerType({
client,
signature,
signer: account.getSigner(),
const signedRequest = await client.signUserOperation({
account,
uoStruct: userOperationRequest,
context: {
aggregatedSignature: combineSignatures({
signatures,
upperLimitMaxFeePerGas: userOperationRequest.maxFeePerGas,
upperLimitMaxPriorityFeePerGas:
userOperationRequest.maxPriorityFeePerGas,
upperLimitPvg: userOperationRequest.preVerificationGas,
usingMaxValues: false,
}),
signatures,
userOpSignatureType: "UPPERLIMIT",
},
});
const signatureObj: Signature = {
signerType,
signer: signerAddress,
signature,
userOpSigType: "UPPERLIMIT",
};
const splitSignatures = await splitAggregatedSignature({
account,
request: signedRequest,
aggregatedSignature: signedRequest.signature,
// split works on the assumption that we have t - 1 signatures
// we have signatures.length + 1 signatures now, so we need sl + 1 + 1
threshold: signatures.length + 2,
});
const signatureObj = splitSignatures.signatures.find(
(x) => x.signer === signerAddress
);
if (!signatureObj) {
// TODO: strongly type this
throw new Error(
"INTERNAL ERROR: signature not found in split signatures, this is an internal bug please report"
);
}
return {
signatureObj,
signature,
aggregatedSignature: combineSignatures({
signatures: [...signatures, signatureObj],
upperLimitMaxFeePerGas: userOperationRequest.maxFeePerGas,
upperLimitMaxPriorityFeePerGas: userOperationRequest.maxPriorityFeePerGas,
upperLimitPvg: userOperationRequest.preVerificationGas,
}),
signature: signatureObj.signature,
aggregatedSignature: signedRequest.signature,
};
}
import {
type GetAccountParameter,
type GetEntryPointFromAccount,
type IsUndefined,

@@ -45,3 +46,5 @@ type SendUserOperationParameters,

params: SendUserOperationParameters<TAccount, undefined>
) => Promise<ProposeUserOperationResult<TAccount>>;
) => Promise<
ProposeUserOperationResult<TAccount, GetEntryPointFromAccount<TAccount>>
>;

@@ -48,0 +51,0 @@ signMultisigUserOperation: (

@@ -9,4 +9,6 @@ import {

type ClientMiddlewareFn,
type UserOperationRequest_v6,
type UserOperationRequest_v7,
} from "@alchemy/aa-core";
import { isHex, type Hex } from "viem";
import { type Hex } from "viem";
import { isMultisigModularAccount } from "../../account/multisigAccount.js";

@@ -17,3 +19,2 @@ import {

} from "../../errors.js";
import { getThreshold } from "./actions/getThreshold.js";
import {

@@ -23,7 +24,30 @@ combineSignatures,

splitAggregatedSignature,
type MultisigUserOperationContext,
} from "./index.js";
export const multisigSignatureMiddleware: ClientMiddlewareFn<{
signature: Hex;
}> = async (struct, { account, client, context }) => {
/**
* A signer middleware to be used with Multisig Account Clients.
* This middleware handles correctly aggregating signatures passed through
* as context when sending UserOperations, proposing UserOperations, or adding signatures to a UserOperation.
*
* @param struct the user operation struct to be signed
* @param param the parameters to be passed to the middleware
* @param param.account the account to be used for signing
* @param param.client the smart account client that will be used for RPC requests
* @param param.context the context object containing the signatures to be aggregated {@link MultisigUserOperationContext}
* @returns a Promise containing a UserOperation with an aggregated signature in the `signature` field
*/
export const multisigSignatureMiddleware: ClientMiddlewareFn<
MultisigUserOperationContext
> = async (struct, { account, client, context }) => {
// if the signature is not present, this has to be UPPERLIMIT because it's likely a propose operation
if (
!context ||
(context.userOpSignatureType === "ACTUAL" &&
!context.signatures &&
!context.aggregatedSignature)
) {
throw new InvalidContextSignatureError();
}
if (!isSmartAccountWithSigner(account)) {

@@ -38,2 +62,3 @@ throw new SmartAccountWithSignerRequiredError();

const resolvedStruct = await resolveProperties(struct);
const request = deepHexlify(resolvedStruct);

@@ -54,17 +79,32 @@ if (!isValidRequest(request)) {

// TODO: this needs to actually check the account's installed plugins and fetch the multisig plugin address
const threshold = await getThreshold(client, { account });
// if there is no override, then return the dummy signature
if (context?.signature == null) {
// then this is a propose operation
if (
context.userOpSignatureType === "UPPERLIMIT" &&
context?.signatures?.length == null &&
context?.aggregatedSignature == null
) {
return {
...resolvedStruct,
signature: await account.getDummySignature(),
signature: combineSignatures({
signatures: [
{
signature,
signer: await account.getSigner().getAddress(),
signerType,
userOpSigType: context.userOpSignatureType,
},
],
upperLimitMaxFeePerGas: request.maxFeePerGas,
upperLimitMaxPriorityFeePerGas: request.maxPriorityFeePerGas,
upperLimitPvg: request.preVerificationGas,
usingMaxValues: false,
}),
};
}
if (!isHex(context.signature)) {
if (context.aggregatedSignature == null || context.signatures == null) {
throw new InvalidContextSignatureError();
}
// otherwise this is a sign operation
const {

@@ -74,6 +114,5 @@ upperLimitPvg,

upperLimitMaxPriorityFeePerGas,
signatures,
} = await splitAggregatedSignature({
aggregatedSignature: context.signature,
threshold: Number(threshold),
aggregatedSignature: context.aggregatedSignature,
threshold: context.signatures.length + 1,
account,

@@ -84,4 +123,4 @@ request,

const finalSignature = combineSignatures({
signatures: signatures.concat({
userOpSigType: "ACTUAL",
signatures: context.signatures.concat({
userOpSigType: context.userOpSignatureType,
signerType,

@@ -94,2 +133,7 @@ signature,

upperLimitMaxPriorityFeePerGas,
usingMaxValues: isUsingMaxValues(request, {
upperLimitPvg,
upperLimitMaxFeePerGas,
upperLimitMaxPriorityFeePerGas,
}),
});

@@ -102,1 +146,31 @@

};
const isUsingMaxValues = (
request: UserOperationRequest_v6 | UserOperationRequest_v7,
upperLimits: {
upperLimitPvg: Hex;
upperLimitMaxFeePerGas: Hex;
upperLimitMaxPriorityFeePerGas: Hex;
}
): boolean => {
if (
BigInt(request.preVerificationGas) !== BigInt(upperLimits.upperLimitPvg)
) {
return false;
}
if (
BigInt(request.maxFeePerGas) !== BigInt(upperLimits.upperLimitMaxFeePerGas)
) {
return false;
}
if (
BigInt(request.maxPriorityFeePerGas) !==
BigInt(upperLimits.upperLimitMaxPriorityFeePerGas)
) {
return false;
}
return true;
};

@@ -395,3 +395,3 @@ import {

outputs: [
{ name: "failed", internalType: "bool", type: "bool" },
{ name: "success", internalType: "bool", type: "bool" },
{ name: "firstFailure", internalType: "uint256", type: "uint256" },

@@ -912,5 +912,6 @@ ],

{ type: "error", inputs: [], name: "InvalidAction" },
{ type: "error", inputs: [], name: "InvalidGasValues" },
{ type: "error", inputs: [], name: "InvalidAddress" },
{ type: "error", inputs: [], name: "InvalidMaxFeePerGas" },
{ type: "error", inputs: [], name: "InvalidMaxPriorityFeePerGas" },
{ type: "error", inputs: [], name: "InvalidNumSigsOnActualGas" },
{

@@ -917,0 +918,0 @@ type: "error",

@@ -49,4 +49,12 @@ import type {

export type MultisigUserOperationContext = {
signature: Hex;
};
export type MultisigUserOperationContext =
| {
userOpSignatureType: Extract<UserOpSignatureType, "UPPERLIMIT">;
aggregatedSignature?: Hex;
signatures?: Signature[];
}
| {
aggregatedSignature: Hex;
signatures: Signature[];
userOpSignatureType: Extract<UserOpSignatureType, "ACTUAL">;
};
import { type Hex, concat, pad } from "viem";
import type { Signature } from "../types.js";
import { formatSignatures } from "./formatSignatures.js";
import type { Signature } from "../types.js";

@@ -10,2 +10,3 @@ export const combineSignatures = ({

upperLimitPvg,
usingMaxValues,
}: {

@@ -16,2 +17,3 @@ upperLimitPvg: Hex;

signatures: Signature[];
usingMaxValues: boolean;
}) => {

@@ -22,4 +24,4 @@ return concat([

pad(upperLimitMaxPriorityFeePerGas),
formatSignatures(signatures),
formatSignatures(signatures, usingMaxValues),
]);
};
import { takeBytes } from "@alchemy/aa-core";
import { hexToBigInt, concat, toHex, pad } from "viem";
import { concat, hexToBigInt, pad, toHex } from "viem";
import type { Signature } from "../types";
export const formatSignatures = (signatures: Signature[]) => {
/**
* Formats a collection of Signature objects into a single aggregated signature.
* The format is in the form of EOA_SIGS | CONTRACT_SIG_DATAS. The signatures are ordered
* by signer address. The EOA SIGS contain the 65 signautre data for EOA signers and 65 bytes containing SIGNER | OFFSET | V for contract signers.
* The OFFSET is used to fetch the signature data from the CONTRACT_SIG_DATAS.
*
* @param signatures the array of {@link Signature} objects to combine into the correct aggregated signature format excluding the upper limits
* @param usingMaxValues a boolean indicating wether or not the UserOperation is using the UPPER_LIMIT for the gas and fee values
* @returns the Hex representation of the signature
*/
export const formatSignatures = (
signatures: Signature[],
usingMaxValues: boolean = false
) => {
let eoaSigs: string = "";

@@ -18,3 +31,3 @@ let contractSigs: string = "";

// add 32 to v if the signature covers the actual gas values
const addV = sig.userOpSigType === "ACTUAL" ? 32 : 0;
const addV = sig.userOpSigType === "ACTUAL" && !usingMaxValues ? 32 : 0;

@@ -21,0 +34,0 @@ if (sig.signerType === "EOA") {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc