Socket
Socket
Sign inDemoInstall

@biconomy/account

Package Overview
Dependencies
34
Maintainers
7
Versions
23
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.2.0 to 4.3.0

dist/_cjs/account/abi/ECDSAModule.js

57

dist/_cjs/account/BiconomySmartAccountV2.js

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

feeTokenAddress: feeQuote.tokenAddress,
calculateGasLimits: true
calculateGasLimits: paymasterServiceData.calculateGasLimits ?? true
});

@@ -725,2 +725,15 @@ }

}
async transferOwnership(newOwner, moduleAddress, buildUseropDto) {
const encodedCall = (0, viem_1.encodeFunctionData)({
abi: (0, viem_1.parseAbi)(["function transferOwnership(address newOwner) public"]),
functionName: "transferOwnership",
args: [newOwner]
});
const transaction = {
to: moduleAddress,
data: encodedCall
};
const userOpResponse = await this.sendTransaction(transaction, buildUseropDto);
return userOpResponse;
}
async sendTransaction(manyOrOneTransactions, buildUseropDto) {

@@ -772,2 +785,24 @@ const userOp = await this.buildUserOp(Array.isArray(manyOrOneTransactions)

userOp.maxPriorityFeePerGas = gasFeeValues?.maxPriorityFeePerGas;
if (buildUseropDto.gasOffset) {
userOp = await this.estimateUserOpGas(userOp);
const { verificationGasLimitOffsetPct, preVerificationGasOffsetPct, callGasLimitOffsetPct, maxFeePerGasOffsetPct, maxPriorityFeePerGasOffsetPct } = buildUseropDto.gasOffset;
userOp.verificationGasLimit = (0, viem_1.toHex)(Number.parseInt((Number(userOp.verificationGasLimit ?? 0) *
(0, Utils_js_1.convertToFactor)(verificationGasLimitOffsetPct)).toString()));
userOp.preVerificationGas = (0, viem_1.toHex)(Number.parseInt((Number(userOp.preVerificationGas ?? 0) *
(0, Utils_js_1.convertToFactor)(preVerificationGasOffsetPct)).toString()));
userOp.callGasLimit = (0, viem_1.toHex)(Number.parseInt((Number(userOp.callGasLimit ?? 0) *
(0, Utils_js_1.convertToFactor)(callGasLimitOffsetPct)).toString()));
userOp.maxFeePerGas = (0, viem_1.toHex)(Number.parseInt((Number(userOp.maxFeePerGas ?? 0) *
(0, Utils_js_1.convertToFactor)(maxFeePerGasOffsetPct)).toString()));
userOp.maxPriorityFeePerGas = (0, viem_1.toHex)(Number.parseInt((Number(userOp.maxPriorityFeePerGas ?? 0) *
(0, Utils_js_1.convertToFactor)(maxPriorityFeePerGasOffsetPct)).toString()));
userOp = await this.getPaymasterUserOp(userOp, {
...buildUseropDto.paymasterServiceData,
calculateGasLimits: false
});
return userOp;
}
if (buildUseropDto.paymasterServiceData.calculateGasLimits === false) {
userOp = await this.estimateUserOpGas(userOp);
}
userOp = await this.getPaymasterUserOp(userOp, buildUseropDto.paymasterServiceData);

@@ -777,2 +812,22 @@ return userOp;

userOp = await this.estimateUserOpGas(userOp);
if (buildUseropDto?.gasOffset) {
if (buildUseropDto?.paymasterServiceData) {
userOp = await this.getPaymasterUserOp(userOp, {
...buildUseropDto.paymasterServiceData,
calculateGasLimits: false
});
}
const { verificationGasLimitOffsetPct, preVerificationGasOffsetPct, callGasLimitOffsetPct, maxFeePerGasOffsetPct, maxPriorityFeePerGasOffsetPct } = buildUseropDto.gasOffset;
userOp.verificationGasLimit = (0, viem_1.toHex)(Number.parseInt((Number(userOp.verificationGasLimit ?? 0) *
(0, Utils_js_1.convertToFactor)(verificationGasLimitOffsetPct)).toString()));
userOp.preVerificationGas = (0, viem_1.toHex)(Number.parseInt((Number(userOp.preVerificationGas ?? 0) *
(0, Utils_js_1.convertToFactor)(preVerificationGasOffsetPct)).toString()));
userOp.callGasLimit = (0, viem_1.toHex)(Number.parseInt((Number(userOp.callGasLimit ?? 0) *
(0, Utils_js_1.convertToFactor)(callGasLimitOffsetPct)).toString()));
userOp.maxFeePerGas = (0, viem_1.toHex)(Number.parseInt((Number(userOp.maxFeePerGas ?? 0) *
(0, Utils_js_1.convertToFactor)(maxFeePerGasOffsetPct)).toString()));
userOp.maxPriorityFeePerGas = (0, viem_1.toHex)(Number.parseInt((Number(userOp.maxPriorityFeePerGas ?? 0) *
(0, Utils_js_1.convertToFactor)(maxPriorityFeePerGasOffsetPct)).toString()));
return userOp;
}
if (buildUseropDto?.paymasterServiceData) {

@@ -779,0 +834,0 @@ userOp = await this.getPaymasterUserOp(userOp, buildUseropDto.paymasterServiceData);

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.wrapSignatureWith6492 = exports.addressEquals = exports.isValidRpcUrl = exports.compareChainIds = exports.isNullOrUndefined = exports.packUserOp = void 0;
exports.convertToFactor = exports.percentage = exports.wrapSignatureWith6492 = exports.addressEquals = exports.isValidRpcUrl = exports.compareChainIds = exports.isNullOrUndefined = exports.packUserOp = void 0;
const viem_1 = require("viem");

@@ -91,2 +91,17 @@ const account_1 = require("../../account/index.js");

exports.wrapSignatureWith6492 = wrapSignatureWith6492;
function percentage(partialValue, totalValue) {
return (100 * partialValue) / totalValue;
}
exports.percentage = percentage;
function convertToFactor(percentage) {
if (percentage) {
if (percentage < 1 || percentage > 100) {
throw new Error("The percentage value should be between 1 and 100.");
}
const factor = percentage / 100 + 1;
return factor;
}
return 1;
}
exports.convertToFactor = convertToFactor;
//# sourceMappingURL=Utils.js.map

6

dist/_cjs/paymaster/BiconomyPaymaster.js

@@ -238,5 +238,5 @@ "use strict";

const paymasterAndData = response.result.paymasterAndData;
const preVerificationGas = response.result.preVerificationGas;
const verificationGasLimit = response.result.verificationGasLimit;
const callGasLimit = response.result.callGasLimit;
const preVerificationGas = response.result.preVerificationGas ?? _userOp.preVerificationGas;
const verificationGasLimit = response.result.verificationGasLimit ?? _userOp.verificationGasLimit;
const callGasLimit = response.result.callGasLimit ?? _userOp.callGasLimit;
return {

@@ -243,0 +243,0 @@ paymasterAndData: paymasterAndData,

@@ -99,2 +99,17 @@ import { concat, encodeAbiParameters, keccak256, parseAbiParameters } from "viem";

};
export function percentage(partialValue, totalValue) {
return (100 * partialValue) / totalValue;
}
export function convertToFactor(percentage) {
// Check if the input is within the valid range
if (percentage) {
if (percentage < 1 || percentage > 100) {
throw new Error("The percentage value should be between 1 and 100.");
}
// Calculate the factor
const factor = percentage / 100 + 1;
return factor;
}
return 1;
}
//# sourceMappingURL=Utils.js.map

@@ -288,5 +288,5 @@ import { encodeFunctionData, parseAbi } from "viem";

const paymasterAndData = response.result.paymasterAndData;
const preVerificationGas = response.result.preVerificationGas;
const verificationGasLimit = response.result.verificationGasLimit;
const callGasLimit = response.result.callGasLimit;
const preVerificationGas = response.result.preVerificationGas ?? _userOp.preVerificationGas;
const verificationGasLimit = response.result.verificationGasLimit ?? _userOp.verificationGasLimit;
const callGasLimit = response.result.callGasLimit ?? _userOp.callGasLimit;
return {

@@ -293,0 +293,0 @@ paymasterAndData: paymasterAndData,

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

import { type GetContractReturnType, type Hex, type PublicClient } from "viem";
import { type Address, type GetContractReturnType, type Hex, type PublicClient } from "viem";
import type { IBundler } from "../bundler/IBundler.js";

@@ -9,3 +9,3 @@ import { type UserOpResponse } from "../bundler/index.js";

import { BiconomyAccountAbi } from "./abi/SmartAccount.js";
import type { BalancePayload, BatchUserOperationCallData, BiconomySmartAccountV2Config, BiconomySmartAccountV2ConfigConstructorProps, BiconomyTokenPaymasterRequest, BuildUserOpOptions, CounterFactualAddressParam, PaymasterUserOperationDto, QueryParamsForAddressResolver, SimulationType, SupportedToken, Transaction, WithdrawalRequest } from "./utils/Types.js";
import type { BalancePayload, BatchUserOperationCallData, BiconomySmartAccountV2Config, BiconomySmartAccountV2ConfigConstructorProps, BiconomyTokenPaymasterRequest, BuildUserOpOptions, CounterFactualAddressParam, PaymasterUserOperationDto, QueryParamsForAddressResolver, SimulationType, SupportedToken, Transaction, TransferOwnershipCompatibleModule, WithdrawalRequest } from "./utils/Types.js";
type UserOperationKey = keyof UserOperationStruct;

@@ -381,2 +381,43 @@ export declare class BiconomySmartAccountV2 extends BaseSmartContractAccount {

/**
* Transfers ownership of the smart account to a new owner.
* @param newOwner The address of the new owner.
* @param moduleAddress {@link TransferOwnershipCompatibleModule} The address of the validation module (ECDSA Ownership Module or Multichain Validation Module).
* @param buildUseropDto {@link BuildUserOpOptions}. Optional parameter
* @returns A Promise that resolves to a UserOpResponse or rejects with an Error.
* @description This function will transfer ownership of the smart account to a new owner. If you use session key manager module, after transferring the ownership
* you will need to re-create a session for the smart account with the new owner (signer) and specify "accountAddress" in "createSmartAccountClient" function.
* @example
* ```typescript
*
* let walletClient = createWalletClient({
account,
chain: baseSepolia,
transport: http()
});
let smartAccount = await createSmartAccountClient({
signer: walletClient,
paymasterUrl: "https://paymaster.biconomy.io/api/v1/...",
bundlerUrl: `https://bundler.biconomy.io/api/v2/84532/nJPK7B3ru.dd7f7861-190d-41bd-af80-6877f74b8f44`,
chainId: 84532
});
const response = await smartAccount.transferOwnership(newOwner, DEFAULT_ECDSA_OWNERSHIP_MODULE, {paymasterServiceData: {mode: PaymasterMode.SPONSORED}});
walletClient = createWalletClient({
newOwnerAccount,
chain: baseSepolia,
transport: http()
})
smartAccount = await createSmartAccountClient({
signer: walletClient,
paymasterUrl: "https://paymaster.biconomy.io/api/v1/...",
bundlerUrl: `https://bundler.biconomy.io/api/v2/84532/nJPK7B3ru.dd7f7861-190d-41bd-af80-6877f74b8f44`,
chainId: 84532,
accountAddress: await smartAccount.getAccountAddress()
})
* ```
*/
transferOwnership(newOwner: Address, moduleAddress: TransferOwnershipCompatibleModule, buildUseropDto?: BuildUserOpOptions): Promise<UserOpResponse>;
/**
* Sends a transaction (builds and sends a user op in sequence)

@@ -417,2 +458,36 @@ *

*
* @remarks
* This example shows how to increase the estimated gas values for a transaction using `gasOffset` parameter.
* @example
* import { createClient } from "viem"
* import { createSmartAccountClient } from "@biconomy/account"
* import { createWalletClient, http } from "viem";
* import { polygonAmoy } from "viem/chains";
*
* const signer = createWalletClient({
* account,
* chain: polygonAmoy,
* transport: http(),
* });
*
* const smartAccount = await createSmartAccountClient({ signer, bundlerUrl }); // Retrieve bundler url from dashboard
* const encodedCall = encodeFunctionData({
* abi: parseAbi(["function safeMint(address to) public"]),
* functionName: "safeMint",
* args: ["0x..."],
* });
*
* const transaction = {
* to: nftAddress,
* data: encodedCall
* }
*
* const { waitForTxHash } = await smartAccount.sendTransaction(transaction, {
* gasOffset: {
* verificationGasLimitOffsetPct: 25, // 25% increase for the already estimated gas limit
* preVerificationGasOffsetPct: 10 // 10% increase for the already estimated gas limit
* }
* });
* const { transactionHash, userOperationReceipt } = await wait();
*
*/

@@ -419,0 +494,0 @@ sendTransaction(manyOrOneTransactions: Transaction | Transaction[], buildUseropDto?: BuildUserOpOptions): Promise<UserOpResponse>;

@@ -130,20 +130,23 @@ import type { Address, Chain, Hash, Hex, PrivateKeyAccount, PublicClient, SignTypedDataParameters, SignableMessage, TypedData, TypedDataDefinition, WalletClient } from "viem";

export type BiconomySmartAccountV2ConfigConstructorProps = BiconomySmartAccountV2ConfigBaseProps & BaseSmartAccountConfig & ResolvedBundlerProps & ResolvedValidationProps;
/**
* Represents options for building a user operation.
* @typedef BuildUserOpOptions
* @property {GasOffset} [gasOffset] - Increment gas values by giving an offset, the given value will be an increment to the current estimated gas values, not an override.
* @property {ModuleInfo} [params] - Parameters relevant to the module, mostly relevant to sessions.
* @property {NonceOptions} [nonceOptions] - Options for overriding the nonce.
* @property {boolean} [forceEncodeForBatch] - Whether to encode the user operation for batch.
* @property {PaymasterUserOperationDto} [paymasterServiceData] - Options specific to transactions that involve a paymaster.
* @property {SimulationType} [simulationType] - Determine which parts of the transaction a bundler will simulate: "validation" | "validation_and_execution".
* @property {StateOverrideSet} [stateOverrideSet] - For overriding the state.
* @property {boolean} [useEmptyDeployCallData] - Set to true if the transaction is being used only to deploy the smart contract, so "0x" is set as the user operation call data.
*/
export type BuildUserOpOptions = {
/** overrides: Explicitly set gas values */
/** Not currently in use */
/** params relevant to the module, mostly relevant to sessions */
gasOffset?: GasOffsetPct;
params?: ModuleInfo;
/** nonceOptions: For overriding the nonce */
nonceOptions?: NonceOptions;
/** forceEncodeForBatch: For encoding the user operation for batch */
forceEncodeForBatch?: boolean;
/** paymasterServiceData: Options specific to transactions that involve a paymaster */
paymasterServiceData?: PaymasterUserOperationDto;
/** simulationType: Determine which parts of the tx a bundler will simulate: "validation" | "validation_and_execution". */
simulationType?: SimulationType;
/** dummy pnd override */
stateOverrideSet?: StateOverrideSet;
dummyPndOverride?: BytesLike;
/** stateOverrideSet: For overriding the state */
stateOverrideSet?: StateOverrideSet;
/** set to true if the tx is being used *only* to deploy the smartContract, so "0x" is set as the userOp.callData */
useEmptyDeployCallData?: boolean;

@@ -158,10 +161,26 @@ };

export type SimulationType = "validation" | "validation_and_execution";
export type Overrides = {
callGasLimit?: Hex;
verificationGasLimit?: Hex;
preVerificationGas?: Hex;
maxFeePerGas?: Hex;
maxPriorityFeePerGas?: Hex;
paymasterData?: Hex;
signature?: Hex;
/**
* Represents an offset percentage value used for gas-related calculations.
* @remarks
* This type defines offset percentages for various gas-related parameters. Each percentage represents a proportion of the current estimated gas values.
* For example:
* - A value of `1` represents a 1% offset.
* - A value of `100` represents a 100% offset.
* @public
*/
/**
* Represents an object containing offset percentages for gas-related parameters.
* @typedef GasOffsetPct
* @property {number} [callGasLimitOffsetPct] - Percentage offset for the gas limit used by inner account execution.
* @property {number} [verificationGasLimitOffsetPct] - Percentage offset for the actual gas used by the validation of a UserOperation.
* @property {number} [preVerificationGasOffsetPct] - Percentage offset representing the gas overhead of a UserOperation.
* @property {number} [maxFeePerGasOffsetPct] - Percentage offset for the maximum fee per gas (similar to EIP-1559 max_fee_per_gas).
* @property {number} [maxPriorityFeePerGasOffsetPct] - Percentage offset for the maximum priority fee per gas (similar to EIP-1559 max_priority_fee_per_gas).
*/
export type GasOffsetPct = {
callGasLimitOffsetPct?: number;
verificationGasLimitOffsetPct?: number;
preVerificationGasOffsetPct?: number;
maxFeePerGasOffsetPct?: number;
maxPriorityFeePerGasOffsetPct?: number;
};

@@ -450,2 +469,3 @@ export type InitilizationData = {

}
export type TransferOwnershipCompatibleModule = "0x0000001c5b32F37F5beA87BDD5374eB2aC54eA8e" | "0x000000824dc138db84FD9109fc154bdad332Aa8E";
//# sourceMappingURL=Types.d.ts.map

@@ -22,2 +22,4 @@ import { type Address, type Hash, type Hex } from "viem";

export declare const wrapSignatureWith6492: ({ factoryAddress, factoryCalldata, signature }: SignWith6492Params) => Hash;
export declare function percentage(partialValue: number, totalValue: number): number;
export declare function convertToFactor(percentage: number | undefined): number;
//# sourceMappingURL=Utils.d.ts.map

@@ -11,3 +11,3 @@ {

"author": "Biconomy",
"version": "4.2.0",
"version": "4.3.0",
"description": "SDK for Biconomy integration with support for account abstraction, smart accounts, ERC-4337.",

@@ -50,6 +50,3 @@ "keywords": [

},
"files": [
"dist/*",
"README.md"
],
"files": ["dist/*", "README.md"],
"scripts": {

@@ -110,5 +107,3 @@ "format": "biome format . --write",

"commitlint": {
"extends": [
"@commitlint/config-conventional"
]
"extends": ["@commitlint/config-conventional"]
},

@@ -115,0 +110,0 @@ "simple-git-hooks": {

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 too big to display

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc