Socket
Socket
Sign inDemoInstall

@biconomy/bundler

Package Overview
Dependencies
43
Maintainers
6
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.0.2 to 4.1.0

4

dist/cjs/Bundler.d.ts
import { type UserOperationStruct } from "@alchemy/aa-core";
import { IBundler } from "./interfaces/IBundler.js";
import { Bundlerconfig, UserOpResponse, UserOpReceipt, UserOpGasResponse, UserOpByHashResponse, GasFeeValues, UserOpStatus, SimulationType } from "./utils/Types.js";
import { StateOverrideSet } from "@biconomy/common";
export declare class Bundler implements IBundler {

@@ -18,5 +19,6 @@ private bundlerConfig;

};
private provider;
constructor(bundlerConfig: Bundlerconfig);
getBundlerUrl(): string;
estimateUserOpGas(userOp: UserOperationStruct): Promise<UserOpGasResponse>;
estimateUserOpGas(userOp: UserOperationStruct, stateOverrideSet?: StateOverrideSet): Promise<UserOpGasResponse>;
sendUserOp(userOp: UserOperationStruct, simulationParam?: SimulationType): Promise<UserOpResponse>;

@@ -23,0 +25,0 @@ getUserOpReceipt(userOpHash: string): Promise<UserOpReceipt>;

@@ -42,4 +42,14 @@ "use strict";

});
Object.defineProperty(this, "provider", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
const parsedChainId = bundlerConfig?.chainId || (0, Utils_js_1.extractChainIdFromBundlerUrl)(bundlerConfig.bundlerUrl);
this.bundlerConfig = { ...bundlerConfig, chainId: parsedChainId };
this.provider = (0, viem_1.createPublicClient)({
chain: bundlerConfig.viemChain ?? (0, aa_core_1.getChain)(parsedChainId),
transport: (0, viem_1.http)((bundlerConfig.viemChain || (0, aa_core_1.getChain)(parsedChainId)).rpcUrls.default.http[0]),
});
this.UserOpReceiptIntervals = {

@@ -66,3 +76,3 @@ ...Constants_js_1.UserOpReceiptIntervals,

}
async estimateUserOpGas(userOp) {
async estimateUserOpGas(userOp, stateOverrideSet) {
userOp = (0, HelperFunction_js_1.transformUserOP)(userOp);

@@ -75,3 +85,5 @@ const bundlerUrl = this.getBundlerUrl();

method: "eth_estimateUserOperationGas",
params: [userOp, this.bundlerConfig.entryPointAddress],
params: stateOverrideSet
? [userOp, this.bundlerConfig.entryPointAddress, stateOverrideSet]
: [userOp, this.bundlerConfig.entryPointAddress],
id: (0, HelperFunction_js_1.getTimestampInSeconds)(),

@@ -112,6 +124,2 @@ jsonrpc: "2.0",

wait: (confirmations) => {
const providerClient = (0, viem_1.createPublicClient)({
chain: (0, aa_core_1.getChain)(chainId),
transport: (0, viem_1.http)(),
});
const maxDuration = this.UserOpReceiptMaxDurationIntervals[chainId] || 30000;

@@ -126,3 +134,3 @@ let totalDuration = 0;

if (confirmations) {
const latestBlock = await providerClient.getBlockNumber();
const latestBlock = await this.provider.getBlockNumber();
const confirmedBlocks = Number(latestBlock) - userOpResponse.receipt.blockNumber;

@@ -129,0 +137,0 @@ if (confirmations >= confirmedBlocks) {

@@ -0,5 +1,6 @@

import { StateOverrideSet } from "@biconomy/common";
import { UserOpResponse, UserOpGasResponse, UserOpReceipt, UserOpByHashResponse, UserOpStatus, SimulationType, GasFeeValues } from "../utils/Types";
import { UserOperationStruct } from "@alchemy/aa-core";
export interface IBundler {
estimateUserOpGas(_userOp: Partial<UserOperationStruct>): Promise<UserOpGasResponse>;
estimateUserOpGas(_userOp: Partial<UserOperationStruct>, stateOverrideSet?: StateOverrideSet): Promise<UserOpGasResponse>;
sendUserOp(_userOp: UserOperationStruct, _simulationType?: SimulationType): Promise<UserOpResponse>;

@@ -6,0 +7,0 @@ getUserOpReceipt(_userOpHash: string): Promise<UserOpReceipt>;

import { UserOperationStruct } from "@alchemy/aa-core";
import { Hex } from "viem";
import { Chain, Hex } from "viem";
export type Bundlerconfig = {

@@ -19,2 +19,3 @@ bundlerUrl: string;

};
viemChain?: Chain;
};

@@ -21,0 +22,0 @@ export type BundlerConfigWithChainId = Bundlerconfig & {

export declare const extractChainIdFromBundlerUrl: (url: string) => number;
export declare const extractChainIdFromPaymasterUrl: (url: string) => number;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.extractChainIdFromBundlerUrl = void 0;
exports.extractChainIdFromPaymasterUrl = exports.extractChainIdFromBundlerUrl = void 0;
const extractChainIdFromBundlerUrl = (url) => {

@@ -15,2 +15,16 @@ try {

exports.extractChainIdFromBundlerUrl = extractChainIdFromBundlerUrl;
const extractChainIdFromPaymasterUrl = (url) => {
try {
const regex = /\/api\/v\d+\/(\d+)\//;
const match = regex.exec(url);
if (!match) {
throw new Error("Invalid URL format");
}
return parseInt(match[1]);
}
catch (error) {
throw new Error("Invalid chain id");
}
};
exports.extractChainIdFromPaymasterUrl = extractChainIdFromPaymasterUrl;
//# sourceMappingURL=Utils.js.map
import { type UserOperationStruct } from "@alchemy/aa-core";
import { IBundler } from "./interfaces/IBundler.js";
import { Bundlerconfig, UserOpResponse, UserOpReceipt, UserOpGasResponse, UserOpByHashResponse, GasFeeValues, UserOpStatus, SimulationType } from "./utils/Types.js";
import { StateOverrideSet } from "@biconomy/common";
export declare class Bundler implements IBundler {

@@ -18,5 +19,6 @@ private bundlerConfig;

};
private provider;
constructor(bundlerConfig: Bundlerconfig);
getBundlerUrl(): string;
estimateUserOpGas(userOp: UserOperationStruct): Promise<UserOpGasResponse>;
estimateUserOpGas(userOp: UserOperationStruct, stateOverrideSet?: StateOverrideSet): Promise<UserOpGasResponse>;
sendUserOp(userOp: UserOperationStruct, simulationParam?: SimulationType): Promise<UserOpResponse>;

@@ -23,0 +25,0 @@ getUserOpReceipt(userOpHash: string): Promise<UserOpReceipt>;

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

"use strict";import{getChain as f}from"@alchemy/aa-core";import{createPublicClient as x,http as w}from"viem";import{transformUserOP as v,getTimestampInSeconds as l}from"./utils/HelperFunction.js";import{UserOpReceiptIntervals as R,UserOpWaitForTxHashIntervals as P,UserOpWaitForTxHashMaxDurationIntervals as B,UserOpReceiptMaxDurationIntervals as H,DEFAULT_ENTRYPOINT_ADDRESS as T}from"./utils/Constants.js";import{extractChainIdFromBundlerUrl as D}from"./utils/Utils.js";import{sendRequest as u,HttpMethod as c}from"@biconomy/common";export class Bundler{constructor(e){Object.defineProperty(this,"bundlerConfig",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"UserOpReceiptIntervals",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"UserOpWaitForTxHashIntervals",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"UserOpReceiptMaxDurationIntervals",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"UserOpWaitForTxHashMaxDurationIntervals",{enumerable:!0,configurable:!0,writable:!0,value:void 0});const t=e?.chainId||D(e.bundlerUrl);this.bundlerConfig={...e,chainId:t},this.UserOpReceiptIntervals={...R,...e.userOpReceiptIntervals},this.UserOpWaitForTxHashIntervals={...P,...e.userOpWaitForTxHashIntervals},this.UserOpReceiptMaxDurationIntervals={...H,...e.userOpReceiptMaxDurationIntervals},this.UserOpWaitForTxHashMaxDurationIntervals={...B,...e.userOpWaitForTxHashMaxDurationIntervals},this.bundlerConfig.entryPointAddress=e.entryPointAddress||T}getBundlerUrl(){return`${this.bundlerConfig.bundlerUrl}`}async estimateUserOpGas(e){e=v(e);const t=this.getBundlerUrl(),s=(await u({url:t,method:c.Post,body:{method:"eth_estimateUserOperationGas",params:[e,this.bundlerConfig.entryPointAddress],id:l(),jsonrpc:"2.0"}},"Bundler")).result;for(const o in s)if(!(o==="maxFeePerGas"||o==="maxPriorityFeePerGas")&&(s[o]===void 0||s[o]===null))throw new Error(`Got undefined ${o} from bundler`);return s}async sendUserOp(e,t){const r=this.bundlerConfig.chainId;e=v(e);const s={simulation_type:t||"validation"},o=[e,this.bundlerConfig.entryPointAddress,s],y=this.getBundlerUrl(),p=await u({url:y,method:c.Post,body:{method:"eth_sendUserOperation",params:o,id:l(),jsonrpc:"2.0"}},"Bundler");return{userOpHash:p.result,wait:d=>{const O=x({chain:f(r),transport:w()}),U=this.UserOpReceiptMaxDurationIntervals[r]||3e4;let h=0;return new Promise((m,i)=>{const n=this.UserOpReceiptIntervals[r]||5e3,b=setInterval(async()=>{try{const a=await this.getUserOpReceipt(p.result);if(a&&a.receipt&&a.receipt.blockNumber)if(d){const I=await O.getBlockNumber(),g=Number(I)-a.receipt.blockNumber;if(d>=g){clearInterval(b),m(a);return}}else{clearInterval(b),m(a);return}}catch(a){clearInterval(b),i(a);return}h+=n,h>=U&&(clearInterval(b),i(new Error(`Exceeded maximum duration (${U/1e3} sec) waiting to get receipt for userOpHash ${p.result}. Try getting the receipt manually using eth_getUserOperationReceipt rpc method on bundler`)))},n)})},waitForTxHash:()=>{const d=this.UserOpWaitForTxHashMaxDurationIntervals[r]||2e4;let O=0;return new Promise((U,h)=>{const m=this.UserOpWaitForTxHashIntervals[r]||500,i=setInterval(async()=>{try{const n=await this.getUserOpStatus(p.result);if(n&&n.state&&n.transactionHash){clearInterval(i),U(n);return}}catch(n){clearInterval(i),h(n);return}O+=m,O>=d&&(clearInterval(i),h(new Error(`Exceeded maximum duration (${d/1e3} sec) waiting to get receipt for userOpHash ${p.result}. Try getting the receipt manually using eth_getUserOperationReceipt rpc method on bundler`)))},m)})}}}async getUserOpReceipt(e){const t=this.getBundlerUrl();return(await u({url:t,method:c.Post,body:{method:"eth_getUserOperationReceipt",params:[e],id:l(),jsonrpc:"2.0"}},"Bundler")).result}async getUserOpStatus(e){const t=this.getBundlerUrl();return(await u({url:t,method:c.Post,body:{method:"biconomy_getUserOperationStatus",params:[e],id:l(),jsonrpc:"2.0"}},"Bundler")).result}async getUserOpByHash(e){const t=this.getBundlerUrl();return(await u({url:t,method:c.Post,body:{method:"eth_getUserOperationByHash",params:[e],id:l(),jsonrpc:"2.0"}},"Bundler")).result}async getGasFeeValues(){const e=this.getBundlerUrl();return(await u({url:e,method:c.Post,body:{method:"biconomy_getGasFeeValues",params:[],id:l(),jsonrpc:"2.0"}},"Bundler")).result}static async create(e){return new Bundler(e)}}
"use strict";import{getChain as O}from"@alchemy/aa-core";import{createPublicClient as f,http as x}from"viem";import{transformUserOP as y,getTimestampInSeconds as l}from"./utils/HelperFunction.js";import{UserOpReceiptIntervals as w,UserOpWaitForTxHashIntervals as P,UserOpWaitForTxHashMaxDurationIntervals as R,UserOpReceiptMaxDurationIntervals as B,DEFAULT_ENTRYPOINT_ADDRESS as H}from"./utils/Constants.js";import{extractChainIdFromBundlerUrl as T}from"./utils/Utils.js";import{sendRequest as u,HttpMethod as p}from"@biconomy/common";export class Bundler{constructor(e){Object.defineProperty(this,"bundlerConfig",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"UserOpReceiptIntervals",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"UserOpWaitForTxHashIntervals",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"UserOpReceiptMaxDurationIntervals",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"UserOpWaitForTxHashMaxDurationIntervals",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"provider",{enumerable:!0,configurable:!0,writable:!0,value:void 0});const t=e?.chainId||T(e.bundlerUrl);this.bundlerConfig={...e,chainId:t},this.provider=f({chain:e.viemChain??O(t),transport:x((e.viemChain||O(t)).rpcUrls.default.http[0])}),this.UserOpReceiptIntervals={...w,...e.userOpReceiptIntervals},this.UserOpWaitForTxHashIntervals={...P,...e.userOpWaitForTxHashIntervals},this.UserOpReceiptMaxDurationIntervals={...B,...e.userOpReceiptMaxDurationIntervals},this.UserOpWaitForTxHashMaxDurationIntervals={...R,...e.userOpWaitForTxHashMaxDurationIntervals},this.bundlerConfig.entryPointAddress=e.entryPointAddress||H}getBundlerUrl(){return`${this.bundlerConfig.bundlerUrl}`}async estimateUserOpGas(e,t){e=y(e);const s=this.getBundlerUrl(),i=(await u({url:s,method:p.Post,body:{method:"eth_estimateUserOperationGas",params:t?[e,this.bundlerConfig.entryPointAddress,t]:[e,this.bundlerConfig.entryPointAddress],id:l(),jsonrpc:"2.0"}},"Bundler")).result;for(const a in i)if(!(a==="maxFeePerGas"||a==="maxPriorityFeePerGas")&&(i[a]===void 0||i[a]===null))throw new Error(`Got undefined ${a} from bundler`);return i}async sendUserOp(e,t){const s=this.bundlerConfig.chainId;e=y(e);const c={simulation_type:t||"validation"},i=[e,this.bundlerConfig.entryPointAddress,c],a=this.getBundlerUrl(),d=await u({url:a,method:p.Post,body:{method:"eth_sendUserOperation",params:i,id:l(),jsonrpc:"2.0"}},"Bundler");return{userOpHash:d.result,wait:h=>{const m=this.UserOpReceiptMaxDurationIntervals[s]||3e4;let v=0;return new Promise((U,b)=>{const o=this.UserOpReceiptIntervals[s]||5e3,r=setInterval(async()=>{try{const n=await this.getUserOpReceipt(d.result);if(n&&n.receipt&&n.receipt.blockNumber)if(h){const I=await this.provider.getBlockNumber(),g=Number(I)-n.receipt.blockNumber;if(h>=g){clearInterval(r),U(n);return}}else{clearInterval(r),U(n);return}}catch(n){clearInterval(r),b(n);return}v+=o,v>=m&&(clearInterval(r),b(new Error(`Exceeded maximum duration (${m/1e3} sec) waiting to get receipt for userOpHash ${d.result}. Try getting the receipt manually using eth_getUserOperationReceipt rpc method on bundler`)))},o)})},waitForTxHash:()=>{const h=this.UserOpWaitForTxHashMaxDurationIntervals[s]||2e4;let m=0;return new Promise((v,U)=>{const b=this.UserOpWaitForTxHashIntervals[s]||500,o=setInterval(async()=>{try{const r=await this.getUserOpStatus(d.result);if(r&&r.state&&r.transactionHash){clearInterval(o),v(r);return}}catch(r){clearInterval(o),U(r);return}m+=b,m>=h&&(clearInterval(o),U(new Error(`Exceeded maximum duration (${h/1e3} sec) waiting to get receipt for userOpHash ${d.result}. Try getting the receipt manually using eth_getUserOperationReceipt rpc method on bundler`)))},b)})}}}async getUserOpReceipt(e){const t=this.getBundlerUrl();return(await u({url:t,method:p.Post,body:{method:"eth_getUserOperationReceipt",params:[e],id:l(),jsonrpc:"2.0"}},"Bundler")).result}async getUserOpStatus(e){const t=this.getBundlerUrl();return(await u({url:t,method:p.Post,body:{method:"biconomy_getUserOperationStatus",params:[e],id:l(),jsonrpc:"2.0"}},"Bundler")).result}async getUserOpByHash(e){const t=this.getBundlerUrl();return(await u({url:t,method:p.Post,body:{method:"eth_getUserOperationByHash",params:[e],id:l(),jsonrpc:"2.0"}},"Bundler")).result}async getGasFeeValues(){const e=this.getBundlerUrl();return(await u({url:e,method:p.Post,body:{method:"biconomy_getGasFeeValues",params:[],id:l(),jsonrpc:"2.0"}},"Bundler")).result}static async create(e){return new Bundler(e)}}

@@ -0,5 +1,6 @@

import { StateOverrideSet } from "@biconomy/common";
import { UserOpResponse, UserOpGasResponse, UserOpReceipt, UserOpByHashResponse, UserOpStatus, SimulationType, GasFeeValues } from "../utils/Types";
import { UserOperationStruct } from "@alchemy/aa-core";
export interface IBundler {
estimateUserOpGas(_userOp: Partial<UserOperationStruct>): Promise<UserOpGasResponse>;
estimateUserOpGas(_userOp: Partial<UserOperationStruct>, stateOverrideSet?: StateOverrideSet): Promise<UserOpGasResponse>;
sendUserOp(_userOp: UserOperationStruct, _simulationType?: SimulationType): Promise<UserOpResponse>;

@@ -6,0 +7,0 @@ getUserOpReceipt(_userOpHash: string): Promise<UserOpReceipt>;

import { UserOperationStruct } from "@alchemy/aa-core";
import { Hex } from "viem";
import { Chain, Hex } from "viem";
export type Bundlerconfig = {

@@ -19,2 +19,3 @@ bundlerUrl: string;

};
viemChain?: Chain;
};

@@ -21,0 +22,0 @@ export type BundlerConfigWithChainId = Bundlerconfig & {

export declare const extractChainIdFromBundlerUrl: (url: string) => number;
export declare const extractChainIdFromPaymasterUrl: (url: string) => number;

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

"use strict";export const extractChainIdFromBundlerUrl=r=>{try{const t=/\/api\/v2\/(\d+)\/[a-zA-Z0-9.-]+$/.exec(r);return parseInt(t[1])}catch{throw new Error("Invalid chain id")}};
"use strict";export const extractChainIdFromBundlerUrl=e=>{try{const r=/\/api\/v2\/(\d+)\/[a-zA-Z0-9.-]+$/.exec(e);return parseInt(r[1])}catch{throw new Error("Invalid chain id")}},extractChainIdFromPaymasterUrl=e=>{try{const r=/\/api\/v\d+\/(\d+)\//.exec(e);if(!r)throw new Error("Invalid URL format");return parseInt(r[1])}catch{throw new Error("Invalid chain id")}};
import { type UserOperationStruct } from "@alchemy/aa-core";
import { IBundler } from "./interfaces/IBundler.js";
import { Bundlerconfig, UserOpResponse, UserOpReceipt, UserOpGasResponse, UserOpByHashResponse, GasFeeValues, UserOpStatus, SimulationType } from "./utils/Types.js";
import { StateOverrideSet } from "@biconomy/common";
/**

@@ -23,2 +24,3 @@ * This class implements IBundler interface.

};
private provider;
constructor(bundlerConfig: Bundlerconfig);

@@ -31,3 +33,3 @@ getBundlerUrl(): string;

*/
estimateUserOpGas(userOp: UserOperationStruct): Promise<UserOpGasResponse>;
estimateUserOpGas(userOp: UserOperationStruct, stateOverrideSet?: StateOverrideSet): Promise<UserOpGasResponse>;
/**

@@ -34,0 +36,0 @@ *

@@ -0,5 +1,6 @@

import { StateOverrideSet } from "@biconomy/common";
import { UserOpResponse, UserOpGasResponse, UserOpReceipt, UserOpByHashResponse, UserOpStatus, SimulationType, GasFeeValues } from "../utils/Types";
import { UserOperationStruct } from "@alchemy/aa-core";
export interface IBundler {
estimateUserOpGas(_userOp: Partial<UserOperationStruct>): Promise<UserOpGasResponse>;
estimateUserOpGas(_userOp: Partial<UserOperationStruct>, stateOverrideSet?: StateOverrideSet): Promise<UserOpGasResponse>;
sendUserOp(_userOp: UserOperationStruct, _simulationType?: SimulationType): Promise<UserOpResponse>;

@@ -6,0 +7,0 @@ getUserOpReceipt(_userOpHash: string): Promise<UserOpReceipt>;

import { UserOperationStruct } from "@alchemy/aa-core";
import { Hex } from "viem";
import { Chain, Hex } from "viem";
export type Bundlerconfig = {

@@ -19,2 +19,4 @@ bundlerUrl: string;

};
/** Can be used to optionally override the chain with a custom chain if it doesn't already exist in viems list of supported chains */
viemChain?: Chain;
};

@@ -21,0 +23,0 @@ export type BundlerConfigWithChainId = Bundlerconfig & {

export declare const extractChainIdFromBundlerUrl: (url: string) => number;
export declare const extractChainIdFromPaymasterUrl: (url: string) => number;
//# sourceMappingURL=Utils.d.ts.map
{
"name": "@biconomy/bundler",
"version": "4.0.2",
"version": "4.1.0",
"description": "Biconomy Bundler package to interact with any bundler node as per ERC4337 standard",

@@ -60,3 +60,3 @@ "main": "./dist/cjs/index.js",

"@alchemy/aa-core": "^3.1.1",
"@biconomy/common": "^4.0.2",
"@biconomy/common": "^4.1.0",
"viem": "^2.7.12"

@@ -70,3 +70,3 @@ },

},
"gitHead": "66d5d5605eb1b12d26bd0f0569bda2d4f036b8f5"
"gitHead": "466968dbbcf2fabbe4fce76de1cdb7dc44bf5c3e"
}

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc