New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

abstractionkit

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

abstractionkit - npm Package Compare versions

Comparing version 0.0.9 to 0.1.0

dist/account/Safe/multisend.d.ts

16

dist/abstractionkit.d.ts
export { SmartAccount } from "./account/SmartAccount";
export { CandideAccount } from "./account/Candide/CandideAccount";
export { MetaTransaction } from "./account/Candide/types";
export { SimpleAccount } from "./account/SimpleAccount";
export { SafeAccountV0_2_0 } from "./account/Safe/SafeAccountV0_2_0";
export { SendUseroperationResponse } from "./account/SendUseroperationResponse";
export { SmartAccountFactory } from "./factory/SmartAccountFactory";
export { CandideAccountFactory } from "./factory/CandideAccountFactory";
export { SimpleAccountFactory } from "./factory/SimpleAccountFactory";
export { SafeAccountFactory } from "./factory/SafeAccountFactory";
export { Bundler } from "./Bundler";
export { CandideValidationPaymaster } from "./paymaster/CandideValidationPaymaster";
export { getUserOperationHash, getCallData, getFunctionSelector } from "./utils";
export { UserOperationEmptyValues, UserOperationDummyValues } from "./constants";
export { Operation } from "./types";
export type { UserOperation, AbiInputValue, JsonRpcParam, JsonRpcResponse, JsonRpcResult, JsonRpcError, GasEstimationResult, UserOperationByHashResult, UserOperationReceipt, UserOperationReceiptResult, } from "./types";
export { CandidePaymaster } from "./paymaster/CandidePaymaster";
export { createUserOperationHash, createCallData, getFunctionSelector, fetchAccountNonce, calculateUserOperationMaxGasCost, } from "./utils";
export { UserOperation, AbiInputValue, JsonRpcParam, JsonRpcResponse, JsonRpcResult, GasEstimationResult, UserOperationByHashResult, UserOperationReceipt, UserOperationReceiptResult, JsonRpcError, StateOverrideSet, Operation, MetaTransaction, } from "./types";
//# sourceMappingURL=abstractionkit.d.ts.map

@@ -1,14 +0,11 @@

import type { BytesLike } from "ethers";
import { AbiInputValue } from "../types";
export declare class SmartAccount {
readonly singletonAddress: string;
readonly proxyByteCode: BytesLike;
readonly initializerFunctionSelector: string;
readonly initializerFunctionInputAbi: string[];
readonly executorFunctionSelector: string;
readonly executorFunctionInputAbi: string[];
constructor(singletonAddress: string, proxyByteCode: BytesLike, initializerFunctionSelector: string, initializerFunctionInputAbi: string[], executorFunctionSelector: string, executorFunctionInputAbi: string[]);
getInitializerCallData(initializerFunctionInputParameters: AbiInputValue[]): BytesLike;
getExecutorCallData(executorFunctionInputParameters: AbiInputValue[]): BytesLike;
export declare abstract class SmartAccount {
readonly accountAddress: string;
static readonly proxyByteCode: string;
static readonly initializerFunctionSelector: string;
static readonly initializerFunctionInputAbi: string[];
static readonly executorFunctionSelector: string;
static readonly executorFunctionInputAbi: string[];
constructor(accountAddress: string);
abstract prependTokenPaymasterApproveToCallData(callData: string, tokenAddress: string, paymasterAddress: string, approveAmount: bigint): string;
}
//# sourceMappingURL=SmartAccount.d.ts.map

@@ -1,20 +0,12 @@

import type { UserOperation, JsonRpcError, GasEstimationResult, UserOperationByHashResult, UserOperationReceiptResult } from "./types";
import { BytesLike } from "ethers";
import type { UserOperation, GasEstimationResult, UserOperationByHashResult, UserOperationReceiptResult, StateOverrideSet } from "./types";
export declare class Bundler {
readonly rpcUrl: string;
readonly entrypointAddress: string;
constructor(rpcUrl: string, entrypointAddress: string);
chainId(): Promise<{
chainId: string;
} | JsonRpcError>;
supportedEntryPoints(): Promise<{
supportedEntryPoints: string[];
} | JsonRpcError>;
estimateUserOperationGas(useroperation: UserOperation): Promise<GasEstimationResult | JsonRpcError>;
sendUserOperation(useroperation: UserOperation): Promise<{
userOperationHash: string;
} | JsonRpcError>;
getUserOperationReceipt(useroperationhash: BytesLike): Promise<UserOperationReceiptResult | JsonRpcError>;
getUserOperationByHash(useroperationhash: BytesLike): Promise<UserOperationByHashResult | JsonRpcError>;
constructor(rpcUrl: string);
chainId(): Promise<string>;
supportedEntryPoints(): Promise<string[]>;
estimateUserOperationGas(useroperation: UserOperation, entrypointAddress: string, state_override_set?: StateOverrideSet): Promise<GasEstimationResult>;
sendUserOperation(useroperation: UserOperation, entrypointAddress: string): Promise<string>;
getUserOperationReceipt(useroperationhash: string): Promise<UserOperationReceiptResult>;
getUserOperationByHash(useroperationhash: string): Promise<UserOperationByHashResult>;
}
//# sourceMappingURL=Bundler.d.ts.map

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

import type { UserOperation } from "./types";
export declare const UserOperationEmptyValues: UserOperation;
import { type UserOperation } from "./types";
export declare const ZeroAddress = "0x0000000000000000000000000000000000000000";
export declare const UserOperationDummyValues: UserOperation;
//# sourceMappingURL=constants.d.ts.map

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

import type { BytesLike } from "ethers";
import type { AbiInputValue } from "../types";

@@ -8,4 +7,4 @@ export declare class SmartAccountFactory {

constructor(address: string, generatorFunctionSelector: string, generatorFunctionInputAbi: string[]);
getFactoryGeneratorFunctionCallData(generatorFunctionInputParameters: AbiInputValue[]): BytesLike;
getFactoryGeneratorFunctionCallData(generatorFunctionInputParameters: AbiInputValue[]): string;
}
//# sourceMappingURL=SmartAccountFactory.d.ts.map

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

var e=require("isomorphic-unfetch"),t=require("ethers");function r(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,t}var n=/*#__PURE__*/r(e),a=function(e,t,r){try{var a=n.default||n,i=JSON.stringify({method:t,params:r,id:1,jsonrpc:"2.0"});return Promise.resolve(a(e,{method:"POST",body:i,redirect:"follow"})).then(function(e){return Promise.resolve(e.json())})}catch(e){return Promise.reject(e)}};function i(e,r,n){var a=t.keccak256(function(e){var r=[e.sender,e.nonce,t.keccak256(e.initCode),t.keccak256(e.callData),e.callGasLimit,e.verificationGasLimit,e.preVerificationGas,e.maxFeePerGas,e.maxPriorityFeePerGas,t.keccak256(e.paymasterAndData)];return t.AbiCoder.defaultAbiCoder().encode(["address","uint256","bytes32","bytes32","uint256","uint256","uint256","uint256","uint256","bytes32"],r)}(e)),i=t.AbiCoder.defaultAbiCoder().encode(["bytes32","address","uint256"],[a,r,n]);return t.keccak256(i)}function o(e,r,n){return e+t.AbiCoder.defaultAbiCoder().encode(r,n).slice(2)}function f(e){return t.id(e).slice(0,10)}var c,s=/*#__PURE__*/function(){function e(e,t,r,n,a,i){this.singletonAddress=void 0,this.proxyByteCode=void 0,this.initializerFunctionSelector=void 0,this.initializerFunctionInputAbi=void 0,this.executorFunctionSelector=void 0,this.executorFunctionInputAbi=void 0,this.singletonAddress=e,this.proxyByteCode=t,this.initializerFunctionSelector=r,this.initializerFunctionInputAbi=n,this.executorFunctionSelector=a,this.executorFunctionInputAbi=i}var t=e.prototype;return t.getInitializerCallData=function(e){return o(this.initializerFunctionSelector,this.initializerFunctionInputAbi,e)},t.getExecutorCallData=function(e){return o(this.executorFunctionSelector,this.executorFunctionInputAbi,e)},e}();function d(){return d=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},d.apply(this,arguments)}function u(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,b(e,t)}function b(e,t){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},b(e,t)}exports.Operation=void 0,(c=exports.Operation||(exports.Operation={}))[c.Call=0]="Call",c[c.Delegate=1]="Delegate";var l=/*#__PURE__*/function(){function e(e,t,r){this.address=void 0,this.generatorFunctionSelector=void 0,this.generatorFunctionInputAbi=void 0,this.address=e,this.generatorFunctionSelector=t,this.generatorFunctionInputAbi=r}return e.prototype.getFactoryGeneratorFunctionCallData=function(e){var t=o(this.generatorFunctionSelector,this.generatorFunctionInputAbi,e);return this.address+t.slice(2)},e}(),p=/*#__PURE__*/function(e){function t(t){return void 0===t&&(t="0xb73Eb505Abc30d0e7e15B73A492863235B3F4309"),e.call(this,t,"0x1688f0b9",["address","bytes","uint256"])||this}return u(t,e),t}(l);function h(e){return"0x"+e.map(function(e){return function(e){var r=t.ethers.getBytes(e.data);return t.ethers.solidityPacked(["uint8","address","uint256","uint256","bytes"],[e.operation,e.to,e.value,r.length,r]).slice(2)}(e)}).join("")}var y=/*#__PURE__*/function(e){function r(t,r,n){var a;return void 0===t&&(t="0x3A0a17Bcc84576b099373ab3Eed9702b07D30402"),void 0===r&&(r="0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"),void 0===n&&(n=new p),(a=e.call(this,t,"0x608060405234801561001057600080fd5b5060405161017338038061017383398101604081905261002f916100b9565b6001600160a01b0381166100945760405162461bcd60e51b815260206004820152602260248201527f496e76616c69642073696e676c65746f6e20616464726573732070726f766964604482015261195960f21b606482015260840160405180910390fd5b600080546001600160a01b0319166001600160a01b03929092169190911790556100e9565b6000602082840312156100cb57600080fd5b81516001600160a01b03811681146100e257600080fd5b9392505050565b607c806100f76000396000f3fe6080604052600080546001600160a01b0316813563530ca43760e11b1415602857808252602082f35b3682833781823684845af490503d82833e806041573d82fd5b503d81f3fea2646970667358221220022b6bb97dd1e16cb867add83d4159f7550336cbb5b40514145e43f493c1377664736f6c634300080c0033","0x6a1e9826",["address[]","uint256","address","bytes","address","address","uint256","address","address"],"0xf34308ef",["address","uint256","bytes","uint8","address","address","uint256"])||this).entrypointAddress=void 0,a.candideAccountFactory=void 0,a.entrypointAddress=r,a.candideAccountFactory=n,a}u(r,e);var n=r.prototype;return n.createNewAccount=function(e,r,n,a){void 0===r&&(r=1),void 0===n&&(n=0),void 0===a&&(a="0x2a15DE4410d4c8af0A7b6c12803120f43C42B820");var i=this.getInitializerCallData([e,r,t.ZeroAddress,"0x",a,t.ZeroAddress,0,t.ZeroAddress,this.entrypointAddress]);return[this.getProxyAddress(i,this.candideAccountFactory.address,n),this.candideAccountFactory.getFactoryGeneratorFunctionCallData([this.singletonAddress,i,n])]},n.createSendEthCallData=function(e,r){return this.createCallData(e,r,"0x",0,t.ZeroAddress,t.ZeroAddress,0)},n.createCallData=function(e,t,r,n,a,i,o){return this.getExecutorCallData([e,t,r,n,a,i,o])},n.getProxyAddress=function(e,r,n){var a=t.keccak256(t.solidityPacked(["bytes32","uint256"],[t.keccak256(e),n])),i=t.keccak256(t.solidityPacked(["bytes","uint256"],[this.proxyByteCode,this.singletonAddress]));return"0x"+t.solidityPackedKeccak256(["bytes1","address","bytes32","bytes32"],["0xff",r,a,i]).slice(-40)},n.createCallDataSingleTransactionWithPaymaster=function(e,t,r,n){return this.getExecutorCallData([e.to,e.value,e.data,e.operation,t,r,n])},n.createCallDataSingleTransaction=function(e){return this.createCallDataSingleTransactionWithPaymaster(e,t.ZeroAddress,t.ZeroAddress,0)},n.createCallDataBatchTransactionWithPaymaster=function(e,t,r,n){var a=o("0x8d80ff0a",["bytes"],[h(e)]);return this.getExecutorCallData(["0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526",0,a,exports.Operation.Delegate,t,r,n])},n.createCallDataBatchTransaction=function(e){return this.createCallDataBatchTransactionWithPaymaster(e,t.ZeroAddress,t.ZeroAddress,0)},r}(s),x=/*#__PURE__*/function(e){function t(t){return void 0===t&&(t="0x9406Cc6185a346906296840746125a0E44976454"),e.call(this,t,"0x5fbfb9cf",["address","uint256"])||this}return u(t,e),t}(l),A=/*#__PURE__*/function(e){function r(t,r,n){var a;return void 0===t&&(t="0x8ABB13360b87Be5EEb1B98647A016adD927a136c"),void 0===r&&(r="0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"),void 0===n&&(n=new x),(a=e.call(this,t,"0x60806040526040516107c13803806107c183398101604081905261002291610321565b61002e82826000610035565b505061043e565b61003e8361006b565b60008251118061004b5750805b156100665761006483836100ab60201b6100291760201c565b505b505050565b610074816100d7565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606100d0838360405180606001604052806027815260200161079a602791396101a9565b9392505050565b6100ea8161022260201b6100551760201c565b6101515760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084015b60405180910390fd5b806101887f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b61023160201b6100711760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b6060600080856001600160a01b0316856040516101c691906103ef565b600060405180830381855af49150503d8060008114610201576040519150601f19603f3d011682016040523d82523d6000602084013e610206565b606091505b50909250905061021886838387610234565b9695505050505050565b6001600160a01b03163b151590565b90565b606083156102a357825160000361029c576001600160a01b0385163b61029c5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610148565b50816102ad565b6102ad83836102b5565b949350505050565b8151156102c55781518083602001fd5b8060405162461bcd60e51b8152600401610148919061040b565b634e487b7160e01b600052604160045260246000fd5b60005b838110156103105781810151838201526020016102f8565b838111156100645750506000910152565b6000806040838503121561033457600080fd5b82516001600160a01b038116811461034b57600080fd5b60208401519092506001600160401b038082111561036857600080fd5b818501915085601f83011261037c57600080fd5b81518181111561038e5761038e6102df565b604051601f8201601f19908116603f011681019083821181831017156103b6576103b66102df565b816040528281528860208487010111156103cf57600080fd5b6103e08360208301602088016102f5565b80955050505050509250929050565b600082516104018184602087016102f5565b9190910192915050565b602081526000825180602084015261042a8160408501602087016102f5565b601f01601f19169190910160400192915050565b61034d8061044d6000396000f3fe60806040523661001357610011610017565b005b6100115b610027610022610074565b6100b9565b565b606061004e83836040518060600160405280602781526020016102f1602791396100dd565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b90565b60006100b47f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5473ffffffffffffffffffffffffffffffffffffffff1690565b905090565b3660008037600080366000845af43d6000803e8080156100d8573d6000f35b3d6000fd5b60606000808573ffffffffffffffffffffffffffffffffffffffff16856040516101079190610283565b600060405180830381855af49150503d8060008114610142576040519150601f19603f3d011682016040523d82523d6000602084013e610147565b606091505b509150915061015886838387610162565b9695505050505050565b606083156101fd5782516000036101f65773ffffffffffffffffffffffffffffffffffffffff85163b6101f6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064015b60405180910390fd5b5081610207565b610207838361020f565b949350505050565b81511561021f5781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101ed919061029f565b60005b8381101561026e578181015183820152602001610256565b8381111561027d576000848401525b50505050565b60008251610295818460208701610253565b9190910192915050565b60208152600082518060208401526102be816040850160208701610253565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212201cd78ab6a31213989661cff2d7d05fc9b9c38b1a848e8249e2e398659a9eb7e364736f6c634300080f0033416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564","0xc4d66de8",["address"],"0xb61d27f6",["address","uint256","bytes"])||this).entrypointAddress=void 0,a.simpleAccountFactory=void 0,a.batchExecutorFunctionSelector=void 0,a.batchExecutorFunctionInputAbi=void 0,a.entrypointAddress=r,a.simpleAccountFactory=n,a.batchExecutorFunctionSelector="0x18dfb3c7",a.batchExecutorFunctionInputAbi=["address[]","bytes[]"],a}u(r,e);var n=r.prototype;return n.createNewAccount=function(e,t){void 0===t&&(t=0);var r=this.getInitializerCallData([e]),n=this.simpleAccountFactory.getFactoryGeneratorFunctionCallData([e,t]);return[this.getProxyAddress(r,this.simpleAccountFactory.address,t),n]},n.getProxyAddress=function(e,r,n){var a=t.AbiCoder.defaultAbiCoder(),i=a.encode(["uint256"],[n]),o=a.encode(["address","bytes"],[this.singletonAddress,e]),f=t.keccak256(t.solidityPacked(["bytes","bytes"],[this.proxyByteCode,o]));return"0x"+t.solidityPackedKeccak256(["bytes1","address","bytes32","bytes32"],["0xff",r,i,f]).slice(-40)},n.createSendEthCallData=function(e,t){return this.createCallData(e,t,"0x")},n.createCallData=function(e,t,r){return this.getExecutorCallData([e,t,r])},n.createBatchCallData=function(e,t){return o(this.batchExecutorFunctionSelector,this.batchExecutorFunctionInputAbi,[e,t])},r}(s),m=/*#__PURE__*/function(){function e(e,t){this.rpcUrl=void 0,this.entrypointAddress=void 0,this.rpcUrl=e,this.entrypointAddress=t}var t=e.prototype;return t.chainId=function(){try{return Promise.resolve(a(this.rpcUrl,"eth_chainId",[])).then(function(e){return"result"in e?{chainId:e.result}:e.error})}catch(e){return Promise.reject(e)}},t.supportedEntryPoints=function(){try{return Promise.resolve(a(this.rpcUrl,"eth_supportedEntryPoints",[])).then(function(e){return"result"in e?{supportedEntryPoints:e.result}:e.error})}catch(e){return Promise.reject(e)}},t.estimateUserOperationGas=function(e){try{return Promise.resolve(a(this.rpcUrl,"eth_estimateUserOperationGas",[e,this.entrypointAddress])).then(function(e){return"result"in e?e.result:e.error})}catch(e){return Promise.reject(e)}},t.sendUserOperation=function(e){try{return Promise.resolve(a(this.rpcUrl,"eth_sendUserOperation",[e,this.entrypointAddress])).then(function(e){return"result"in e?{userOperationHash:e.result}:e.error})}catch(e){return Promise.reject(e)}},t.getUserOperationReceipt=function(e){try{return Promise.resolve(a(this.rpcUrl,"eth_getUserOperationReceipt",[e])).then(function(e){if("result"in e){var t=e.result,r=d({},t.receipt,{logs:JSON.stringify(t.receipt.logs)});return d({},t,{logs:JSON.stringify(t.logs),receipt:r})}return e.error})}catch(e){return Promise.reject(e)}},t.getUserOperationByHash=function(e){try{return Promise.resolve(a(this.rpcUrl,"eth_getUserOperationByHash",[e])).then(function(e){return"result"in e?e.result:e.error})}catch(e){return Promise.reject(e)}},e}(),v=/*#__PURE__*/function(e){function t(t,r){var n;return(n=e.call(this)||this).rpcUrl=void 0,n.entrypointAddress=void 0,n.rpcUrl=r,n.entrypointAddress=t,n}u(t,e);var r=t.prototype;return r.getSupportedERC20Tokens=function(){try{return Promise.resolve(a(this.rpcUrl,"pm_supportedERC20Tokens",[])).then(function(e){if("result"in e){var t=e.result;return{tokens:t.tokens,paymasterMetadata:t.paymasterMetadata}}return e.error})}catch(e){return Promise.reject(e)}},r.getSupportedEntrypoint=function(){try{return Promise.resolve(a(this.rpcUrl,"pm_supportedEntryPoint",[])).then(function(e){return"result"in e?e.result:e.error})}catch(e){return Promise.reject(e)}},r.getPaymasterCallDataForPayingGasWithErc20=function(e,t){try{var r=this;return Promise.resolve(r.getPaymasterCallData(e,[r.rpcUrl,r.entrypointAddress,t]))}catch(e){return Promise.reject(e)}},r.getPaymasterCallDataForGaslessTx=function(e){try{var t=this;return Promise.resolve(t.getPaymasterCallData(e,[t.rpcUrl,t.entrypointAddress]))}catch(e){return Promise.reject(e)}},r.getPaymasterCallData=function(e,t){try{return Promise.resolve(a(t[0],"pm_sponsorUserOperation",[e,t[1],{token:t[2]}])).then(function(e){return"result"in e?e.result:e.error})}catch(e){return Promise.reject(e)}},t}(function(){}),g={sender:t.ZeroAddress,nonce:"0x00",initCode:"0x",callData:"0x",callGasLimit:"0x00",verificationGasLimit:"0x00",preVerificationGas:"0x00",maxFeePerGas:"0x00",maxPriorityFeePerGas:"0x00",paymasterAndData:"0x",signature:"0x"},P={sender:t.ZeroAddress,nonce:"0x00",initCode:"0x",callData:"0x",callGasLimit:"0xffffff",verificationGasLimit:"0xffffff",preVerificationGas:"0xffffff",maxFeePerGas:"0xffffff",maxPriorityFeePerGas:"0xfffffff",paymasterAndData:"0x",signature:"0x"},F={__proto__:null,SmartAccount:s,CandideAccount:y,SimpleAccount:A,SmartAccountFactory:l,CandideAccountFactory:p,SimpleAccountFactory:x,Bundler:m,CandideValidationPaymaster:v,getUserOperationHash:i,getCallData:o,getFunctionSelector:f,UserOperationEmptyValues:g,UserOperationDummyValues:P,get Operation(){return exports.Operation}};exports.Bundler=m,exports.CandideAccount=y,exports.CandideAccountFactory=p,exports.CandideValidationPaymaster=v,exports.SimpleAccount=A,exports.SimpleAccountFactory=x,exports.SmartAccount=s,exports.SmartAccountFactory=l,exports.UserOperationDummyValues=P,exports.UserOperationEmptyValues=g,exports.abstractionkit=F,exports.getCallData=o,exports.getFunctionSelector=f,exports.getUserOperationHash=i;
var e=require("ethers");function t(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,t}var r,n,i=/*#__PURE__*/t(require("isomorphic-unfetch")),a=function(e){this.accountAddress=void 0,this.accountAddress=e};function o(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(o=function(){return!!e})()}function s(){return s=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},s.apply(this,arguments)}function f(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,u(e,t)}function c(e){return c=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},c(e)}function u(e,t){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},u(e,t)}function l(e){var t="function"==typeof Map?new Map:void 0;return l=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return function(e,t,r){if(o())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,t);var i=new(e.bind.apply(e,n));return r&&u(i,r.prototype),i}(e,arguments,c(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),u(r,e)},l(e)}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}a.proxyByteCode=void 0,a.initializerFunctionSelector=void 0,a.initializerFunctionInputAbi=void 0,a.executorFunctionSelector=void 0,a.executorFunctionInputAbi=void 0,exports.Operation=void 0,(r=exports.Operation||(exports.Operation={}))[r.Call=0]="Call",r[r.Delegate=1]="Delegate",function(e){e[e.Slow=1]="Slow",e[e.Medium=1.2]="Medium",e[e.Fast=1.5]="Fast"}(n||(n={}));var p={"-32602":"INVALID_FIELDS","-32500":"SIMULATE_VALIDATION","-32501":"SIMULATE_PAYMASTER_VALIDATION","-32502":"OPCODE_VALIDATION","-32503":"EXPIRE_SHORTLY","-32504":"REPUTATION","-32505":"INSUFFICIENT_STAKE","-32506":"UNSUPPORTED_SIGNATURE_AGGREGATOR","-32507":"INVALID_SIGNATURE","-32601":"INVALID_USEROPERATION_HASH","-32521":"EXECUTION_REVERTED"},h=/*#__PURE__*/function(e){function t(t,r,n){var i;void 0===n&&(n={});var a=n.errno,o=n.context;return(i=e.call(this,r,{cause:n.cause})||this).code=void 0,i.context=void 0,i.errno=void 0,i.name=i.constructor.name,i.code=t,i.errno=a,i.context=o,i}return f(t,e),t}(/*#__PURE__*/l(Error));function v(e){if(e instanceof Error)return e;var t="[Unable to stringify the thrown value]";try{t=JSON.stringify(e)}catch(e){}return new Error("This value was thrown as is, not through an Error: "+t)}var m=function(e,t,r,n){void 0===n&&(n=0);try{var i=[{from:"0x0000000000000000000000000000000000000000",to:t,data:P(g("getNonce(address,uint192)"),["address","uint192"],[r,n])},"latest"];return Promise.resolve(function(t,r){try{var n=Promise.resolve(y(e,"eth_call",i)).then(function(e){if("string"!=typeof e)throw new h("BAD_DATA","getNonce returned ill formed data",{context:JSON.stringify(e)});try{return BigInt(e)}catch(e){var t=v(e);throw new h("BAD_DATA","getNonce returned ill formed data",{cause:t})}})}catch(e){return r(e)}return n&&n.then?n.then(void 0,r):n}(0,function(e){var t=v(e);throw new h("BAD_DATA","getNonce failed",{cause:t})}))}catch(e){return Promise.reject(e)}},y=function(e,t,r){try{var n=i.default||i,a={method:"POST",body:JSON.stringify({method:t,params:r,id:(new Date).getTime(),jsonrpc:"2.0"},function(e,t){return"bigint"==typeof t?"0x"+t.toString(16):t}),redirect:"follow"};return Promise.resolve(n(e,a)).then(function(t){return Promise.resolve(t.json()).then(function(t){if("result"in t)return t.result;var r=t.error,n=String(r.code);throw new h(n in p?p[n]:"UNKNOWN_ERROR",r.message,{errno:r.code,context:{url:e,requestOptions:JSON.stringify(a)}})})})}catch(e){return Promise.reject(e)}};function A(t,r,n){var i=e.keccak256(function(t){var r=[t.sender,t.nonce,e.keccak256(t.initCode),e.keccak256(t.callData),t.callGasLimit,t.verificationGasLimit,t.preVerificationGas,t.maxFeePerGas,t.maxPriorityFeePerGas,e.keccak256(t.paymasterAndData)];return e.AbiCoder.defaultAbiCoder().encode(["address","uint256","bytes32","bytes32","uint256","uint256","uint256","uint256","uint256","bytes32"],r)}(t)),a=e.AbiCoder.defaultAbiCoder().encode(["bytes32","address","uint256"],[i,r,n]);return e.keccak256(a)}function P(t,r,n){return t+e.AbiCoder.defaultAbiCoder().encode(r,n).slice(2)}function g(t){return e.id(t).slice(0,10)}function D(e){return(e.callGasLimit+e.verificationGasLimit*("0x"==e.paymasterAndData||null==e.paymasterAndData?3n:0n)+e.preVerificationGas)*e.maxFeePerGas}var E,b="0x0000000000000000000000000000000000000000",G={sender:b,nonce:0n,initCode:"0x",callData:"0x",callGasLimit:0xffffffn,verificationGasLimit:0xffffffn,preVerificationGas:0xffffffn,maxFeePerGas:0xffffffn,maxPriorityFeePerGas:0xfffffffn,paymasterAndData:"0x",signature:"0x"},O=/*#__PURE__*/function(){function e(e,t,r){this.address=void 0,this.generatorFunctionSelector=void 0,this.generatorFunctionInputAbi=void 0,this.address=e,this.generatorFunctionSelector=t,this.generatorFunctionInputAbi=r}return e.prototype.getFactoryGeneratorFunctionCallData=function(e){var t=P(this.generatorFunctionSelector,this.generatorFunctionInputAbi,e);return this.address+t.slice(2)},e}(),x=/*#__PURE__*/function(e){function t(t){return void 0===t&&(t="0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67"),e.call(this,t,"0x1688f0b9",["address","bytes","uint256"])||this}return f(t,e),t}(O);function R(t){return"0x"+t.map(function(t){return i=null!=(n=(r=t).operation)?n:exports.Operation.Call,a=e.getBytes(r.data),e.solidityPacked(["uint8","address","uint256","uint256","bytes"],[i,r.to,r.value,a.length,a]).slice(2);var r,n,i,a}).join("")}function _(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}!function(e){e.executeUserOpWithErrorString="0x541d63c8",e.executeUserOp="0x7bb37428"}(E||(E={}));var S=/*#__PURE__*/function(){function e(e){this.rpcUrl=void 0,this.rpcUrl=e}var t=e.prototype;return t.chainId=function(){try{var e=this;return Promise.resolve(_(function(){return Promise.resolve(y(e.rpcUrl,"eth_chainId",[])).then(function(e){if("string"==typeof e)return e;throw new h("BAD_DATA","bundler eth_chainId rpc call failed")})},function(e){var t=v(e);throw new h("BUNDLER_ERROR","bundler eth_chainId rpc call failed",{cause:t})}))}catch(e){return Promise.reject(e)}},t.supportedEntryPoints=function(){try{var e=this;return Promise.resolve(_(function(){return Promise.resolve(y(e.rpcUrl,"eth_supportedEntryPoints",[]))},function(e){var t=v(e);throw new h("BUNDLER_ERROR","bundler eth_supportedEntryPoints rpc call failed",{cause:t})}))}catch(e){return Promise.reject(e)}},t.estimateUserOperationGas=function(e,t,r){try{var n=this;return Promise.resolve(_(function(){function i(){var e=a;return{callGasLimit:BigInt(e.callGasLimit),preVerificationGas:BigInt(e.preVerificationGas),verificationGasLimit:BigInt(e.verificationGasLimit)}}var a={},o=void 0===r?Promise.resolve(y(n.rpcUrl,"eth_estimateUserOperationGas",[e,t])).then(function(e){a=e}):Promise.resolve(y(n.rpcUrl,"eth_estimateUserOperationGas",[e,t,r])).then(function(e){a=e});return o&&o.then?o.then(i):i()},function(e){var t=v(e);throw new h("BUNDLER_ERROR","bundler eth_estimateUserOperationGas rpc call failed",{cause:t})}))}catch(e){return Promise.reject(e)}},t.sendUserOperation=function(e,t){try{var r=this;return Promise.resolve(_(function(){return Promise.resolve(y(r.rpcUrl,"eth_sendUserOperation",[e,t]))},function(e){var t=v(e);throw new h("BUNDLER_ERROR","bundler eth_sendUserOperation rpc call failed",{cause:t})}))}catch(e){return Promise.reject(e)}},t.getUserOperationReceipt=function(e){try{var t=this;return Promise.resolve(_(function(){return Promise.resolve(y(t.rpcUrl,"eth_getUserOperationReceipt",[e])).then(function(e){var t=e;if(null!=t){var r=s({},t.receipt,{blockNumber:BigInt(t.receipt.blockNumber),cumulativeGasUsed:BigInt(t.receipt.cumulativeGasUsed),gasUsed:BigInt(t.receipt.gasUsed),transactionIndex:BigInt(t.receipt.transactionIndex),effectiveGasPrice:null==t.receipt.effectiveGasPrice?void 0:BigInt(t.receipt.effectiveGasPrice),logs:JSON.stringify(t.receipt.logs)});return s({},t,{nonce:BigInt(t.nonce),actualGasCost:BigInt(t.actualGasCost),actualGasUsed:BigInt(t.actualGasUsed),logs:JSON.stringify(t.logs),receipt:r})}return null})},function(t){var r=v(t);throw new h("BUNDLER_ERROR","bundler eth_getUserOperationReceipt rpc call failed",{cause:r,context:{useroperationhash:e}})}))}catch(e){return Promise.reject(e)}},t.getUserOperationByHash=function(e){try{var t=this;return Promise.resolve(_(function(){return Promise.resolve(y(t.rpcUrl,"eth_getUserOperationByHash",[e])).then(function(e){return null!=e?s({},e,{blockNumber:null==e.blockNumber?null:BigInt(e.blockNumber)}):null})},function(t){var r=v(t);throw new h("BUNDLER_ERROR","bundler eth_getUserOperationByHash rpc call failed",{cause:r,context:{useroperationhash:e}})}))}catch(e){return Promise.reject(e)}},e}();function U(e,t,r){if(!e.s){if(r instanceof T){if(!r.s)return void(r.o=U.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(U.bind(null,e,t),U.bind(null,e,2));e.s=t,e.v=r;const n=e.o;n&&n(e)}}var T=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(t,r){var n=new e,i=this.s;if(i){var a=1&i?t:r;if(a){try{U(n,1,a(this.v))}catch(e){U(n,2,e)}return n}return this}return this.o=function(e){try{var i=e.v;1&e.s?U(n,1,t?t(i):i):r?U(n,1,r(i)):U(n,2,i)}catch(e){U(n,2,e)}},n},e}();function F(e){return e instanceof T&&1&e.s}var L=/*#__PURE__*/function(){function e(e,t,r){this.userOperationHash=void 0,this.bundler=void 0,this.entrypointAddress=void 0,this.bundler=t,this.userOperationHash=e,this.entrypointAddress=r}var t=e.prototype;return t.delay=function(e){return new Promise(function(t){return setTimeout(t,e)})},t.included=function(e,t){void 0===e&&(e=180),void 0===t&&(t=2);try{var r,n=function(e){if(r)return e;throw new h("TIMEOUT","can't find useroperation",{context:i.userOperationHash})},i=this;if(e<=0||t<=0)throw RangeError("timeoutInSeconds and requestIntervalInSeconds should be bigger than zero");if(e<t)throw RangeError("timeoutInSeconds can't be less than requestIntervalInSeconds");var a=0,o=function(e,t,r){for(var n;;){var i=e();if(F(i)&&(i=i.v),!i)return a;if(i.then){n=0;break}var a=r();if(a&&a.then){if(!F(a)){n=1;break}a=a.s}if(t){var o=t();if(o&&o.then&&!F(o)){n=2;break}}}var s=new T,f=U.bind(null,s,2);return(0===n?i.then(u):1===n?a.then(c):o.then(l)).then(void 0,f),s;function c(n){a=n;do{if(t&&(o=t())&&o.then&&!F(o))return void o.then(l).then(void 0,f);if(!(i=e())||F(i)&&!i.v)return void U(s,1,a);if(i.then)return void i.then(u).then(void 0,f);F(a=r())&&(a=a.v)}while(!a||!a.then);a.then(c).then(void 0,f)}function u(e){e?(a=r())&&a.then?a.then(c).then(void 0,f):c(a):U(s,1,a)}function l(){(i=e())?i.then?i.then(u).then(void 0,f):u(i):U(s,1,a)}}(function(){return!r&&a<=e},void 0,function(){return Promise.resolve(i.delay(1e3*t)).then(function(){return Promise.resolve(i.bundler.getUserOperationReceipt(i.userOperationHash)).then(function(e){if(null!=e)return r=1,e;a++})})});return Promise.resolve(o&&o.then?o.then(n):n(o))}catch(e){return Promise.reject(e)}},e}(),w=/*#__PURE__*/function(t){function r(e,n,i){var a;return void 0===n&&(n=r.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===i&&(i=r.DEFAULT_ENTRYPOINT_ADDRESS),(a=t.call(this,e)||this).entrypointAddress=void 0,a.safe4337ModuleAddress=void 0,a.initCode=void 0,a.entrypointAddress=i,a.safe4337ModuleAddress=n,a.initCode=null,a}f(r,t),r.initializeNewAccount=function(e,t){void 0===t&&(t={});var n=r.createAccountAddressAndInitCode(e,t),i=n[1],a=new r(n[0]);return a.initCode=i,a},r.createAccountAddressAndInitCode=function(e,t){var n,i,a,o,s;if(void 0===t&&(t={}),e.length<1)throw RangeError("There should be at least one owner");var f=null!=(n=t.threshold)?n:1,c=null!=(i=t.c2Nonce)?i:0n,u=null!=(a=t.singletonAddress)?a:r.DEFAULT_SINGLETON_ADDRESS,l=null!=(o=t.safe4337ModuleAddress)?o:r.DEFAULT_SAFE_4337_MODULE_ADDRESS,d=null!=(s=t.addModuleLibAddress)?s:r.DEFAULT_ADD_MODULE_LIB_ADDRESS,p=new x;null!=t.safeAccountFactoryAddress&&(p=new x(t.safeAccountFactoryAddress));var h=r.createInitializerCallData(e,f,l,d);return[this.createProxyAddress(h,c,p.address,u),p.getFactoryGeneratorFunctionCallData([u,h,c])]},r.createInitializerCallData=function(e,t,n,i){if(void 0===n&&(n=r.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===i&&(i=r.DEFAULT_ADD_MODULE_LIB_ADDRESS),e.length<1)throw RangeError("There should be at least one owner");if(t<1)throw RangeError("threshold should be at least one");if(t>e.length)throw RangeError("threshold can't be larger than number of owners");var a=P("0x8d0dc49f",["address[]"],[[n]]);return P(r.initializerFunctionSelector,r.initializerFunctionInputAbi,[e,t,i,a,n,b,0,b])},r.createInitCode=function(e,t,n,i,a,o,s){if(void 0===t&&(t=1),void 0===n&&(n=0n),void 0===i&&(i=r.DEFAULT_SINGLETON_ADDRESS),void 0===a&&(a=new x),void 0===o&&(o=r.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===s&&(s=r.DEFAULT_ADD_MODULE_LIB_ADDRESS),e.length<1)throw RangeError("There should be at least one owner");if(t<1)throw RangeError("threshold should be at least one");if(t>e.length)throw RangeError("threshold can't be larger than number of owners");if(n<0n)throw RangeError("c2Nonce can't be negative");var f=r.createInitializerCallData(e,t,o,s);return a.getFactoryGeneratorFunctionCallData([i,f,n])},r.createProxyAddress=function(t,r,n,i){if(r<0n)throw RangeError("c2Nonce can't be negative");var a=e.AbiCoder.defaultAbiCoder(),o=e.keccak256(e.solidityPacked(["bytes32","uint256"],[e.keccak256(t),r])),s=a.encode(["uint256"],[i]),f=e.keccak256(e.solidityPacked(["bytes","bytes"],[this.proxyByteCode,s]));return"0x"+e.solidityPackedKeccak256(["bytes1","address","bytes32","bytes32"],["0xff",n,o,f]).slice(-40)},r.createAccountCallDataSingleTransaction=function(e){var t,n,i,a=null!=(t=e.value)?t:0,o=null!=(n=e.data)?n:"0x",s=null!=(i=e.operation)?i:exports.Operation.Call;return r.createAccountCallData(e.to,a,o,s)},r.createAccountCallDataBatchTransactions=function(e,t){if(void 0===t&&(t=r.DEFAULT_MULTISEND_CONTRACT_ADDRESS),e.length<1)throw RangeError("There should be at least one metaTransaction");var n=P("0x8d80ff0a",["bytes"],[R(e)]);return r.createAccountCallData(t,0n,n,exports.Operation.Delegate)},r.createAccountCallData=function(e,t,n,i,a){return void 0===a&&(a=r.DEFAULT_EXECUTOR_FUCNTION_SELECTOR),P(a,r.executorFunctionInputAbi,[e,t,n,i])};var i=r.prototype;return i.decodeAccountCallData=function(t){if(t.startsWith(E.executeUserOpWithErrorString)||t.startsWith(E.executeUserOp)){var r=e.AbiCoder.defaultAbiCoder(),n="0x"+t.slice(10),i=r.decode(["address","uint256","bytes","uint8"],n);return[i[0],BigInt(i[1]),i[2],Number(i[3])]}throw new h("BAD_DATA","Invalid calldata, should start with "+E.executeUserOpWithErrorString+" or "+E.executeUserOp,{context:{callData:t}})},i.prependTokenPaymasterApproveToCallData=function(t,n,i,a,o){void 0===o&&(o=r.DEFAULT_MULTISEND_CONTRACT_ADDRESS);var s=this.decodeAccountCallData(t),f=s[0],c=s[1],u=s[2],l=s[3],d="";d="string"!=typeof u?(new TextDecoder).decode(u):u;var p=R([{to:n,value:0n,data:P(g("approve(address,uint256)"),["address","uint256"],[i,a]),operation:exports.Operation.Call}]),h="",v="0x8d80ff0a";if(d.startsWith(v)){var m=function(t){return e.AbiCoder.defaultAbiCoder().decode(["bytes"],"0x"+t.slice(10))[0]}(d);h=m+p.slice(2)}else h=R([{to:f,value:c,data:u,operation:l}])+p.slice(2);var y=P(v,["bytes"],[h]);return r.createAccountCallData(o,0n,y,exports.Operation.Delegate)},i.estimateUserOperationGas=function(e,t,r,n){void 0===n&&(n=1);try{if(n<0n)throw RangeError("numberOfSigners can't be negative");for(var i="",a=0;a<n;a++)i+="ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff";e.signature="0xffffffffffffffffffffffff"+i;var o=new S(t);return Promise.resolve(o.estimateUserOperationGas(e,this.entrypointAddress,r)).then(function(e){return[BigInt(e.preVerificationGas),BigInt(e.verificationGasLimit)+5000n,BigInt(e.callGasLimit)]})}catch(e){return Promise.reject(e)}},i.createUserOperation=function(t,i,a,o){void 0===o&&(o={});try{var f=function(){var f;function l(){var e,t;function r(){var e,t,r;if("bigint"==typeof o.preVerificationGas&&o.preVerificationGas<0n)throw RangeError("preVerificationGas overrid can't be negative");if("bigint"==typeof o.verificationGasLimit&&o.verificationGasLimit<0n)throw RangeError("verificationGasLimit overrid can't be negative");if("bigint"==typeof o.callGasLimit&&o.callGasLimit<0n)throw RangeError("callGasLimit overrid can't be negative");return n.preVerificationGas=null!=(e=o.preVerificationGas)?e:i,n.verificationGasLimit=null!=(t=o.verificationGasLimit)?t:f,n.callGasLimit=null!=(r=o.callGasLimit)?r:l,n}if("bigint"==typeof o.maxFeePerGas&&o.maxFeePerGas<0n)throw RangeError("maxFeePerGas overrid can't be negative");if("bigint"==typeof o.maxPriorityFeePerGas&&o.maxPriorityFeePerGas<0n)throw RangeError("maxPriorityFeePerGas overrid can't be negative");h=null!=(e=o.maxFeePerGas)?e:h,v=null!=(t=o.maxPriorityFeePerGas)?t:v;var n=s({},G,{sender:c.accountAddress,nonce:u,initCode:d,callData:p,maxFeePerGas:h,maxPriorityFeePerGas:v}),i=G.preVerificationGas,f=G.verificationGasLimit,l=G.callGasLimit,m=function(){if(null==o.preVerificationGas||null==o.verificationGasLimit||null==o.callGasLimit)return Promise.resolve(c.estimateUserOperationGas(n,a,o.state_override_set,o.numberOfSigners)).then(function(e){i=e[0],f=e[1],l=e[2]})}();return m&&m.then?m.then(r):r()}var d=null!=(f=o.initCode)?f:c.initCode;if((null==d||u>0n)&&(d="0x"),u<0n)throw RangeError("nonce can't be negative");var p="0x";p=null==o.callData?1==t.length?r.createAccountCallDataSingleTransaction(t[0]):r.createAccountCallDataBatchTransactions(t):o.callData;var h=G.maxFeePerGas,v=G.maxPriorityFeePerGas,m=function(){if(null==o.maxFeePerGas||null==o.maxPriorityFeePerGas)return Promise.resolve(function(t,r){try{void 0===r&&(r=n.Medium);var i=new e.JsonRpcProvider(t);return Promise.resolve(i.getFeeData()).then(function(e){return[BigInt(Math.ceil(Number(e.maxFeePerGas)*r)),BigInt(Math.ceil(Number(e.maxPriorityFeePerGas)*r))]})}catch(e){return Promise.reject(e)}}(i)).then(function(e){h=e[0],v=e[1]})}();return m&&m.then?m.then(l):l()},c=this;if(t.length<1)throw RangeError("There should be at least one transaction");var u=0n,l=function(){if(null==o.nonce)return Promise.resolve(m(i,c.entrypointAddress,c.accountAddress)).then(function(e){u=e});u=o.nonce}();return Promise.resolve(l&&l.then?l.then(f):f())}catch(e){return Promise.reject(e)}},i.signUserOperation=function(t,r,n,i,a){if(void 0===i&&(i=0n),void 0===a&&(a=0n),r.length<1)throw RangeError("There should be at least one privateKey");if(n<0n)throw RangeError("chainId can't be negative");if(i<0n)throw RangeError("validAfter can't be negative");if(a<0n)throw RangeError("validUntil can't be negative");for(var o,s={safe:t.sender,nonce:t.nonce,initCode:t.initCode,callData:t.callData,callGasLimit:t.callGasLimit,verificationGasLimit:t.verificationGasLimit,preVerificationGas:t.preVerificationGas,maxFeePerGas:t.maxFeePerGas,maxPriorityFeePerGas:t.maxPriorityFeePerGas,paymasterAndData:t.paymasterAndData,validAfter:i,validUntil:a,entryPoint:this.entrypointAddress},f={SafeOp:[{type:"address",name:"safe"},{type:"uint256",name:"nonce"},{type:"bytes",name:"initCode"},{type:"bytes",name:"callData"},{type:"uint256",name:"callGasLimit"},{type:"uint256",name:"verificationGasLimit"},{type:"uint256",name:"preVerificationGas"},{type:"uint256",name:"maxFeePerGas"},{type:"uint256",name:"maxPriorityFeePerGas"},{type:"bytes",name:"paymasterAndData"},{type:"uint48",name:"validAfter"},{type:"uint48",name:"validUntil"},{type:"address",name:"entryPoint"}]},c="0x",u=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return d(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?d(e,t):void 0}}(e))){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(r);!(o=u()).done;)c+=new e.Wallet(o.value).signingKey.sign(e.TypedDataEncoder.hash({chainId:n,verifyingContract:this.safe4337ModuleAddress},f,s)).serialized.slice(2);return e.solidityPacked(["uint48","uint48","bytes"],[i,a,c])},i.sendUserOperation=function(e,t){try{var r=this,n=new S(t);return Promise.resolve(n.sendUserOperation(e,r.entrypointAddress)).then(function(e){return new L(e,n,r.entrypointAddress)})}catch(e){return Promise.reject(e)}},r}(a);function C(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}w.DEFAULT_ENTRYPOINT_ADDRESS="0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",w.DEFAULT_SAFE_4337_MODULE_ADDRESS="0xa581c4A4DB7175302464fF3C06380BC3270b4037",w.DEFAULT_SINGLETON_ADDRESS="0x29fcB43b46531BcA003ddC8FCB67FFE91900C762",w.DEFAULT_ADD_MODULE_LIB_ADDRESS="0x8EcD4ec46D4D2a6B64fE960B3D64e8B94B2234eb",w.DEFAULT_MULTISEND_CONTRACT_ADDRESS="0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526",w.proxyByteCode="0x608060405234801561001057600080fd5b506040516101e63803806101e68339818101604052602081101561003357600080fd5b8101908080519060200190929190505050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156100ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806101c46022913960400191505060405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505060ab806101196000396000f3fe608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea264697066735822122003d1488ee65e08fa41e58e888a9865554c535f2c77126a82cb4c0f917f31441364736f6c63430007060033496e76616c69642073696e676c65746f6e20616464726573732070726f7669646564",w.initializerFunctionSelector="0xb63e800d",w.initializerFunctionInputAbi=["address[]","uint256","address","bytes","address","address","uint256","address"],w.DEFAULT_EXECUTOR_FUCNTION_SELECTOR=E.executeUserOpWithErrorString,w.executorFunctionInputAbi=["address","uint256","bytes","uint8"];var I=/*#__PURE__*/function(e){function t(t){var r;return(r=e.call(this)||this).rpcUrl=void 0,r.entrypointAddress=void 0,r.supportedTokens=void 0,r.paymasterMetadata=void 0,r.rpcUrl=t,r}f(t,e);var r=t.prototype;return r.initialize=function(){try{var e=this;return Promise.resolve(C(function(){return Promise.resolve(e.getSupportedEntrypoint()).then(function(t){return e.entrypointAddress=t,Promise.resolve(e.getSupportedERC20TokensAndPaymasterMetadata()).then(function(t){return e.supportedTokens=t.tokens,e.paymasterMetadata=t.paymasterMetadata,null})})},function(e){var t=v(e);throw new h("PAYMASTER_ERROR","failed initializing the paymaster",{cause:t})}))}catch(e){return Promise.reject(e)}},r.getPaymasterMetaData=function(){try{var e=function(){return t.paymasterMetadata},t=this,r=function(){if(null==t.paymasterMetadata)return Promise.resolve(t.initialize()).then(function(){})}();return Promise.resolve(r&&r.then?r.then(e):e())}catch(e){return Promise.reject(e)}},r.getSupportedERC20TokensAndPaymasterMetadata=function(){try{var e=this;return Promise.resolve(null==e.supportedTokens||null==e.paymasterMetadata?C(function(){return Promise.resolve(y(e.rpcUrl,"pm_supportedERC20Tokens",[])).then(function(e){return{tokens:e.tokens,paymasterMetadata:e.paymasterMetadata}})},function(e){var t=v(e);throw new h("PAYMASTER_ERROR","getSupportedERC20TokensAndPaymasterMetadata failed",{cause:t})}):{tokens:e.supportedTokens,paymasterMetadata:e.paymasterMetadata})}catch(e){return Promise.reject(e)}},r.getSupportedEntrypoint=function(){try{var e=this;return Promise.resolve(null==e.entrypointAddress?C(function(){return Promise.resolve(y(e.rpcUrl,"pm_supportedEntryPoint",[]))},function(e){var t=v(e);throw new h("PAYMASTER_ERROR","getSupportedEntrypoint failed",{cause:t})}):e.entrypointAddress)}catch(e){return Promise.reject(e)}},r.isSupportedERC20Token=function(e){try{var t=function(){return!!r.supportedTokens.find(function(t){return t.address===e.toLowerCase()})},r=this,n=function(){if(null==r.entrypointAddress||null==r.supportedTokens||null==r.paymasterMetadata)return Promise.resolve(r.initialize()).then(function(){})}();return Promise.resolve(n&&n.then?n.then(t):t())}catch(e){return Promise.reject(e)}},r.getSupportedERC20TokenData=function(e){try{var t=function(){var t=r.supportedTokens.find(function(t){return t.address.toLowerCase()===e.toLowerCase()});return t?{symbol:t.symbol,address:t.address,decimal:Number(t.decimal),fee:BigInt(t.fee),exchangeRate:BigInt(t.exchangeRate)}:null},r=this,n=function(){if(null==r.entrypointAddress||null==r.supportedTokens||null==r.paymasterMetadata)return Promise.resolve(r.initialize()).then(function(){})}();return Promise.resolve(n&&n.then?n.then(t):t())}catch(e){return Promise.reject(e)}},r.createPaymasterUserOperation=function(e,t,r,n){void 0===r&&(r={});try{var i=function(){return C(function(){e.paymasterAndData=a.paymasterMetadata.dummyPaymasterAndData;var i=new S(t);return Promise.resolve(i.estimateUserOperationGas(e,a.entrypointAddress,n)).then(function(t){return e.preVerificationGas=t.preVerificationGas,e.verificationGasLimit=t.verificationGasLimit+10000n,e.callGasLimit=t.callGasLimit,Promise.resolve(y(a.rpcUrl,"pm_sponsorUserOperation",[e,a.entrypointAddress,r])).then(function(t){var r,n,i,a,o,s=t,f={paymasterAndData:s.paymasterAndData,callGasLimit:null==s.callGasLimit?void 0:BigInt(s.callGasLimit),preVerificationGas:null==s.preVerificationGas?void 0:BigInt(s.preVerificationGas),verificationGasLimit:null==s.verificationGasLimit?void 0:BigInt(s.verificationGasLimit),maxFeePerGas:null==s.maxFeePerGas?void 0:BigInt(s.maxFeePerGas),maxPriorityFeePerGas:null==s.maxPriorityFeePerGas?void 0:BigInt(s.maxPriorityFeePerGas)};return e.paymasterAndData=f.paymasterAndData,e.callGasLimit=null!=(r=f.callGasLimit)?r:e.callGasLimit,e.preVerificationGas=null!=(n=f.preVerificationGas)?n:e.preVerificationGas,e.verificationGasLimit=null!=(i=f.verificationGasLimit)?i:e.verificationGasLimit,e.maxFeePerGas=null!=(a=f.maxFeePerGas)?a:e.maxFeePerGas,e.maxPriorityFeePerGas=null!=(o=f.maxPriorityFeePerGas)?o:e.maxPriorityFeePerGas,e})})},function(e){var t=v(e);throw new h("PAYMASTER_ERROR","pm_sponsorUserOperation failed",{cause:t})})},a=this,o=function(){if(null==a.entrypointAddress||null==a.supportedTokens||null==a.paymasterMetadata)return Promise.resolve(a.initialize()).then(function(){})}();return Promise.resolve(o&&o.then?o.then(i):i())}catch(e){return Promise.reject(e)}},r.createSponsorPaymasterUserOperation=function(e,t,r){try{return Promise.resolve(this.createPaymasterUserOperation(e,t,{},r))}catch(e){return Promise.reject(e)}},r.createTokenPaymasterUserOperation=function(e,t,r,n,i){void 0===i&&(i={});try{var a=this;return Promise.resolve(a.calculateUserOperationErc20TokenMaxGasCost(t,r)).then(function(o){var s=2n*o;return Promise.resolve(a.getPaymasterMetaData()).then(function(o){var f=e.prependTokenPaymasterApproveToCallData(t.callData,r,o.address,s);return t.callData=f,Promise.resolve(a.createPaymasterUserOperation(t,n,{token:r},i))})})}catch(e){return Promise.reject(e)}},r.calculateUserOperationErc20TokenMaxGasCost=function(e,t){try{var r=this;return Promise.resolve(r.getSupportedERC20TokenData(t)).then(function(n){if(null==n)return Promise.resolve(r.getSupportedERC20TokensAndPaymasterMetadata()).then(function(e){throw new h("PAYMASTER_ERROR",t+" token is not supported by the paymaster.",{context:{supportedERC20TokensAndPaymasterMetadata:JSON.stringify(e)}})});var i=D(e);return n.exchangeRate*i/BigInt(Math.pow(10,18))})}catch(e){return Promise.reject(e)}},t}(function(){}),N={__proto__:null,SmartAccount:a,SafeAccountV0_2_0:w,SendUseroperationResponse:L,SmartAccountFactory:O,SafeAccountFactory:x,Bundler:S,CandidePaymaster:I,createUserOperationHash:A,createCallData:P,getFunctionSelector:g,fetchAccountNonce:m,calculateUserOperationMaxGasCost:D,get Operation(){return exports.Operation}};exports.Bundler=S,exports.CandidePaymaster=I,exports.SafeAccountFactory=x,exports.SafeAccountV0_2_0=w,exports.SendUseroperationResponse=L,exports.SmartAccount=a,exports.SmartAccountFactory=O,exports.abstractionkit=N,exports.calculateUserOperationMaxGasCost=D,exports.createCallData=P,exports.createUserOperationHash=A,exports.fetchAccountNonce=m,exports.getFunctionSelector=g;

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

import*as t from"isomorphic-unfetch";import{keccak256 as e,AbiCoder as r,id as n,ethers as i,ZeroAddress as a,solidityPacked as f,solidityPackedKeccak256 as c}from"ethers";var o=function(e,r,n){try{var i=t.default||t,a=JSON.stringify({method:r,params:n,id:1,jsonrpc:"2.0"});return Promise.resolve(i(e,{method:"POST",body:a,redirect:"follow"})).then(function(t){return Promise.resolve(t.json())})}catch(t){return Promise.reject(t)}};function s(t,n,i){var a=e(function(t){var n=[t.sender,t.nonce,e(t.initCode),e(t.callData),t.callGasLimit,t.verificationGasLimit,t.preVerificationGas,t.maxFeePerGas,t.maxPriorityFeePerGas,e(t.paymasterAndData)];return r.defaultAbiCoder().encode(["address","uint256","bytes32","bytes32","uint256","uint256","uint256","uint256","uint256","bytes32"],n)}(t)),f=r.defaultAbiCoder().encode(["bytes32","address","uint256"],[a,n,i]);return e(f)}function d(t,e,n){return t+r.defaultAbiCoder().encode(e,n).slice(2)}function u(t){return n(t).slice(0,10)}var b,l=/*#__PURE__*/function(){function t(t,e,r,n,i,a){this.singletonAddress=void 0,this.proxyByteCode=void 0,this.initializerFunctionSelector=void 0,this.initializerFunctionInputAbi=void 0,this.executorFunctionSelector=void 0,this.executorFunctionInputAbi=void 0,this.singletonAddress=t,this.proxyByteCode=e,this.initializerFunctionSelector=r,this.initializerFunctionInputAbi=n,this.executorFunctionSelector=i,this.executorFunctionInputAbi=a}var e=t.prototype;return e.getInitializerCallData=function(t){return d(this.initializerFunctionSelector,this.initializerFunctionInputAbi,t)},e.getExecutorCallData=function(t){return d(this.executorFunctionSelector,this.executorFunctionInputAbi,t)},t}();function h(){return h=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},h.apply(this,arguments)}function p(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,y(t,e)}function y(t,e){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},y(t,e)}!function(t){t[t.Call=0]="Call",t[t.Delegate=1]="Delegate"}(b||(b={}));var x=/*#__PURE__*/function(){function t(t,e,r){this.address=void 0,this.generatorFunctionSelector=void 0,this.generatorFunctionInputAbi=void 0,this.address=t,this.generatorFunctionSelector=e,this.generatorFunctionInputAbi=r}return t.prototype.getFactoryGeneratorFunctionCallData=function(t){var e=d(this.generatorFunctionSelector,this.generatorFunctionInputAbi,t);return this.address+e.slice(2)},t}(),v=/*#__PURE__*/function(t){function e(e){return void 0===e&&(e="0xb73Eb505Abc30d0e7e15B73A492863235B3F4309"),t.call(this,e,"0x1688f0b9",["address","bytes","uint256"])||this}return p(e,t),e}(x);function m(t){return"0x"+t.map(function(t){return function(t){var e=i.getBytes(t.data);return i.solidityPacked(["uint8","address","uint256","uint256","bytes"],[t.operation,t.to,t.value,e.length,e]).slice(2)}(t)}).join("")}var A=/*#__PURE__*/function(t){function r(e,r,n){var i;return void 0===e&&(e="0x3A0a17Bcc84576b099373ab3Eed9702b07D30402"),void 0===r&&(r="0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"),void 0===n&&(n=new v),(i=t.call(this,e,"0x608060405234801561001057600080fd5b5060405161017338038061017383398101604081905261002f916100b9565b6001600160a01b0381166100945760405162461bcd60e51b815260206004820152602260248201527f496e76616c69642073696e676c65746f6e20616464726573732070726f766964604482015261195960f21b606482015260840160405180910390fd5b600080546001600160a01b0319166001600160a01b03929092169190911790556100e9565b6000602082840312156100cb57600080fd5b81516001600160a01b03811681146100e257600080fd5b9392505050565b607c806100f76000396000f3fe6080604052600080546001600160a01b0316813563530ca43760e11b1415602857808252602082f35b3682833781823684845af490503d82833e806041573d82fd5b503d81f3fea2646970667358221220022b6bb97dd1e16cb867add83d4159f7550336cbb5b40514145e43f493c1377664736f6c634300080c0033","0x6a1e9826",["address[]","uint256","address","bytes","address","address","uint256","address","address"],"0xf34308ef",["address","uint256","bytes","uint8","address","address","uint256"])||this).entrypointAddress=void 0,i.candideAccountFactory=void 0,i.entrypointAddress=r,i.candideAccountFactory=n,i}p(r,t);var n=r.prototype;return n.createNewAccount=function(t,e,r,n){void 0===e&&(e=1),void 0===r&&(r=0),void 0===n&&(n="0x2a15DE4410d4c8af0A7b6c12803120f43C42B820");var i=this.getInitializerCallData([t,e,a,"0x",n,a,0,a,this.entrypointAddress]);return[this.getProxyAddress(i,this.candideAccountFactory.address,r),this.candideAccountFactory.getFactoryGeneratorFunctionCallData([this.singletonAddress,i,r])]},n.createSendEthCallData=function(t,e){return this.createCallData(t,e,"0x",0,a,a,0)},n.createCallData=function(t,e,r,n,i,a,f){return this.getExecutorCallData([t,e,r,n,i,a,f])},n.getProxyAddress=function(t,r,n){var i=e(f(["bytes32","uint256"],[e(t),n])),a=e(f(["bytes","uint256"],[this.proxyByteCode,this.singletonAddress]));return"0x"+c(["bytes1","address","bytes32","bytes32"],["0xff",r,i,a]).slice(-40)},n.createCallDataSingleTransactionWithPaymaster=function(t,e,r,n){return this.getExecutorCallData([t.to,t.value,t.data,t.operation,e,r,n])},n.createCallDataSingleTransaction=function(t){return this.createCallDataSingleTransactionWithPaymaster(t,a,a,0)},n.createCallDataBatchTransactionWithPaymaster=function(t,e,r,n){var i=d("0x8d80ff0a",["bytes"],[m(t)]);return this.getExecutorCallData(["0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526",0,i,b.Delegate,e,r,n])},n.createCallDataBatchTransaction=function(t){return this.createCallDataBatchTransactionWithPaymaster(t,a,a,0)},r}(l),g=/*#__PURE__*/function(t){function e(e){return void 0===e&&(e="0x9406Cc6185a346906296840746125a0E44976454"),t.call(this,e,"0x5fbfb9cf",["address","uint256"])||this}return p(e,t),e}(x),F=/*#__PURE__*/function(t){function n(e,r,n){var i;return void 0===e&&(e="0x8ABB13360b87Be5EEb1B98647A016adD927a136c"),void 0===r&&(r="0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"),void 0===n&&(n=new g),(i=t.call(this,e,"0x60806040526040516107c13803806107c183398101604081905261002291610321565b61002e82826000610035565b505061043e565b61003e8361006b565b60008251118061004b5750805b156100665761006483836100ab60201b6100291760201c565b505b505050565b610074816100d7565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606100d0838360405180606001604052806027815260200161079a602791396101a9565b9392505050565b6100ea8161022260201b6100551760201c565b6101515760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084015b60405180910390fd5b806101887f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b61023160201b6100711760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b6060600080856001600160a01b0316856040516101c691906103ef565b600060405180830381855af49150503d8060008114610201576040519150601f19603f3d011682016040523d82523d6000602084013e610206565b606091505b50909250905061021886838387610234565b9695505050505050565b6001600160a01b03163b151590565b90565b606083156102a357825160000361029c576001600160a01b0385163b61029c5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610148565b50816102ad565b6102ad83836102b5565b949350505050565b8151156102c55781518083602001fd5b8060405162461bcd60e51b8152600401610148919061040b565b634e487b7160e01b600052604160045260246000fd5b60005b838110156103105781810151838201526020016102f8565b838111156100645750506000910152565b6000806040838503121561033457600080fd5b82516001600160a01b038116811461034b57600080fd5b60208401519092506001600160401b038082111561036857600080fd5b818501915085601f83011261037c57600080fd5b81518181111561038e5761038e6102df565b604051601f8201601f19908116603f011681019083821181831017156103b6576103b66102df565b816040528281528860208487010111156103cf57600080fd5b6103e08360208301602088016102f5565b80955050505050509250929050565b600082516104018184602087016102f5565b9190910192915050565b602081526000825180602084015261042a8160408501602087016102f5565b601f01601f19169190910160400192915050565b61034d8061044d6000396000f3fe60806040523661001357610011610017565b005b6100115b610027610022610074565b6100b9565b565b606061004e83836040518060600160405280602781526020016102f1602791396100dd565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b90565b60006100b47f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5473ffffffffffffffffffffffffffffffffffffffff1690565b905090565b3660008037600080366000845af43d6000803e8080156100d8573d6000f35b3d6000fd5b60606000808573ffffffffffffffffffffffffffffffffffffffff16856040516101079190610283565b600060405180830381855af49150503d8060008114610142576040519150601f19603f3d011682016040523d82523d6000602084013e610147565b606091505b509150915061015886838387610162565b9695505050505050565b606083156101fd5782516000036101f65773ffffffffffffffffffffffffffffffffffffffff85163b6101f6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064015b60405180910390fd5b5081610207565b610207838361020f565b949350505050565b81511561021f5781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101ed919061029f565b60005b8381101561026e578181015183820152602001610256565b8381111561027d576000848401525b50505050565b60008251610295818460208701610253565b9190910192915050565b60208152600082518060208401526102be816040850160208701610253565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212201cd78ab6a31213989661cff2d7d05fc9b9c38b1a848e8249e2e398659a9eb7e364736f6c634300080f0033416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564","0xc4d66de8",["address"],"0xb61d27f6",["address","uint256","bytes"])||this).entrypointAddress=void 0,i.simpleAccountFactory=void 0,i.batchExecutorFunctionSelector=void 0,i.batchExecutorFunctionInputAbi=void 0,i.entrypointAddress=r,i.simpleAccountFactory=n,i.batchExecutorFunctionSelector="0x18dfb3c7",i.batchExecutorFunctionInputAbi=["address[]","bytes[]"],i}p(n,t);var i=n.prototype;return i.createNewAccount=function(t,e){void 0===e&&(e=0);var r=this.getInitializerCallData([t]),n=this.simpleAccountFactory.getFactoryGeneratorFunctionCallData([t,e]);return[this.getProxyAddress(r,this.simpleAccountFactory.address,e),n]},i.getProxyAddress=function(t,n,i){var a=r.defaultAbiCoder(),o=a.encode(["uint256"],[i]),s=a.encode(["address","bytes"],[this.singletonAddress,t]),d=e(f(["bytes","bytes"],[this.proxyByteCode,s]));return"0x"+c(["bytes1","address","bytes32","bytes32"],["0xff",n,o,d]).slice(-40)},i.createSendEthCallData=function(t,e){return this.createCallData(t,e,"0x")},i.createCallData=function(t,e,r){return this.getExecutorCallData([t,e,r])},i.createBatchCallData=function(t,e){return d(this.batchExecutorFunctionSelector,this.batchExecutorFunctionInputAbi,[t,e])},n}(l),P=/*#__PURE__*/function(){function t(t,e){this.rpcUrl=void 0,this.entrypointAddress=void 0,this.rpcUrl=t,this.entrypointAddress=e}var e=t.prototype;return e.chainId=function(){try{return Promise.resolve(o(this.rpcUrl,"eth_chainId",[])).then(function(t){return"result"in t?{chainId:t.result}:t.error})}catch(t){return Promise.reject(t)}},e.supportedEntryPoints=function(){try{return Promise.resolve(o(this.rpcUrl,"eth_supportedEntryPoints",[])).then(function(t){return"result"in t?{supportedEntryPoints:t.result}:t.error})}catch(t){return Promise.reject(t)}},e.estimateUserOperationGas=function(t){try{return Promise.resolve(o(this.rpcUrl,"eth_estimateUserOperationGas",[t,this.entrypointAddress])).then(function(t){return"result"in t?t.result:t.error})}catch(t){return Promise.reject(t)}},e.sendUserOperation=function(t){try{return Promise.resolve(o(this.rpcUrl,"eth_sendUserOperation",[t,this.entrypointAddress])).then(function(t){return"result"in t?{userOperationHash:t.result}:t.error})}catch(t){return Promise.reject(t)}},e.getUserOperationReceipt=function(t){try{return Promise.resolve(o(this.rpcUrl,"eth_getUserOperationReceipt",[t])).then(function(t){if("result"in t){var e=t.result,r=h({},e.receipt,{logs:JSON.stringify(e.receipt.logs)});return h({},e,{logs:JSON.stringify(e.logs),receipt:r})}return t.error})}catch(t){return Promise.reject(t)}},e.getUserOperationByHash=function(t){try{return Promise.resolve(o(this.rpcUrl,"eth_getUserOperationByHash",[t])).then(function(t){return"result"in t?t.result:t.error})}catch(t){return Promise.reject(t)}},t}(),C=/*#__PURE__*/function(t){function e(e,r){var n;return(n=t.call(this)||this).rpcUrl=void 0,n.entrypointAddress=void 0,n.rpcUrl=r,n.entrypointAddress=e,n}p(e,t);var r=e.prototype;return r.getSupportedERC20Tokens=function(){try{return Promise.resolve(o(this.rpcUrl,"pm_supportedERC20Tokens",[])).then(function(t){if("result"in t){var e=t.result;return{tokens:e.tokens,paymasterMetadata:e.paymasterMetadata}}return t.error})}catch(t){return Promise.reject(t)}},r.getSupportedEntrypoint=function(){try{return Promise.resolve(o(this.rpcUrl,"pm_supportedEntryPoint",[])).then(function(t){return"result"in t?t.result:t.error})}catch(t){return Promise.reject(t)}},r.getPaymasterCallDataForPayingGasWithErc20=function(t,e){try{var r=this;return Promise.resolve(r.getPaymasterCallData(t,[r.rpcUrl,r.entrypointAddress,e]))}catch(t){return Promise.reject(t)}},r.getPaymasterCallDataForGaslessTx=function(t){try{var e=this;return Promise.resolve(e.getPaymasterCallData(t,[e.rpcUrl,e.entrypointAddress]))}catch(t){return Promise.reject(t)}},r.getPaymasterCallData=function(t,e){try{return Promise.resolve(o(e[0],"pm_sponsorUserOperation",[t,e[1],{token:e[2]}])).then(function(t){return"result"in t?t.result:t.error})}catch(t){return Promise.reject(t)}},e}(function(){}),D={sender:a,nonce:"0x00",initCode:"0x",callData:"0x",callGasLimit:"0x00",verificationGasLimit:"0x00",preVerificationGas:"0x00",maxFeePerGas:"0x00",maxPriorityFeePerGas:"0x00",paymasterAndData:"0x",signature:"0x"},E={sender:a,nonce:"0x00",initCode:"0x",callData:"0x",callGasLimit:"0xffffff",verificationGasLimit:"0xffffff",preVerificationGas:"0xffffff",maxFeePerGas:"0xffffff",maxPriorityFeePerGas:"0xfffffff",paymasterAndData:"0x",signature:"0x"},S={__proto__:null,SmartAccount:l,CandideAccount:A,SimpleAccount:F,SmartAccountFactory:x,CandideAccountFactory:v,SimpleAccountFactory:g,Bundler:P,CandideValidationPaymaster:C,getUserOperationHash:s,getCallData:d,getFunctionSelector:u,UserOperationEmptyValues:D,UserOperationDummyValues:E,get Operation(){return b}};export{P as Bundler,A as CandideAccount,v as CandideAccountFactory,C as CandideValidationPaymaster,b as Operation,F as SimpleAccount,g as SimpleAccountFactory,l as SmartAccount,x as SmartAccountFactory,E as UserOperationDummyValues,D as UserOperationEmptyValues,S as abstractionkit,d as getCallData,u as getFunctionSelector,s as getUserOperationHash};
import{keccak256 as e,AbiCoder as t,id as r,JsonRpcProvider as n,getBytes as i,solidityPacked as a,solidityPackedKeccak256 as o,Wallet as s,TypedDataEncoder as f}from"ethers";import*as c from"isomorphic-unfetch";var u,l,d=function(e){this.accountAddress=void 0,this.accountAddress=e};function p(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(p=function(){return!!e})()}function h(){return h=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},h.apply(this,arguments)}function v(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,y(e,t)}function m(e){return m=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},m(e)}function y(e,t){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},y(e,t)}function A(e){var t="function"==typeof Map?new Map:void 0;return A=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return function(e,t,r){if(p())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,t);var i=new(e.bind.apply(e,n));return r&&y(i,r.prototype),i}(e,arguments,m(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),y(r,e)},A(e)}function P(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}d.proxyByteCode=void 0,d.initializerFunctionSelector=void 0,d.initializerFunctionInputAbi=void 0,d.executorFunctionSelector=void 0,d.executorFunctionInputAbi=void 0,function(e){e[e.Call=0]="Call",e[e.Delegate=1]="Delegate"}(u||(u={})),function(e){e[e.Slow=1]="Slow",e[e.Medium=1.2]="Medium",e[e.Fast=1.5]="Fast"}(l||(l={}));var g={"-32602":"INVALID_FIELDS","-32500":"SIMULATE_VALIDATION","-32501":"SIMULATE_PAYMASTER_VALIDATION","-32502":"OPCODE_VALIDATION","-32503":"EXPIRE_SHORTLY","-32504":"REPUTATION","-32505":"INSUFFICIENT_STAKE","-32506":"UNSUPPORTED_SIGNATURE_AGGREGATOR","-32507":"INVALID_SIGNATURE","-32601":"INVALID_USEROPERATION_HASH","-32521":"EXECUTION_REVERTED"},E=/*#__PURE__*/function(e){function t(t,r,n){var i;void 0===n&&(n={});var a=n.errno,o=n.context;return(i=e.call(this,r,{cause:n.cause})||this).code=void 0,i.context=void 0,i.errno=void 0,i.name=i.constructor.name,i.code=t,i.errno=a,i.context=o,i}return v(t,e),t}(/*#__PURE__*/A(Error));function D(e){if(e instanceof Error)return e;var t="[Unable to stringify the thrown value]";try{t=JSON.stringify(e)}catch(e){}return new Error("This value was thrown as is, not through an Error: "+t)}var b=function(e,t,r,n){void 0===n&&(n=0);try{var i=[{from:"0x0000000000000000000000000000000000000000",to:t,data:O(_("getNonce(address,uint192)"),["address","uint192"],[r,n])},"latest"];return Promise.resolve(function(t,r){try{var n=Promise.resolve(G(e,"eth_call",i)).then(function(e){if("string"!=typeof e)throw new E("BAD_DATA","getNonce returned ill formed data",{context:JSON.stringify(e)});try{return BigInt(e)}catch(e){var t=D(e);throw new E("BAD_DATA","getNonce returned ill formed data",{cause:t})}})}catch(e){return r(e)}return n&&n.then?n.then(void 0,r):n}(0,function(e){var t=D(e);throw new E("BAD_DATA","getNonce failed",{cause:t})}))}catch(e){return Promise.reject(e)}},G=function(e,t,r){try{var n=c.default||c,i={method:"POST",body:JSON.stringify({method:t,params:r,id:(new Date).getTime(),jsonrpc:"2.0"},function(e,t){return"bigint"==typeof t?"0x"+t.toString(16):t}),redirect:"follow"};return Promise.resolve(n(e,i)).then(function(t){return Promise.resolve(t.json()).then(function(t){if("result"in t)return t.result;var r=t.error,n=String(r.code);throw new E(n in g?g[n]:"UNKNOWN_ERROR",r.message,{errno:r.code,context:{url:e,requestOptions:JSON.stringify(i)}})})})}catch(e){return Promise.reject(e)}};function R(r,n,i){var a=e(function(r){var n=[r.sender,r.nonce,e(r.initCode),e(r.callData),r.callGasLimit,r.verificationGasLimit,r.preVerificationGas,r.maxFeePerGas,r.maxPriorityFeePerGas,e(r.paymasterAndData)];return t.defaultAbiCoder().encode(["address","uint256","bytes32","bytes32","uint256","uint256","uint256","uint256","uint256","bytes32"],n)}(r)),o=t.defaultAbiCoder().encode(["bytes32","address","uint256"],[a,n,i]);return e(o)}function O(e,r,n){return e+t.defaultAbiCoder().encode(r,n).slice(2)}function _(e){return r(e).slice(0,10)}function S(e){return(e.callGasLimit+e.verificationGasLimit*("0x"==e.paymasterAndData||null==e.paymasterAndData?3n:0n)+e.preVerificationGas)*e.maxFeePerGas}var U,x="0x0000000000000000000000000000000000000000",T={sender:x,nonce:0n,initCode:"0x",callData:"0x",callGasLimit:0xffffffn,verificationGasLimit:0xffffffn,preVerificationGas:0xffffffn,maxFeePerGas:0xffffffn,maxPriorityFeePerGas:0xfffffffn,paymasterAndData:"0x",signature:"0x"},F=/*#__PURE__*/function(){function e(e,t,r){this.address=void 0,this.generatorFunctionSelector=void 0,this.generatorFunctionInputAbi=void 0,this.address=e,this.generatorFunctionSelector=t,this.generatorFunctionInputAbi=r}return e.prototype.getFactoryGeneratorFunctionCallData=function(e){var t=O(this.generatorFunctionSelector,this.generatorFunctionInputAbi,e);return this.address+t.slice(2)},e}(),L=/*#__PURE__*/function(e){function t(t){return void 0===t&&(t="0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67"),e.call(this,t,"0x1688f0b9",["address","bytes","uint256"])||this}return v(t,e),t}(F);function w(e){return"0x"+e.map(function(e){return n=null!=(r=(t=e).operation)?r:u.Call,o=i(t.data),a(["uint8","address","uint256","uint256","bytes"],[n,t.to,t.value,o.length,o]).slice(2);var t,r,n,o}).join("")}function I(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}!function(e){e.executeUserOpWithErrorString="0x541d63c8",e.executeUserOp="0x7bb37428"}(U||(U={}));var C=/*#__PURE__*/function(){function e(e){this.rpcUrl=void 0,this.rpcUrl=e}var t=e.prototype;return t.chainId=function(){try{var e=this;return Promise.resolve(I(function(){return Promise.resolve(G(e.rpcUrl,"eth_chainId",[])).then(function(e){if("string"==typeof e)return e;throw new E("BAD_DATA","bundler eth_chainId rpc call failed")})},function(e){var t=D(e);throw new E("BUNDLER_ERROR","bundler eth_chainId rpc call failed",{cause:t})}))}catch(e){return Promise.reject(e)}},t.supportedEntryPoints=function(){try{var e=this;return Promise.resolve(I(function(){return Promise.resolve(G(e.rpcUrl,"eth_supportedEntryPoints",[]))},function(e){var t=D(e);throw new E("BUNDLER_ERROR","bundler eth_supportedEntryPoints rpc call failed",{cause:t})}))}catch(e){return Promise.reject(e)}},t.estimateUserOperationGas=function(e,t,r){try{var n=this;return Promise.resolve(I(function(){function i(){var e=a;return{callGasLimit:BigInt(e.callGasLimit),preVerificationGas:BigInt(e.preVerificationGas),verificationGasLimit:BigInt(e.verificationGasLimit)}}var a={},o=void 0===r?Promise.resolve(G(n.rpcUrl,"eth_estimateUserOperationGas",[e,t])).then(function(e){a=e}):Promise.resolve(G(n.rpcUrl,"eth_estimateUserOperationGas",[e,t,r])).then(function(e){a=e});return o&&o.then?o.then(i):i()},function(e){var t=D(e);throw new E("BUNDLER_ERROR","bundler eth_estimateUserOperationGas rpc call failed",{cause:t})}))}catch(e){return Promise.reject(e)}},t.sendUserOperation=function(e,t){try{var r=this;return Promise.resolve(I(function(){return Promise.resolve(G(r.rpcUrl,"eth_sendUserOperation",[e,t]))},function(e){var t=D(e);throw new E("BUNDLER_ERROR","bundler eth_sendUserOperation rpc call failed",{cause:t})}))}catch(e){return Promise.reject(e)}},t.getUserOperationReceipt=function(e){try{var t=this;return Promise.resolve(I(function(){return Promise.resolve(G(t.rpcUrl,"eth_getUserOperationReceipt",[e])).then(function(e){var t=e;if(null!=t){var r=h({},t.receipt,{blockNumber:BigInt(t.receipt.blockNumber),cumulativeGasUsed:BigInt(t.receipt.cumulativeGasUsed),gasUsed:BigInt(t.receipt.gasUsed),transactionIndex:BigInt(t.receipt.transactionIndex),effectiveGasPrice:null==t.receipt.effectiveGasPrice?void 0:BigInt(t.receipt.effectiveGasPrice),logs:JSON.stringify(t.receipt.logs)});return h({},t,{nonce:BigInt(t.nonce),actualGasCost:BigInt(t.actualGasCost),actualGasUsed:BigInt(t.actualGasUsed),logs:JSON.stringify(t.logs),receipt:r})}return null})},function(t){var r=D(t);throw new E("BUNDLER_ERROR","bundler eth_getUserOperationReceipt rpc call failed",{cause:r,context:{useroperationhash:e}})}))}catch(e){return Promise.reject(e)}},t.getUserOperationByHash=function(e){try{var t=this;return Promise.resolve(I(function(){return Promise.resolve(G(t.rpcUrl,"eth_getUserOperationByHash",[e])).then(function(e){return null!=e?h({},e,{blockNumber:null==e.blockNumber?null:BigInt(e.blockNumber)}):null})},function(t){var r=D(t);throw new E("BUNDLER_ERROR","bundler eth_getUserOperationByHash rpc call failed",{cause:r,context:{useroperationhash:e}})}))}catch(e){return Promise.reject(e)}},e}();function N(e,t,r){if(!e.s){if(r instanceof B){if(!r.s)return void(r.o=N.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(N.bind(null,e,t),N.bind(null,e,2));e.s=t,e.v=r;const n=e.o;n&&n(e)}}var B=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(t,r){var n=new e,i=this.s;if(i){var a=1&i?t:r;if(a){try{N(n,1,a(this.v))}catch(e){N(n,2,e)}return n}return this}return this.o=function(e){try{var i=e.v;1&e.s?N(n,1,t?t(i):i):r?N(n,1,r(i)):N(n,2,i)}catch(e){N(n,2,e)}},n},e}();function M(e){return e instanceof B&&1&e.s}var j=/*#__PURE__*/function(){function e(e,t,r){this.userOperationHash=void 0,this.bundler=void 0,this.entrypointAddress=void 0,this.bundler=t,this.userOperationHash=e,this.entrypointAddress=r}var t=e.prototype;return t.delay=function(e){return new Promise(function(t){return setTimeout(t,e)})},t.included=function(e,t){void 0===e&&(e=180),void 0===t&&(t=2);try{var r,n=function(e){if(r)return e;throw new E("TIMEOUT","can't find useroperation",{context:i.userOperationHash})},i=this;if(e<=0||t<=0)throw RangeError("timeoutInSeconds and requestIntervalInSeconds should be bigger than zero");if(e<t)throw RangeError("timeoutInSeconds can't be less than requestIntervalInSeconds");var a=0,o=function(e,t,r){for(var n;;){var i=e();if(M(i)&&(i=i.v),!i)return a;if(i.then){n=0;break}var a=r();if(a&&a.then){if(!M(a)){n=1;break}a=a.s}if(t){var o=t();if(o&&o.then&&!M(o)){n=2;break}}}var s=new B,f=N.bind(null,s,2);return(0===n?i.then(u):1===n?a.then(c):o.then(l)).then(void 0,f),s;function c(n){a=n;do{if(t&&(o=t())&&o.then&&!M(o))return void o.then(l).then(void 0,f);if(!(i=e())||M(i)&&!i.v)return void N(s,1,a);if(i.then)return void i.then(u).then(void 0,f);M(a=r())&&(a=a.v)}while(!a||!a.then);a.then(c).then(void 0,f)}function u(e){e?(a=r())&&a.then?a.then(c).then(void 0,f):c(a):N(s,1,a)}function l(){(i=e())?i.then?i.then(u).then(void 0,f):u(i):N(s,1,a)}}(function(){return!r&&a<=e},void 0,function(){return Promise.resolve(i.delay(1e3*t)).then(function(){return Promise.resolve(i.bundler.getUserOperationReceipt(i.userOperationHash)).then(function(e){if(null!=e)return r=1,e;a++})})});return Promise.resolve(o&&o.then?o.then(n):n(o))}catch(e){return Promise.reject(e)}},e}(),k=/*#__PURE__*/function(r){function i(e,t,n){var a;return void 0===t&&(t=i.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===n&&(n=i.DEFAULT_ENTRYPOINT_ADDRESS),(a=r.call(this,e)||this).entrypointAddress=void 0,a.safe4337ModuleAddress=void 0,a.initCode=void 0,a.entrypointAddress=n,a.safe4337ModuleAddress=t,a.initCode=null,a}v(i,r),i.initializeNewAccount=function(e,t){void 0===t&&(t={});var r=i.createAccountAddressAndInitCode(e,t),n=r[1],a=new i(r[0]);return a.initCode=n,a},i.createAccountAddressAndInitCode=function(e,t){var r,n,a,o,s;if(void 0===t&&(t={}),e.length<1)throw RangeError("There should be at least one owner");var f=null!=(r=t.threshold)?r:1,c=null!=(n=t.c2Nonce)?n:0n,u=null!=(a=t.singletonAddress)?a:i.DEFAULT_SINGLETON_ADDRESS,l=null!=(o=t.safe4337ModuleAddress)?o:i.DEFAULT_SAFE_4337_MODULE_ADDRESS,d=null!=(s=t.addModuleLibAddress)?s:i.DEFAULT_ADD_MODULE_LIB_ADDRESS,p=new L;null!=t.safeAccountFactoryAddress&&(p=new L(t.safeAccountFactoryAddress));var h=i.createInitializerCallData(e,f,l,d);return[this.createProxyAddress(h,c,p.address,u),p.getFactoryGeneratorFunctionCallData([u,h,c])]},i.createInitializerCallData=function(e,t,r,n){if(void 0===r&&(r=i.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===n&&(n=i.DEFAULT_ADD_MODULE_LIB_ADDRESS),e.length<1)throw RangeError("There should be at least one owner");if(t<1)throw RangeError("threshold should be at least one");if(t>e.length)throw RangeError("threshold can't be larger than number of owners");var a=O("0x8d0dc49f",["address[]"],[[r]]);return O(i.initializerFunctionSelector,i.initializerFunctionInputAbi,[e,t,n,a,r,x,0,x])},i.createInitCode=function(e,t,r,n,a,o,s){if(void 0===t&&(t=1),void 0===r&&(r=0n),void 0===n&&(n=i.DEFAULT_SINGLETON_ADDRESS),void 0===a&&(a=new L),void 0===o&&(o=i.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===s&&(s=i.DEFAULT_ADD_MODULE_LIB_ADDRESS),e.length<1)throw RangeError("There should be at least one owner");if(t<1)throw RangeError("threshold should be at least one");if(t>e.length)throw RangeError("threshold can't be larger than number of owners");if(r<0n)throw RangeError("c2Nonce can't be negative");var f=i.createInitializerCallData(e,t,o,s);return a.getFactoryGeneratorFunctionCallData([n,f,r])},i.createProxyAddress=function(r,n,i,s){if(n<0n)throw RangeError("c2Nonce can't be negative");var f=t.defaultAbiCoder(),c=e(a(["bytes32","uint256"],[e(r),n])),u=f.encode(["uint256"],[s]),l=e(a(["bytes","bytes"],[this.proxyByteCode,u]));return"0x"+o(["bytes1","address","bytes32","bytes32"],["0xff",i,c,l]).slice(-40)},i.createAccountCallDataSingleTransaction=function(e){var t,r,n,a=null!=(t=e.value)?t:0,o=null!=(r=e.data)?r:"0x",s=null!=(n=e.operation)?n:u.Call;return i.createAccountCallData(e.to,a,o,s)},i.createAccountCallDataBatchTransactions=function(e,t){if(void 0===t&&(t=i.DEFAULT_MULTISEND_CONTRACT_ADDRESS),e.length<1)throw RangeError("There should be at least one metaTransaction");var r=O("0x8d80ff0a",["bytes"],[w(e)]);return i.createAccountCallData(t,0n,r,u.Delegate)},i.createAccountCallData=function(e,t,r,n,a){return void 0===a&&(a=i.DEFAULT_EXECUTOR_FUCNTION_SELECTOR),O(a,i.executorFunctionInputAbi,[e,t,r,n])};var c=i.prototype;return c.decodeAccountCallData=function(e){if(e.startsWith(U.executeUserOpWithErrorString)||e.startsWith(U.executeUserOp)){var r=t.defaultAbiCoder(),n="0x"+e.slice(10),i=r.decode(["address","uint256","bytes","uint8"],n);return[i[0],BigInt(i[1]),i[2],Number(i[3])]}throw new E("BAD_DATA","Invalid calldata, should start with "+U.executeUserOpWithErrorString+" or "+U.executeUserOp,{context:{callData:e}})},c.prependTokenPaymasterApproveToCallData=function(e,r,n,a,o){void 0===o&&(o=i.DEFAULT_MULTISEND_CONTRACT_ADDRESS);var s=this.decodeAccountCallData(e),f=s[0],c=s[1],l=s[2],d=s[3],p="";p="string"!=typeof l?(new TextDecoder).decode(l):l;var h=w([{to:r,value:0n,data:O(_("approve(address,uint256)"),["address","uint256"],[n,a]),operation:u.Call}]),v="",m="0x8d80ff0a";if(p.startsWith(m)){var y=function(e){return t.defaultAbiCoder().decode(["bytes"],"0x"+e.slice(10))[0]}(p);v=y+h.slice(2)}else v=w([{to:f,value:c,data:l,operation:d}])+h.slice(2);var A=O(m,["bytes"],[v]);return i.createAccountCallData(o,0n,A,u.Delegate)},c.estimateUserOperationGas=function(e,t,r,n){void 0===n&&(n=1);try{if(n<0n)throw RangeError("numberOfSigners can't be negative");for(var i="",a=0;a<n;a++)i+="ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff";e.signature="0xffffffffffffffffffffffff"+i;var o=new C(t);return Promise.resolve(o.estimateUserOperationGas(e,this.entrypointAddress,r)).then(function(e){return[BigInt(e.preVerificationGas),BigInt(e.verificationGasLimit)+5000n,BigInt(e.callGasLimit)]})}catch(e){return Promise.reject(e)}},c.createUserOperation=function(e,t,r,a){void 0===a&&(a={});try{var o=function(){var o;function c(){var e,t;function n(){var e,t,r;if("bigint"==typeof a.preVerificationGas&&a.preVerificationGas<0n)throw RangeError("preVerificationGas overrid can't be negative");if("bigint"==typeof a.verificationGasLimit&&a.verificationGasLimit<0n)throw RangeError("verificationGasLimit overrid can't be negative");if("bigint"==typeof a.callGasLimit&&a.callGasLimit<0n)throw RangeError("callGasLimit overrid can't be negative");return i.preVerificationGas=null!=(e=a.preVerificationGas)?e:o,i.verificationGasLimit=null!=(t=a.verificationGasLimit)?t:c,i.callGasLimit=null!=(r=a.callGasLimit)?r:l,i}if("bigint"==typeof a.maxFeePerGas&&a.maxFeePerGas<0n)throw RangeError("maxFeePerGas overrid can't be negative");if("bigint"==typeof a.maxPriorityFeePerGas&&a.maxPriorityFeePerGas<0n)throw RangeError("maxPriorityFeePerGas overrid can't be negative");p=null!=(e=a.maxFeePerGas)?e:p,v=null!=(t=a.maxPriorityFeePerGas)?t:v;var i=h({},T,{sender:s.accountAddress,nonce:f,initCode:u,callData:d,maxFeePerGas:p,maxPriorityFeePerGas:v}),o=T.preVerificationGas,c=T.verificationGasLimit,l=T.callGasLimit,m=function(){if(null==a.preVerificationGas||null==a.verificationGasLimit||null==a.callGasLimit)return Promise.resolve(s.estimateUserOperationGas(i,r,a.state_override_set,a.numberOfSigners)).then(function(e){o=e[0],c=e[1],l=e[2]})}();return m&&m.then?m.then(n):n()}var u=null!=(o=a.initCode)?o:s.initCode;if((null==u||f>0n)&&(u="0x"),f<0n)throw RangeError("nonce can't be negative");var d="0x";d=null==a.callData?1==e.length?i.createAccountCallDataSingleTransaction(e[0]):i.createAccountCallDataBatchTransactions(e):a.callData;var p=T.maxFeePerGas,v=T.maxPriorityFeePerGas,m=function(){if(null==a.maxFeePerGas||null==a.maxPriorityFeePerGas)return Promise.resolve(function(e,t){try{void 0===t&&(t=l.Medium);var r=new n(e);return Promise.resolve(r.getFeeData()).then(function(e){return[BigInt(Math.ceil(Number(e.maxFeePerGas)*t)),BigInt(Math.ceil(Number(e.maxPriorityFeePerGas)*t))]})}catch(e){return Promise.reject(e)}}(t)).then(function(e){p=e[0],v=e[1]})}();return m&&m.then?m.then(c):c()},s=this;if(e.length<1)throw RangeError("There should be at least one transaction");var f=0n,c=function(){if(null==a.nonce)return Promise.resolve(b(t,s.entrypointAddress,s.accountAddress)).then(function(e){f=e});f=a.nonce}();return Promise.resolve(c&&c.then?c.then(o):o())}catch(e){return Promise.reject(e)}},c.signUserOperation=function(e,t,r,n,i){if(void 0===n&&(n=0n),void 0===i&&(i=0n),t.length<1)throw RangeError("There should be at least one privateKey");if(r<0n)throw RangeError("chainId can't be negative");if(n<0n)throw RangeError("validAfter can't be negative");if(i<0n)throw RangeError("validUntil can't be negative");for(var o,c={safe:e.sender,nonce:e.nonce,initCode:e.initCode,callData:e.callData,callGasLimit:e.callGasLimit,verificationGasLimit:e.verificationGasLimit,preVerificationGas:e.preVerificationGas,maxFeePerGas:e.maxFeePerGas,maxPriorityFeePerGas:e.maxPriorityFeePerGas,paymasterAndData:e.paymasterAndData,validAfter:n,validUntil:i,entryPoint:this.entrypointAddress},u={SafeOp:[{type:"address",name:"safe"},{type:"uint256",name:"nonce"},{type:"bytes",name:"initCode"},{type:"bytes",name:"callData"},{type:"uint256",name:"callGasLimit"},{type:"uint256",name:"verificationGasLimit"},{type:"uint256",name:"preVerificationGas"},{type:"uint256",name:"maxFeePerGas"},{type:"uint256",name:"maxPriorityFeePerGas"},{type:"bytes",name:"paymasterAndData"},{type:"uint48",name:"validAfter"},{type:"uint48",name:"validUntil"},{type:"address",name:"entryPoint"}]},l="0x",d=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return P(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?P(e,t):void 0}}(e))){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(t);!(o=d()).done;)l+=new s(o.value).signingKey.sign(f.hash({chainId:r,verifyingContract:this.safe4337ModuleAddress},u,c)).serialized.slice(2);return a(["uint48","uint48","bytes"],[n,i,l])},c.sendUserOperation=function(e,t){try{var r=this,n=new C(t);return Promise.resolve(n.sendUserOperation(e,r.entrypointAddress)).then(function(e){return new j(e,n,r.entrypointAddress)})}catch(e){return Promise.reject(e)}},i}(d);function V(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}k.DEFAULT_ENTRYPOINT_ADDRESS="0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",k.DEFAULT_SAFE_4337_MODULE_ADDRESS="0xa581c4A4DB7175302464fF3C06380BC3270b4037",k.DEFAULT_SINGLETON_ADDRESS="0x29fcB43b46531BcA003ddC8FCB67FFE91900C762",k.DEFAULT_ADD_MODULE_LIB_ADDRESS="0x8EcD4ec46D4D2a6B64fE960B3D64e8B94B2234eb",k.DEFAULT_MULTISEND_CONTRACT_ADDRESS="0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526",k.proxyByteCode="0x608060405234801561001057600080fd5b506040516101e63803806101e68339818101604052602081101561003357600080fd5b8101908080519060200190929190505050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156100ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806101c46022913960400191505060405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505060ab806101196000396000f3fe608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea264697066735822122003d1488ee65e08fa41e58e888a9865554c535f2c77126a82cb4c0f917f31441364736f6c63430007060033496e76616c69642073696e676c65746f6e20616464726573732070726f7669646564",k.initializerFunctionSelector="0xb63e800d",k.initializerFunctionInputAbi=["address[]","uint256","address","bytes","address","address","uint256","address"],k.DEFAULT_EXECUTOR_FUCNTION_SELECTOR=U.executeUserOpWithErrorString,k.executorFunctionInputAbi=["address","uint256","bytes","uint8"];var z=/*#__PURE__*/function(e){function t(t){var r;return(r=e.call(this)||this).rpcUrl=void 0,r.entrypointAddress=void 0,r.supportedTokens=void 0,r.paymasterMetadata=void 0,r.rpcUrl=t,r}v(t,e);var r=t.prototype;return r.initialize=function(){try{var e=this;return Promise.resolve(V(function(){return Promise.resolve(e.getSupportedEntrypoint()).then(function(t){return e.entrypointAddress=t,Promise.resolve(e.getSupportedERC20TokensAndPaymasterMetadata()).then(function(t){return e.supportedTokens=t.tokens,e.paymasterMetadata=t.paymasterMetadata,null})})},function(e){var t=D(e);throw new E("PAYMASTER_ERROR","failed initializing the paymaster",{cause:t})}))}catch(e){return Promise.reject(e)}},r.getPaymasterMetaData=function(){try{var e=function(){return t.paymasterMetadata},t=this,r=function(){if(null==t.paymasterMetadata)return Promise.resolve(t.initialize()).then(function(){})}();return Promise.resolve(r&&r.then?r.then(e):e())}catch(e){return Promise.reject(e)}},r.getSupportedERC20TokensAndPaymasterMetadata=function(){try{var e=this;return Promise.resolve(null==e.supportedTokens||null==e.paymasterMetadata?V(function(){return Promise.resolve(G(e.rpcUrl,"pm_supportedERC20Tokens",[])).then(function(e){return{tokens:e.tokens,paymasterMetadata:e.paymasterMetadata}})},function(e){var t=D(e);throw new E("PAYMASTER_ERROR","getSupportedERC20TokensAndPaymasterMetadata failed",{cause:t})}):{tokens:e.supportedTokens,paymasterMetadata:e.paymasterMetadata})}catch(e){return Promise.reject(e)}},r.getSupportedEntrypoint=function(){try{var e=this;return Promise.resolve(null==e.entrypointAddress?V(function(){return Promise.resolve(G(e.rpcUrl,"pm_supportedEntryPoint",[]))},function(e){var t=D(e);throw new E("PAYMASTER_ERROR","getSupportedEntrypoint failed",{cause:t})}):e.entrypointAddress)}catch(e){return Promise.reject(e)}},r.isSupportedERC20Token=function(e){try{var t=function(){return!!r.supportedTokens.find(function(t){return t.address===e.toLowerCase()})},r=this,n=function(){if(null==r.entrypointAddress||null==r.supportedTokens||null==r.paymasterMetadata)return Promise.resolve(r.initialize()).then(function(){})}();return Promise.resolve(n&&n.then?n.then(t):t())}catch(e){return Promise.reject(e)}},r.getSupportedERC20TokenData=function(e){try{var t=function(){var t=r.supportedTokens.find(function(t){return t.address.toLowerCase()===e.toLowerCase()});return t?{symbol:t.symbol,address:t.address,decimal:Number(t.decimal),fee:BigInt(t.fee),exchangeRate:BigInt(t.exchangeRate)}:null},r=this,n=function(){if(null==r.entrypointAddress||null==r.supportedTokens||null==r.paymasterMetadata)return Promise.resolve(r.initialize()).then(function(){})}();return Promise.resolve(n&&n.then?n.then(t):t())}catch(e){return Promise.reject(e)}},r.createPaymasterUserOperation=function(e,t,r,n){void 0===r&&(r={});try{var i=function(){return V(function(){e.paymasterAndData=a.paymasterMetadata.dummyPaymasterAndData;var i=new C(t);return Promise.resolve(i.estimateUserOperationGas(e,a.entrypointAddress,n)).then(function(t){return e.preVerificationGas=t.preVerificationGas,e.verificationGasLimit=t.verificationGasLimit+10000n,e.callGasLimit=t.callGasLimit,Promise.resolve(G(a.rpcUrl,"pm_sponsorUserOperation",[e,a.entrypointAddress,r])).then(function(t){var r,n,i,a,o,s=t,f={paymasterAndData:s.paymasterAndData,callGasLimit:null==s.callGasLimit?void 0:BigInt(s.callGasLimit),preVerificationGas:null==s.preVerificationGas?void 0:BigInt(s.preVerificationGas),verificationGasLimit:null==s.verificationGasLimit?void 0:BigInt(s.verificationGasLimit),maxFeePerGas:null==s.maxFeePerGas?void 0:BigInt(s.maxFeePerGas),maxPriorityFeePerGas:null==s.maxPriorityFeePerGas?void 0:BigInt(s.maxPriorityFeePerGas)};return e.paymasterAndData=f.paymasterAndData,e.callGasLimit=null!=(r=f.callGasLimit)?r:e.callGasLimit,e.preVerificationGas=null!=(n=f.preVerificationGas)?n:e.preVerificationGas,e.verificationGasLimit=null!=(i=f.verificationGasLimit)?i:e.verificationGasLimit,e.maxFeePerGas=null!=(a=f.maxFeePerGas)?a:e.maxFeePerGas,e.maxPriorityFeePerGas=null!=(o=f.maxPriorityFeePerGas)?o:e.maxPriorityFeePerGas,e})})},function(e){var t=D(e);throw new E("PAYMASTER_ERROR","pm_sponsorUserOperation failed",{cause:t})})},a=this,o=function(){if(null==a.entrypointAddress||null==a.supportedTokens||null==a.paymasterMetadata)return Promise.resolve(a.initialize()).then(function(){})}();return Promise.resolve(o&&o.then?o.then(i):i())}catch(e){return Promise.reject(e)}},r.createSponsorPaymasterUserOperation=function(e,t,r){try{return Promise.resolve(this.createPaymasterUserOperation(e,t,{},r))}catch(e){return Promise.reject(e)}},r.createTokenPaymasterUserOperation=function(e,t,r,n,i){void 0===i&&(i={});try{var a=this;return Promise.resolve(a.calculateUserOperationErc20TokenMaxGasCost(t,r)).then(function(o){var s=2n*o;return Promise.resolve(a.getPaymasterMetaData()).then(function(o){var f=e.prependTokenPaymasterApproveToCallData(t.callData,r,o.address,s);return t.callData=f,Promise.resolve(a.createPaymasterUserOperation(t,n,{token:r},i))})})}catch(e){return Promise.reject(e)}},r.calculateUserOperationErc20TokenMaxGasCost=function(e,t){try{var r=this;return Promise.resolve(r.getSupportedERC20TokenData(t)).then(function(n){if(null==n)return Promise.resolve(r.getSupportedERC20TokensAndPaymasterMetadata()).then(function(e){throw new E("PAYMASTER_ERROR",t+" token is not supported by the paymaster.",{context:{supportedERC20TokensAndPaymasterMetadata:JSON.stringify(e)}})});var i=S(e);return n.exchangeRate*i/BigInt(Math.pow(10,18))})}catch(e){return Promise.reject(e)}},t}(function(){}),H={__proto__:null,SmartAccount:d,SafeAccountV0_2_0:k,SendUseroperationResponse:j,SmartAccountFactory:F,SafeAccountFactory:L,Bundler:C,CandidePaymaster:z,createUserOperationHash:R,createCallData:O,getFunctionSelector:_,fetchAccountNonce:b,calculateUserOperationMaxGasCost:S,get Operation(){return u}};export{C as Bundler,z as CandidePaymaster,u as Operation,L as SafeAccountFactory,k as SafeAccountV0_2_0,j as SendUseroperationResponse,d as SmartAccount,F as SmartAccountFactory,H as abstractionkit,S as calculateUserOperationMaxGasCost,O as createCallData,R as createUserOperationHash,b as fetchAccountNonce,_ as getFunctionSelector};

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("isomorphic-unfetch"),require("ethers")):"function"==typeof define&&define.amd?define(["exports","isomorphic-unfetch","ethers"],t):t((e||self).abstractionkit={},e.isomorphicUnfetch,e.ethers)}(this,function(e,t,r){function n(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,t}var i=/*#__PURE__*/n(t),a=function(e,t,r){try{var n=i.default||i,a=JSON.stringify({method:t,params:r,id:1,jsonrpc:"2.0"});return Promise.resolve(n(e,{method:"POST",body:a,redirect:"follow"})).then(function(e){return Promise.resolve(e.json())})}catch(e){return Promise.reject(e)}};function f(e,t,n){var i=r.keccak256(function(e){var t=[e.sender,e.nonce,r.keccak256(e.initCode),r.keccak256(e.callData),e.callGasLimit,e.verificationGasLimit,e.preVerificationGas,e.maxFeePerGas,e.maxPriorityFeePerGas,r.keccak256(e.paymasterAndData)];return r.AbiCoder.defaultAbiCoder().encode(["address","uint256","bytes32","bytes32","uint256","uint256","uint256","uint256","uint256","bytes32"],t)}(e)),a=r.AbiCoder.defaultAbiCoder().encode(["bytes32","address","uint256"],[i,t,n]);return r.keccak256(a)}function c(e,t,n){return e+r.AbiCoder.defaultAbiCoder().encode(t,n).slice(2)}function o(e){return r.id(e).slice(0,10)}var s,d=/*#__PURE__*/function(){function e(e,t,r,n,i,a){this.singletonAddress=void 0,this.proxyByteCode=void 0,this.initializerFunctionSelector=void 0,this.initializerFunctionInputAbi=void 0,this.executorFunctionSelector=void 0,this.executorFunctionInputAbi=void 0,this.singletonAddress=e,this.proxyByteCode=t,this.initializerFunctionSelector=r,this.initializerFunctionInputAbi=n,this.executorFunctionSelector=i,this.executorFunctionInputAbi=a}var t=e.prototype;return t.getInitializerCallData=function(e){return c(this.initializerFunctionSelector,this.initializerFunctionInputAbi,e)},t.getExecutorCallData=function(e){return c(this.executorFunctionSelector,this.executorFunctionInputAbi,e)},e}();function u(){return u=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},u.apply(this,arguments)}function b(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,l(e,t)}function l(e,t){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},l(e,t)}e.Operation=void 0,(s=e.Operation||(e.Operation={}))[s.Call=0]="Call",s[s.Delegate=1]="Delegate";var p=/*#__PURE__*/function(){function e(e,t,r){this.address=void 0,this.generatorFunctionSelector=void 0,this.generatorFunctionInputAbi=void 0,this.address=e,this.generatorFunctionSelector=t,this.generatorFunctionInputAbi=r}return e.prototype.getFactoryGeneratorFunctionCallData=function(e){var t=c(this.generatorFunctionSelector,this.generatorFunctionInputAbi,e);return this.address+t.slice(2)},e}(),h=/*#__PURE__*/function(e){function t(t){return void 0===t&&(t="0xb73Eb505Abc30d0e7e15B73A492863235B3F4309"),e.call(this,t,"0x1688f0b9",["address","bytes","uint256"])||this}return b(t,e),t}(p);function y(e){return"0x"+e.map(function(e){return function(e){var t=r.ethers.getBytes(e.data);return r.ethers.solidityPacked(["uint8","address","uint256","uint256","bytes"],[e.operation,e.to,e.value,t.length,t]).slice(2)}(e)}).join("")}var A=/*#__PURE__*/function(t){function n(e,r,n){var i;return void 0===e&&(e="0x3A0a17Bcc84576b099373ab3Eed9702b07D30402"),void 0===r&&(r="0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"),void 0===n&&(n=new h),(i=t.call(this,e,"0x608060405234801561001057600080fd5b5060405161017338038061017383398101604081905261002f916100b9565b6001600160a01b0381166100945760405162461bcd60e51b815260206004820152602260248201527f496e76616c69642073696e676c65746f6e20616464726573732070726f766964604482015261195960f21b606482015260840160405180910390fd5b600080546001600160a01b0319166001600160a01b03929092169190911790556100e9565b6000602082840312156100cb57600080fd5b81516001600160a01b03811681146100e257600080fd5b9392505050565b607c806100f76000396000f3fe6080604052600080546001600160a01b0316813563530ca43760e11b1415602857808252602082f35b3682833781823684845af490503d82833e806041573d82fd5b503d81f3fea2646970667358221220022b6bb97dd1e16cb867add83d4159f7550336cbb5b40514145e43f493c1377664736f6c634300080c0033","0x6a1e9826",["address[]","uint256","address","bytes","address","address","uint256","address","address"],"0xf34308ef",["address","uint256","bytes","uint8","address","address","uint256"])||this).entrypointAddress=void 0,i.candideAccountFactory=void 0,i.entrypointAddress=r,i.candideAccountFactory=n,i}b(n,t);var i=n.prototype;return i.createNewAccount=function(e,t,n,i){void 0===t&&(t=1),void 0===n&&(n=0),void 0===i&&(i="0x2a15DE4410d4c8af0A7b6c12803120f43C42B820");var a=this.getInitializerCallData([e,t,r.ZeroAddress,"0x",i,r.ZeroAddress,0,r.ZeroAddress,this.entrypointAddress]);return[this.getProxyAddress(a,this.candideAccountFactory.address,n),this.candideAccountFactory.getFactoryGeneratorFunctionCallData([this.singletonAddress,a,n])]},i.createSendEthCallData=function(e,t){return this.createCallData(e,t,"0x",0,r.ZeroAddress,r.ZeroAddress,0)},i.createCallData=function(e,t,r,n,i,a,f){return this.getExecutorCallData([e,t,r,n,i,a,f])},i.getProxyAddress=function(e,t,n){var i=r.keccak256(r.solidityPacked(["bytes32","uint256"],[r.keccak256(e),n])),a=r.keccak256(r.solidityPacked(["bytes","uint256"],[this.proxyByteCode,this.singletonAddress]));return"0x"+r.solidityPackedKeccak256(["bytes1","address","bytes32","bytes32"],["0xff",t,i,a]).slice(-40)},i.createCallDataSingleTransactionWithPaymaster=function(e,t,r,n){return this.getExecutorCallData([e.to,e.value,e.data,e.operation,t,r,n])},i.createCallDataSingleTransaction=function(e){return this.createCallDataSingleTransactionWithPaymaster(e,r.ZeroAddress,r.ZeroAddress,0)},i.createCallDataBatchTransactionWithPaymaster=function(t,r,n,i){var a=c("0x8d80ff0a",["bytes"],[y(t)]);return this.getExecutorCallData(["0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526",0,a,e.Operation.Delegate,r,n,i])},i.createCallDataBatchTransaction=function(e){return this.createCallDataBatchTransactionWithPaymaster(e,r.ZeroAddress,r.ZeroAddress,0)},n}(d),m=/*#__PURE__*/function(e){function t(t){return void 0===t&&(t="0x9406Cc6185a346906296840746125a0E44976454"),e.call(this,t,"0x5fbfb9cf",["address","uint256"])||this}return b(t,e),t}(p),v=/*#__PURE__*/function(e){function t(t,r,n){var i;return void 0===t&&(t="0x8ABB13360b87Be5EEb1B98647A016adD927a136c"),void 0===r&&(r="0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"),void 0===n&&(n=new m),(i=e.call(this,t,"0x60806040526040516107c13803806107c183398101604081905261002291610321565b61002e82826000610035565b505061043e565b61003e8361006b565b60008251118061004b5750805b156100665761006483836100ab60201b6100291760201c565b505b505050565b610074816100d7565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606100d0838360405180606001604052806027815260200161079a602791396101a9565b9392505050565b6100ea8161022260201b6100551760201c565b6101515760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084015b60405180910390fd5b806101887f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b61023160201b6100711760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b6060600080856001600160a01b0316856040516101c691906103ef565b600060405180830381855af49150503d8060008114610201576040519150601f19603f3d011682016040523d82523d6000602084013e610206565b606091505b50909250905061021886838387610234565b9695505050505050565b6001600160a01b03163b151590565b90565b606083156102a357825160000361029c576001600160a01b0385163b61029c5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610148565b50816102ad565b6102ad83836102b5565b949350505050565b8151156102c55781518083602001fd5b8060405162461bcd60e51b8152600401610148919061040b565b634e487b7160e01b600052604160045260246000fd5b60005b838110156103105781810151838201526020016102f8565b838111156100645750506000910152565b6000806040838503121561033457600080fd5b82516001600160a01b038116811461034b57600080fd5b60208401519092506001600160401b038082111561036857600080fd5b818501915085601f83011261037c57600080fd5b81518181111561038e5761038e6102df565b604051601f8201601f19908116603f011681019083821181831017156103b6576103b66102df565b816040528281528860208487010111156103cf57600080fd5b6103e08360208301602088016102f5565b80955050505050509250929050565b600082516104018184602087016102f5565b9190910192915050565b602081526000825180602084015261042a8160408501602087016102f5565b601f01601f19169190910160400192915050565b61034d8061044d6000396000f3fe60806040523661001357610011610017565b005b6100115b610027610022610074565b6100b9565b565b606061004e83836040518060600160405280602781526020016102f1602791396100dd565b9392505050565b73ffffffffffffffffffffffffffffffffffffffff163b151590565b90565b60006100b47f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5473ffffffffffffffffffffffffffffffffffffffff1690565b905090565b3660008037600080366000845af43d6000803e8080156100d8573d6000f35b3d6000fd5b60606000808573ffffffffffffffffffffffffffffffffffffffff16856040516101079190610283565b600060405180830381855af49150503d8060008114610142576040519150601f19603f3d011682016040523d82523d6000602084013e610147565b606091505b509150915061015886838387610162565b9695505050505050565b606083156101fd5782516000036101f65773ffffffffffffffffffffffffffffffffffffffff85163b6101f6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064015b60405180910390fd5b5081610207565b610207838361020f565b949350505050565b81511561021f5781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101ed919061029f565b60005b8381101561026e578181015183820152602001610256565b8381111561027d576000848401525b50505050565b60008251610295818460208701610253565b9190910192915050565b60208152600082518060208401526102be816040850160208701610253565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212201cd78ab6a31213989661cff2d7d05fc9b9c38b1a848e8249e2e398659a9eb7e364736f6c634300080f0033416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564","0xc4d66de8",["address"],"0xb61d27f6",["address","uint256","bytes"])||this).entrypointAddress=void 0,i.simpleAccountFactory=void 0,i.batchExecutorFunctionSelector=void 0,i.batchExecutorFunctionInputAbi=void 0,i.entrypointAddress=r,i.simpleAccountFactory=n,i.batchExecutorFunctionSelector="0x18dfb3c7",i.batchExecutorFunctionInputAbi=["address[]","bytes[]"],i}b(t,e);var n=t.prototype;return n.createNewAccount=function(e,t){void 0===t&&(t=0);var r=this.getInitializerCallData([e]),n=this.simpleAccountFactory.getFactoryGeneratorFunctionCallData([e,t]);return[this.getProxyAddress(r,this.simpleAccountFactory.address,t),n]},n.getProxyAddress=function(e,t,n){var i=r.AbiCoder.defaultAbiCoder(),a=i.encode(["uint256"],[n]),f=i.encode(["address","bytes"],[this.singletonAddress,e]),c=r.keccak256(r.solidityPacked(["bytes","bytes"],[this.proxyByteCode,f]));return"0x"+r.solidityPackedKeccak256(["bytes1","address","bytes32","bytes32"],["0xff",t,a,c]).slice(-40)},n.createSendEthCallData=function(e,t){return this.createCallData(e,t,"0x")},n.createCallData=function(e,t,r){return this.getExecutorCallData([e,t,r])},n.createBatchCallData=function(e,t){return c(this.batchExecutorFunctionSelector,this.batchExecutorFunctionInputAbi,[e,t])},t}(d),x=/*#__PURE__*/function(){function e(e,t){this.rpcUrl=void 0,this.entrypointAddress=void 0,this.rpcUrl=e,this.entrypointAddress=t}var t=e.prototype;return t.chainId=function(){try{return Promise.resolve(a(this.rpcUrl,"eth_chainId",[])).then(function(e){return"result"in e?{chainId:e.result}:e.error})}catch(e){return Promise.reject(e)}},t.supportedEntryPoints=function(){try{return Promise.resolve(a(this.rpcUrl,"eth_supportedEntryPoints",[])).then(function(e){return"result"in e?{supportedEntryPoints:e.result}:e.error})}catch(e){return Promise.reject(e)}},t.estimateUserOperationGas=function(e){try{return Promise.resolve(a(this.rpcUrl,"eth_estimateUserOperationGas",[e,this.entrypointAddress])).then(function(e){return"result"in e?e.result:e.error})}catch(e){return Promise.reject(e)}},t.sendUserOperation=function(e){try{return Promise.resolve(a(this.rpcUrl,"eth_sendUserOperation",[e,this.entrypointAddress])).then(function(e){return"result"in e?{userOperationHash:e.result}:e.error})}catch(e){return Promise.reject(e)}},t.getUserOperationReceipt=function(e){try{return Promise.resolve(a(this.rpcUrl,"eth_getUserOperationReceipt",[e])).then(function(e){if("result"in e){var t=e.result,r=u({},t.receipt,{logs:JSON.stringify(t.receipt.logs)});return u({},t,{logs:JSON.stringify(t.logs),receipt:r})}return e.error})}catch(e){return Promise.reject(e)}},t.getUserOperationByHash=function(e){try{return Promise.resolve(a(this.rpcUrl,"eth_getUserOperationByHash",[e])).then(function(e){return"result"in e?e.result:e.error})}catch(e){return Promise.reject(e)}},e}(),g=/*#__PURE__*/function(e){function t(t,r){var n;return(n=e.call(this)||this).rpcUrl=void 0,n.entrypointAddress=void 0,n.rpcUrl=r,n.entrypointAddress=t,n}b(t,e);var r=t.prototype;return r.getSupportedERC20Tokens=function(){try{return Promise.resolve(a(this.rpcUrl,"pm_supportedERC20Tokens",[])).then(function(e){if("result"in e){var t=e.result;return{tokens:t.tokens,paymasterMetadata:t.paymasterMetadata}}return e.error})}catch(e){return Promise.reject(e)}},r.getSupportedEntrypoint=function(){try{return Promise.resolve(a(this.rpcUrl,"pm_supportedEntryPoint",[])).then(function(e){return"result"in e?e.result:e.error})}catch(e){return Promise.reject(e)}},r.getPaymasterCallDataForPayingGasWithErc20=function(e,t){try{var r=this;return Promise.resolve(r.getPaymasterCallData(e,[r.rpcUrl,r.entrypointAddress,t]))}catch(e){return Promise.reject(e)}},r.getPaymasterCallDataForGaslessTx=function(e){try{var t=this;return Promise.resolve(t.getPaymasterCallData(e,[t.rpcUrl,t.entrypointAddress]))}catch(e){return Promise.reject(e)}},r.getPaymasterCallData=function(e,t){try{return Promise.resolve(a(t[0],"pm_sponsorUserOperation",[e,t[1],{token:t[2]}])).then(function(e){return"result"in e?e.result:e.error})}catch(e){return Promise.reject(e)}},t}(function(){}),P={sender:r.ZeroAddress,nonce:"0x00",initCode:"0x",callData:"0x",callGasLimit:"0x00",verificationGasLimit:"0x00",preVerificationGas:"0x00",maxFeePerGas:"0x00",maxPriorityFeePerGas:"0x00",paymasterAndData:"0x",signature:"0x"},F={sender:r.ZeroAddress,nonce:"0x00",initCode:"0x",callData:"0x",callGasLimit:"0xffffff",verificationGasLimit:"0xffffff",preVerificationGas:"0xffffff",maxFeePerGas:"0xffffff",maxPriorityFeePerGas:"0xfffffff",paymasterAndData:"0x",signature:"0x"},C={__proto__:null,SmartAccount:d,CandideAccount:A,SimpleAccount:v,SmartAccountFactory:p,CandideAccountFactory:h,SimpleAccountFactory:m,Bundler:x,CandideValidationPaymaster:g,getUserOperationHash:f,getCallData:c,getFunctionSelector:o,UserOperationEmptyValues:P,UserOperationDummyValues:F,get Operation(){return e.Operation}};e.Bundler=x,e.CandideAccount=A,e.CandideAccountFactory=h,e.CandideValidationPaymaster=g,e.SimpleAccount=v,e.SimpleAccountFactory=m,e.SmartAccount=d,e.SmartAccountFactory=p,e.UserOperationDummyValues=F,e.UserOperationEmptyValues=P,e.abstractionkit=C,e.getCallData=c,e.getFunctionSelector=o,e.getUserOperationHash=f});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("ethers"),require("isomorphic-unfetch")):"function"==typeof define&&define.amd?define(["exports","ethers","isomorphic-unfetch"],t):t((e||self).abstractionkit={},e.ethers,e.isomorphicUnfetch)}(this,function(e,t,r){function n(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,t}var i,a,o=/*#__PURE__*/n(r),s=function(e){this.accountAddress=void 0,this.accountAddress=e};function f(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(f=function(){return!!e})()}function c(){return c=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},c.apply(this,arguments)}function u(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,d(e,t)}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}function d(e,t){return d=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},d(e,t)}function p(e){var t="function"==typeof Map?new Map:void 0;return p=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return function(e,t,r){if(f())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,t);var i=new(e.bind.apply(e,n));return r&&d(i,r.prototype),i}(e,arguments,l(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),d(r,e)},p(e)}function h(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}s.proxyByteCode=void 0,s.initializerFunctionSelector=void 0,s.initializerFunctionInputAbi=void 0,s.executorFunctionSelector=void 0,s.executorFunctionInputAbi=void 0,e.Operation=void 0,(i=e.Operation||(e.Operation={}))[i.Call=0]="Call",i[i.Delegate=1]="Delegate",function(e){e[e.Slow=1]="Slow",e[e.Medium=1.2]="Medium",e[e.Fast=1.5]="Fast"}(a||(a={}));var v={"-32602":"INVALID_FIELDS","-32500":"SIMULATE_VALIDATION","-32501":"SIMULATE_PAYMASTER_VALIDATION","-32502":"OPCODE_VALIDATION","-32503":"EXPIRE_SHORTLY","-32504":"REPUTATION","-32505":"INSUFFICIENT_STAKE","-32506":"UNSUPPORTED_SIGNATURE_AGGREGATOR","-32507":"INVALID_SIGNATURE","-32601":"INVALID_USEROPERATION_HASH","-32521":"EXECUTION_REVERTED"},m=/*#__PURE__*/function(e){function t(t,r,n){var i;void 0===n&&(n={});var a=n.errno,o=n.context;return(i=e.call(this,r,{cause:n.cause})||this).code=void 0,i.context=void 0,i.errno=void 0,i.name=i.constructor.name,i.code=t,i.errno=a,i.context=o,i}return u(t,e),t}(/*#__PURE__*/p(Error));function y(e){if(e instanceof Error)return e;var t="[Unable to stringify the thrown value]";try{t=JSON.stringify(e)}catch(e){}return new Error("This value was thrown as is, not through an Error: "+t)}var A=function(e,t,r,n){void 0===n&&(n=0);try{var i=[{from:"0x0000000000000000000000000000000000000000",to:t,data:b(D("getNonce(address,uint192)"),["address","uint192"],[r,n])},"latest"];return Promise.resolve(function(t,r){try{var n=Promise.resolve(P(e,"eth_call",i)).then(function(e){if("string"!=typeof e)throw new m("BAD_DATA","getNonce returned ill formed data",{context:JSON.stringify(e)});try{return BigInt(e)}catch(e){var t=y(e);throw new m("BAD_DATA","getNonce returned ill formed data",{cause:t})}})}catch(e){return r(e)}return n&&n.then?n.then(void 0,r):n}(0,function(e){var t=y(e);throw new m("BAD_DATA","getNonce failed",{cause:t})}))}catch(e){return Promise.reject(e)}},P=function(e,t,r){try{var n=o.default||o,i={method:"POST",body:JSON.stringify({method:t,params:r,id:(new Date).getTime(),jsonrpc:"2.0"},function(e,t){return"bigint"==typeof t?"0x"+t.toString(16):t}),redirect:"follow"};return Promise.resolve(n(e,i)).then(function(t){return Promise.resolve(t.json()).then(function(t){if("result"in t)return t.result;var r=t.error,n=String(r.code);throw new m(n in v?v[n]:"UNKNOWN_ERROR",r.message,{errno:r.code,context:{url:e,requestOptions:JSON.stringify(i)}})})})}catch(e){return Promise.reject(e)}};function g(e,r,n){var i=t.keccak256(function(e){var r=[e.sender,e.nonce,t.keccak256(e.initCode),t.keccak256(e.callData),e.callGasLimit,e.verificationGasLimit,e.preVerificationGas,e.maxFeePerGas,e.maxPriorityFeePerGas,t.keccak256(e.paymasterAndData)];return t.AbiCoder.defaultAbiCoder().encode(["address","uint256","bytes32","bytes32","uint256","uint256","uint256","uint256","uint256","bytes32"],r)}(e)),a=t.AbiCoder.defaultAbiCoder().encode(["bytes32","address","uint256"],[i,r,n]);return t.keccak256(a)}function b(e,r,n){return e+t.AbiCoder.defaultAbiCoder().encode(r,n).slice(2)}function D(e){return t.id(e).slice(0,10)}function E(e){return(e.callGasLimit+e.verificationGasLimit*("0x"==e.paymasterAndData||null==e.paymasterAndData?3n:0n)+e.preVerificationGas)*e.maxFeePerGas}var G,O="0x0000000000000000000000000000000000000000",R={sender:O,nonce:0n,initCode:"0x",callData:"0x",callGasLimit:0xffffffn,verificationGasLimit:0xffffffn,preVerificationGas:0xffffffn,maxFeePerGas:0xffffffn,maxPriorityFeePerGas:0xfffffffn,paymasterAndData:"0x",signature:"0x"},_=/*#__PURE__*/function(){function e(e,t,r){this.address=void 0,this.generatorFunctionSelector=void 0,this.generatorFunctionInputAbi=void 0,this.address=e,this.generatorFunctionSelector=t,this.generatorFunctionInputAbi=r}return e.prototype.getFactoryGeneratorFunctionCallData=function(e){var t=b(this.generatorFunctionSelector,this.generatorFunctionInputAbi,e);return this.address+t.slice(2)},e}(),S=/*#__PURE__*/function(e){function t(t){return void 0===t&&(t="0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67"),e.call(this,t,"0x1688f0b9",["address","bytes","uint256"])||this}return u(t,e),t}(_);function U(r){return"0x"+r.map(function(r){return a=null!=(i=(n=r).operation)?i:e.Operation.Call,o=t.getBytes(n.data),t.solidityPacked(["uint8","address","uint256","uint256","bytes"],[a,n.to,n.value,o.length,o]).slice(2);var n,i,a,o}).join("")}function x(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}!function(e){e.executeUserOpWithErrorString="0x541d63c8",e.executeUserOp="0x7bb37428"}(G||(G={}));var T=/*#__PURE__*/function(){function e(e){this.rpcUrl=void 0,this.rpcUrl=e}var t=e.prototype;return t.chainId=function(){try{var e=this;return Promise.resolve(x(function(){return Promise.resolve(P(e.rpcUrl,"eth_chainId",[])).then(function(e){if("string"==typeof e)return e;throw new m("BAD_DATA","bundler eth_chainId rpc call failed")})},function(e){var t=y(e);throw new m("BUNDLER_ERROR","bundler eth_chainId rpc call failed",{cause:t})}))}catch(e){return Promise.reject(e)}},t.supportedEntryPoints=function(){try{var e=this;return Promise.resolve(x(function(){return Promise.resolve(P(e.rpcUrl,"eth_supportedEntryPoints",[]))},function(e){var t=y(e);throw new m("BUNDLER_ERROR","bundler eth_supportedEntryPoints rpc call failed",{cause:t})}))}catch(e){return Promise.reject(e)}},t.estimateUserOperationGas=function(e,t,r){try{var n=this;return Promise.resolve(x(function(){function i(){var e=a;return{callGasLimit:BigInt(e.callGasLimit),preVerificationGas:BigInt(e.preVerificationGas),verificationGasLimit:BigInt(e.verificationGasLimit)}}var a={},o=void 0===r?Promise.resolve(P(n.rpcUrl,"eth_estimateUserOperationGas",[e,t])).then(function(e){a=e}):Promise.resolve(P(n.rpcUrl,"eth_estimateUserOperationGas",[e,t,r])).then(function(e){a=e});return o&&o.then?o.then(i):i()},function(e){var t=y(e);throw new m("BUNDLER_ERROR","bundler eth_estimateUserOperationGas rpc call failed",{cause:t})}))}catch(e){return Promise.reject(e)}},t.sendUserOperation=function(e,t){try{var r=this;return Promise.resolve(x(function(){return Promise.resolve(P(r.rpcUrl,"eth_sendUserOperation",[e,t]))},function(e){var t=y(e);throw new m("BUNDLER_ERROR","bundler eth_sendUserOperation rpc call failed",{cause:t})}))}catch(e){return Promise.reject(e)}},t.getUserOperationReceipt=function(e){try{var t=this;return Promise.resolve(x(function(){return Promise.resolve(P(t.rpcUrl,"eth_getUserOperationReceipt",[e])).then(function(e){var t=e;if(null!=t){var r=c({},t.receipt,{blockNumber:BigInt(t.receipt.blockNumber),cumulativeGasUsed:BigInt(t.receipt.cumulativeGasUsed),gasUsed:BigInt(t.receipt.gasUsed),transactionIndex:BigInt(t.receipt.transactionIndex),effectiveGasPrice:null==t.receipt.effectiveGasPrice?void 0:BigInt(t.receipt.effectiveGasPrice),logs:JSON.stringify(t.receipt.logs)});return c({},t,{nonce:BigInt(t.nonce),actualGasCost:BigInt(t.actualGasCost),actualGasUsed:BigInt(t.actualGasUsed),logs:JSON.stringify(t.logs),receipt:r})}return null})},function(t){var r=y(t);throw new m("BUNDLER_ERROR","bundler eth_getUserOperationReceipt rpc call failed",{cause:r,context:{useroperationhash:e}})}))}catch(e){return Promise.reject(e)}},t.getUserOperationByHash=function(e){try{var t=this;return Promise.resolve(x(function(){return Promise.resolve(P(t.rpcUrl,"eth_getUserOperationByHash",[e])).then(function(e){return null!=e?c({},e,{blockNumber:null==e.blockNumber?null:BigInt(e.blockNumber)}):null})},function(t){var r=y(t);throw new m("BUNDLER_ERROR","bundler eth_getUserOperationByHash rpc call failed",{cause:r,context:{useroperationhash:e}})}))}catch(e){return Promise.reject(e)}},e}();function F(e,t,r){if(!e.s){if(r instanceof L){if(!r.s)return void(r.o=F.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(F.bind(null,e,t),F.bind(null,e,2));e.s=t,e.v=r;const n=e.o;n&&n(e)}}var L=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(t,r){var n=new e,i=this.s;if(i){var a=1&i?t:r;if(a){try{F(n,1,a(this.v))}catch(e){F(n,2,e)}return n}return this}return this.o=function(e){try{var i=e.v;1&e.s?F(n,1,t?t(i):i):r?F(n,1,r(i)):F(n,2,i)}catch(e){F(n,2,e)}},n},e}();function w(e){return e instanceof L&&1&e.s}var C=/*#__PURE__*/function(){function e(e,t,r){this.userOperationHash=void 0,this.bundler=void 0,this.entrypointAddress=void 0,this.bundler=t,this.userOperationHash=e,this.entrypointAddress=r}var t=e.prototype;return t.delay=function(e){return new Promise(function(t){return setTimeout(t,e)})},t.included=function(e,t){void 0===e&&(e=180),void 0===t&&(t=2);try{var r,n=function(e){if(r)return e;throw new m("TIMEOUT","can't find useroperation",{context:i.userOperationHash})},i=this;if(e<=0||t<=0)throw RangeError("timeoutInSeconds and requestIntervalInSeconds should be bigger than zero");if(e<t)throw RangeError("timeoutInSeconds can't be less than requestIntervalInSeconds");var a=0,o=function(e,t,r){for(var n;;){var i=e();if(w(i)&&(i=i.v),!i)return a;if(i.then){n=0;break}var a=r();if(a&&a.then){if(!w(a)){n=1;break}a=a.s}if(t){var o=t();if(o&&o.then&&!w(o)){n=2;break}}}var s=new L,f=F.bind(null,s,2);return(0===n?i.then(u):1===n?a.then(c):o.then(l)).then(void 0,f),s;function c(n){a=n;do{if(t&&(o=t())&&o.then&&!w(o))return void o.then(l).then(void 0,f);if(!(i=e())||w(i)&&!i.v)return void F(s,1,a);if(i.then)return void i.then(u).then(void 0,f);w(a=r())&&(a=a.v)}while(!a||!a.then);a.then(c).then(void 0,f)}function u(e){e?(a=r())&&a.then?a.then(c).then(void 0,f):c(a):F(s,1,a)}function l(){(i=e())?i.then?i.then(u).then(void 0,f):u(i):F(s,1,a)}}(function(){return!r&&a<=e},void 0,function(){return Promise.resolve(i.delay(1e3*t)).then(function(){return Promise.resolve(i.bundler.getUserOperationReceipt(i.userOperationHash)).then(function(e){if(null!=e)return r=1,e;a++})})});return Promise.resolve(o&&o.then?o.then(n):n(o))}catch(e){return Promise.reject(e)}},e}(),I=/*#__PURE__*/function(r){function n(e,t,i){var a;return void 0===t&&(t=n.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===i&&(i=n.DEFAULT_ENTRYPOINT_ADDRESS),(a=r.call(this,e)||this).entrypointAddress=void 0,a.safe4337ModuleAddress=void 0,a.initCode=void 0,a.entrypointAddress=i,a.safe4337ModuleAddress=t,a.initCode=null,a}u(n,r),n.initializeNewAccount=function(e,t){void 0===t&&(t={});var r=n.createAccountAddressAndInitCode(e,t),i=r[1],a=new n(r[0]);return a.initCode=i,a},n.createAccountAddressAndInitCode=function(e,t){var r,i,a,o,s;if(void 0===t&&(t={}),e.length<1)throw RangeError("There should be at least one owner");var f=null!=(r=t.threshold)?r:1,c=null!=(i=t.c2Nonce)?i:0n,u=null!=(a=t.singletonAddress)?a:n.DEFAULT_SINGLETON_ADDRESS,l=null!=(o=t.safe4337ModuleAddress)?o:n.DEFAULT_SAFE_4337_MODULE_ADDRESS,d=null!=(s=t.addModuleLibAddress)?s:n.DEFAULT_ADD_MODULE_LIB_ADDRESS,p=new S;null!=t.safeAccountFactoryAddress&&(p=new S(t.safeAccountFactoryAddress));var h=n.createInitializerCallData(e,f,l,d);return[this.createProxyAddress(h,c,p.address,u),p.getFactoryGeneratorFunctionCallData([u,h,c])]},n.createInitializerCallData=function(e,t,r,i){if(void 0===r&&(r=n.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===i&&(i=n.DEFAULT_ADD_MODULE_LIB_ADDRESS),e.length<1)throw RangeError("There should be at least one owner");if(t<1)throw RangeError("threshold should be at least one");if(t>e.length)throw RangeError("threshold can't be larger than number of owners");var a=b("0x8d0dc49f",["address[]"],[[r]]);return b(n.initializerFunctionSelector,n.initializerFunctionInputAbi,[e,t,i,a,r,O,0,O])},n.createInitCode=function(e,t,r,i,a,o,s){if(void 0===t&&(t=1),void 0===r&&(r=0n),void 0===i&&(i=n.DEFAULT_SINGLETON_ADDRESS),void 0===a&&(a=new S),void 0===o&&(o=n.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===s&&(s=n.DEFAULT_ADD_MODULE_LIB_ADDRESS),e.length<1)throw RangeError("There should be at least one owner");if(t<1)throw RangeError("threshold should be at least one");if(t>e.length)throw RangeError("threshold can't be larger than number of owners");if(r<0n)throw RangeError("c2Nonce can't be negative");var f=n.createInitializerCallData(e,t,o,s);return a.getFactoryGeneratorFunctionCallData([i,f,r])},n.createProxyAddress=function(e,r,n,i){if(r<0n)throw RangeError("c2Nonce can't be negative");var a=t.AbiCoder.defaultAbiCoder(),o=t.keccak256(t.solidityPacked(["bytes32","uint256"],[t.keccak256(e),r])),s=a.encode(["uint256"],[i]),f=t.keccak256(t.solidityPacked(["bytes","bytes"],[this.proxyByteCode,s]));return"0x"+t.solidityPackedKeccak256(["bytes1","address","bytes32","bytes32"],["0xff",n,o,f]).slice(-40)},n.createAccountCallDataSingleTransaction=function(t){var r,i,a,o=null!=(r=t.value)?r:0,s=null!=(i=t.data)?i:"0x",f=null!=(a=t.operation)?a:e.Operation.Call;return n.createAccountCallData(t.to,o,s,f)},n.createAccountCallDataBatchTransactions=function(t,r){if(void 0===r&&(r=n.DEFAULT_MULTISEND_CONTRACT_ADDRESS),t.length<1)throw RangeError("There should be at least one metaTransaction");var i=b("0x8d80ff0a",["bytes"],[U(t)]);return n.createAccountCallData(r,0n,i,e.Operation.Delegate)},n.createAccountCallData=function(e,t,r,i,a){return void 0===a&&(a=n.DEFAULT_EXECUTOR_FUCNTION_SELECTOR),b(a,n.executorFunctionInputAbi,[e,t,r,i])};var i=n.prototype;return i.decodeAccountCallData=function(e){if(e.startsWith(G.executeUserOpWithErrorString)||e.startsWith(G.executeUserOp)){var r=t.AbiCoder.defaultAbiCoder(),n="0x"+e.slice(10),i=r.decode(["address","uint256","bytes","uint8"],n);return[i[0],BigInt(i[1]),i[2],Number(i[3])]}throw new m("BAD_DATA","Invalid calldata, should start with "+G.executeUserOpWithErrorString+" or "+G.executeUserOp,{context:{callData:e}})},i.prependTokenPaymasterApproveToCallData=function(r,i,a,o,s){void 0===s&&(s=n.DEFAULT_MULTISEND_CONTRACT_ADDRESS);var f=this.decodeAccountCallData(r),c=f[0],u=f[1],l=f[2],d=f[3],p="";p="string"!=typeof l?(new TextDecoder).decode(l):l;var h=U([{to:i,value:0n,data:b(D("approve(address,uint256)"),["address","uint256"],[a,o]),operation:e.Operation.Call}]),v="",m="0x8d80ff0a";if(p.startsWith(m)){var y=function(e){return t.AbiCoder.defaultAbiCoder().decode(["bytes"],"0x"+e.slice(10))[0]}(p);v=y+h.slice(2)}else v=U([{to:c,value:u,data:l,operation:d}])+h.slice(2);var A=b(m,["bytes"],[v]);return n.createAccountCallData(s,0n,A,e.Operation.Delegate)},i.estimateUserOperationGas=function(e,t,r,n){void 0===n&&(n=1);try{if(n<0n)throw RangeError("numberOfSigners can't be negative");for(var i="",a=0;a<n;a++)i+="ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff";e.signature="0xffffffffffffffffffffffff"+i;var o=new T(t);return Promise.resolve(o.estimateUserOperationGas(e,this.entrypointAddress,r)).then(function(e){return[BigInt(e.preVerificationGas),BigInt(e.verificationGasLimit)+5000n,BigInt(e.callGasLimit)]})}catch(e){return Promise.reject(e)}},i.createUserOperation=function(e,r,i,o){void 0===o&&(o={});try{var s=function(){var s;function l(){var e,t;function r(){var e,t,r;if("bigint"==typeof o.preVerificationGas&&o.preVerificationGas<0n)throw RangeError("preVerificationGas overrid can't be negative");if("bigint"==typeof o.verificationGasLimit&&o.verificationGasLimit<0n)throw RangeError("verificationGasLimit overrid can't be negative");if("bigint"==typeof o.callGasLimit&&o.callGasLimit<0n)throw RangeError("callGasLimit overrid can't be negative");return n.preVerificationGas=null!=(e=o.preVerificationGas)?e:a,n.verificationGasLimit=null!=(t=o.verificationGasLimit)?t:s,n.callGasLimit=null!=(r=o.callGasLimit)?r:l,n}if("bigint"==typeof o.maxFeePerGas&&o.maxFeePerGas<0n)throw RangeError("maxFeePerGas overrid can't be negative");if("bigint"==typeof o.maxPriorityFeePerGas&&o.maxPriorityFeePerGas<0n)throw RangeError("maxPriorityFeePerGas overrid can't be negative");h=null!=(e=o.maxFeePerGas)?e:h,v=null!=(t=o.maxPriorityFeePerGas)?t:v;var n=c({},R,{sender:f.accountAddress,nonce:u,initCode:d,callData:p,maxFeePerGas:h,maxPriorityFeePerGas:v}),a=R.preVerificationGas,s=R.verificationGasLimit,l=R.callGasLimit,m=function(){if(null==o.preVerificationGas||null==o.verificationGasLimit||null==o.callGasLimit)return Promise.resolve(f.estimateUserOperationGas(n,i,o.state_override_set,o.numberOfSigners)).then(function(e){a=e[0],s=e[1],l=e[2]})}();return m&&m.then?m.then(r):r()}var d=null!=(s=o.initCode)?s:f.initCode;if((null==d||u>0n)&&(d="0x"),u<0n)throw RangeError("nonce can't be negative");var p="0x";p=null==o.callData?1==e.length?n.createAccountCallDataSingleTransaction(e[0]):n.createAccountCallDataBatchTransactions(e):o.callData;var h=R.maxFeePerGas,v=R.maxPriorityFeePerGas,m=function(){if(null==o.maxFeePerGas||null==o.maxPriorityFeePerGas)return Promise.resolve(function(e,r){try{void 0===r&&(r=a.Medium);var n=new t.JsonRpcProvider(e);return Promise.resolve(n.getFeeData()).then(function(e){return[BigInt(Math.ceil(Number(e.maxFeePerGas)*r)),BigInt(Math.ceil(Number(e.maxPriorityFeePerGas)*r))]})}catch(e){return Promise.reject(e)}}(r)).then(function(e){h=e[0],v=e[1]})}();return m&&m.then?m.then(l):l()},f=this;if(e.length<1)throw RangeError("There should be at least one transaction");var u=0n,l=function(){if(null==o.nonce)return Promise.resolve(A(r,f.entrypointAddress,f.accountAddress)).then(function(e){u=e});u=o.nonce}();return Promise.resolve(l&&l.then?l.then(s):s())}catch(e){return Promise.reject(e)}},i.signUserOperation=function(e,r,n,i,a){if(void 0===i&&(i=0n),void 0===a&&(a=0n),r.length<1)throw RangeError("There should be at least one privateKey");if(n<0n)throw RangeError("chainId can't be negative");if(i<0n)throw RangeError("validAfter can't be negative");if(a<0n)throw RangeError("validUntil can't be negative");for(var o,s={safe:e.sender,nonce:e.nonce,initCode:e.initCode,callData:e.callData,callGasLimit:e.callGasLimit,verificationGasLimit:e.verificationGasLimit,preVerificationGas:e.preVerificationGas,maxFeePerGas:e.maxFeePerGas,maxPriorityFeePerGas:e.maxPriorityFeePerGas,paymasterAndData:e.paymasterAndData,validAfter:i,validUntil:a,entryPoint:this.entrypointAddress},f={SafeOp:[{type:"address",name:"safe"},{type:"uint256",name:"nonce"},{type:"bytes",name:"initCode"},{type:"bytes",name:"callData"},{type:"uint256",name:"callGasLimit"},{type:"uint256",name:"verificationGasLimit"},{type:"uint256",name:"preVerificationGas"},{type:"uint256",name:"maxFeePerGas"},{type:"uint256",name:"maxPriorityFeePerGas"},{type:"bytes",name:"paymasterAndData"},{type:"uint48",name:"validAfter"},{type:"uint48",name:"validUntil"},{type:"address",name:"entryPoint"}]},c="0x",u=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return h(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?h(e,t):void 0}}(e))){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(r);!(o=u()).done;)c+=new t.Wallet(o.value).signingKey.sign(t.TypedDataEncoder.hash({chainId:n,verifyingContract:this.safe4337ModuleAddress},f,s)).serialized.slice(2);return t.solidityPacked(["uint48","uint48","bytes"],[i,a,c])},i.sendUserOperation=function(e,t){try{var r=this,n=new T(t);return Promise.resolve(n.sendUserOperation(e,r.entrypointAddress)).then(function(e){return new C(e,n,r.entrypointAddress)})}catch(e){return Promise.reject(e)}},n}(s);function N(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}I.DEFAULT_ENTRYPOINT_ADDRESS="0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",I.DEFAULT_SAFE_4337_MODULE_ADDRESS="0xa581c4A4DB7175302464fF3C06380BC3270b4037",I.DEFAULT_SINGLETON_ADDRESS="0x29fcB43b46531BcA003ddC8FCB67FFE91900C762",I.DEFAULT_ADD_MODULE_LIB_ADDRESS="0x8EcD4ec46D4D2a6B64fE960B3D64e8B94B2234eb",I.DEFAULT_MULTISEND_CONTRACT_ADDRESS="0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526",I.proxyByteCode="0x608060405234801561001057600080fd5b506040516101e63803806101e68339818101604052602081101561003357600080fd5b8101908080519060200190929190505050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156100ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806101c46022913960400191505060405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505060ab806101196000396000f3fe608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea264697066735822122003d1488ee65e08fa41e58e888a9865554c535f2c77126a82cb4c0f917f31441364736f6c63430007060033496e76616c69642073696e676c65746f6e20616464726573732070726f7669646564",I.initializerFunctionSelector="0xb63e800d",I.initializerFunctionInputAbi=["address[]","uint256","address","bytes","address","address","uint256","address"],I.DEFAULT_EXECUTOR_FUCNTION_SELECTOR=G.executeUserOpWithErrorString,I.executorFunctionInputAbi=["address","uint256","bytes","uint8"];var B=/*#__PURE__*/function(e){function t(t){var r;return(r=e.call(this)||this).rpcUrl=void 0,r.entrypointAddress=void 0,r.supportedTokens=void 0,r.paymasterMetadata=void 0,r.rpcUrl=t,r}u(t,e);var r=t.prototype;return r.initialize=function(){try{var e=this;return Promise.resolve(N(function(){return Promise.resolve(e.getSupportedEntrypoint()).then(function(t){return e.entrypointAddress=t,Promise.resolve(e.getSupportedERC20TokensAndPaymasterMetadata()).then(function(t){return e.supportedTokens=t.tokens,e.paymasterMetadata=t.paymasterMetadata,null})})},function(e){var t=y(e);throw new m("PAYMASTER_ERROR","failed initializing the paymaster",{cause:t})}))}catch(e){return Promise.reject(e)}},r.getPaymasterMetaData=function(){try{var e=function(){return t.paymasterMetadata},t=this,r=function(){if(null==t.paymasterMetadata)return Promise.resolve(t.initialize()).then(function(){})}();return Promise.resolve(r&&r.then?r.then(e):e())}catch(e){return Promise.reject(e)}},r.getSupportedERC20TokensAndPaymasterMetadata=function(){try{var e=this;return Promise.resolve(null==e.supportedTokens||null==e.paymasterMetadata?N(function(){return Promise.resolve(P(e.rpcUrl,"pm_supportedERC20Tokens",[])).then(function(e){return{tokens:e.tokens,paymasterMetadata:e.paymasterMetadata}})},function(e){var t=y(e);throw new m("PAYMASTER_ERROR","getSupportedERC20TokensAndPaymasterMetadata failed",{cause:t})}):{tokens:e.supportedTokens,paymasterMetadata:e.paymasterMetadata})}catch(e){return Promise.reject(e)}},r.getSupportedEntrypoint=function(){try{var e=this;return Promise.resolve(null==e.entrypointAddress?N(function(){return Promise.resolve(P(e.rpcUrl,"pm_supportedEntryPoint",[]))},function(e){var t=y(e);throw new m("PAYMASTER_ERROR","getSupportedEntrypoint failed",{cause:t})}):e.entrypointAddress)}catch(e){return Promise.reject(e)}},r.isSupportedERC20Token=function(e){try{var t=function(){return!!r.supportedTokens.find(function(t){return t.address===e.toLowerCase()})},r=this,n=function(){if(null==r.entrypointAddress||null==r.supportedTokens||null==r.paymasterMetadata)return Promise.resolve(r.initialize()).then(function(){})}();return Promise.resolve(n&&n.then?n.then(t):t())}catch(e){return Promise.reject(e)}},r.getSupportedERC20TokenData=function(e){try{var t=function(){var t=r.supportedTokens.find(function(t){return t.address.toLowerCase()===e.toLowerCase()});return t?{symbol:t.symbol,address:t.address,decimal:Number(t.decimal),fee:BigInt(t.fee),exchangeRate:BigInt(t.exchangeRate)}:null},r=this,n=function(){if(null==r.entrypointAddress||null==r.supportedTokens||null==r.paymasterMetadata)return Promise.resolve(r.initialize()).then(function(){})}();return Promise.resolve(n&&n.then?n.then(t):t())}catch(e){return Promise.reject(e)}},r.createPaymasterUserOperation=function(e,t,r,n){void 0===r&&(r={});try{var i=function(){return N(function(){e.paymasterAndData=a.paymasterMetadata.dummyPaymasterAndData;var i=new T(t);return Promise.resolve(i.estimateUserOperationGas(e,a.entrypointAddress,n)).then(function(t){return e.preVerificationGas=t.preVerificationGas,e.verificationGasLimit=t.verificationGasLimit+10000n,e.callGasLimit=t.callGasLimit,Promise.resolve(P(a.rpcUrl,"pm_sponsorUserOperation",[e,a.entrypointAddress,r])).then(function(t){var r,n,i,a,o,s=t,f={paymasterAndData:s.paymasterAndData,callGasLimit:null==s.callGasLimit?void 0:BigInt(s.callGasLimit),preVerificationGas:null==s.preVerificationGas?void 0:BigInt(s.preVerificationGas),verificationGasLimit:null==s.verificationGasLimit?void 0:BigInt(s.verificationGasLimit),maxFeePerGas:null==s.maxFeePerGas?void 0:BigInt(s.maxFeePerGas),maxPriorityFeePerGas:null==s.maxPriorityFeePerGas?void 0:BigInt(s.maxPriorityFeePerGas)};return e.paymasterAndData=f.paymasterAndData,e.callGasLimit=null!=(r=f.callGasLimit)?r:e.callGasLimit,e.preVerificationGas=null!=(n=f.preVerificationGas)?n:e.preVerificationGas,e.verificationGasLimit=null!=(i=f.verificationGasLimit)?i:e.verificationGasLimit,e.maxFeePerGas=null!=(a=f.maxFeePerGas)?a:e.maxFeePerGas,e.maxPriorityFeePerGas=null!=(o=f.maxPriorityFeePerGas)?o:e.maxPriorityFeePerGas,e})})},function(e){var t=y(e);throw new m("PAYMASTER_ERROR","pm_sponsorUserOperation failed",{cause:t})})},a=this,o=function(){if(null==a.entrypointAddress||null==a.supportedTokens||null==a.paymasterMetadata)return Promise.resolve(a.initialize()).then(function(){})}();return Promise.resolve(o&&o.then?o.then(i):i())}catch(e){return Promise.reject(e)}},r.createSponsorPaymasterUserOperation=function(e,t,r){try{return Promise.resolve(this.createPaymasterUserOperation(e,t,{},r))}catch(e){return Promise.reject(e)}},r.createTokenPaymasterUserOperation=function(e,t,r,n,i){void 0===i&&(i={});try{var a=this;return Promise.resolve(a.calculateUserOperationErc20TokenMaxGasCost(t,r)).then(function(o){var s=2n*o;return Promise.resolve(a.getPaymasterMetaData()).then(function(o){var f=e.prependTokenPaymasterApproveToCallData(t.callData,r,o.address,s);return t.callData=f,Promise.resolve(a.createPaymasterUserOperation(t,n,{token:r},i))})})}catch(e){return Promise.reject(e)}},r.calculateUserOperationErc20TokenMaxGasCost=function(e,t){try{var r=this;return Promise.resolve(r.getSupportedERC20TokenData(t)).then(function(n){if(null==n)return Promise.resolve(r.getSupportedERC20TokensAndPaymasterMetadata()).then(function(e){throw new m("PAYMASTER_ERROR",t+" token is not supported by the paymaster.",{context:{supportedERC20TokensAndPaymasterMetadata:JSON.stringify(e)}})});var i=E(e);return n.exchangeRate*i/BigInt(Math.pow(10,18))})}catch(e){return Promise.reject(e)}},t}(function(){}),k={__proto__:null,SmartAccount:s,SafeAccountV0_2_0:I,SendUseroperationResponse:C,SmartAccountFactory:_,SafeAccountFactory:S,Bundler:T,CandidePaymaster:B,createUserOperationHash:g,createCallData:b,getFunctionSelector:D,fetchAccountNonce:A,calculateUserOperationMaxGasCost:E,get Operation(){return e.Operation}};e.Bundler=T,e.CandidePaymaster=B,e.SafeAccountFactory=S,e.SafeAccountV0_2_0=I,e.SendUseroperationResponse=C,e.SmartAccount=s,e.SmartAccountFactory=_,e.abstractionkit=k,e.calculateUserOperationMaxGasCost=E,e.createCallData=b,e.createUserOperationHash=g,e.fetchAccountNonce=A,e.getFunctionSelector=D});

@@ -1,9 +0,6 @@

import "ethers";
import type { BytesLike } from "ethers";
import type { UserOperation, JsonRpcError } from "../types";
import type { UserOperation, StateOverrideSet } from "../types";
import { CandidePaymasterContext } from "./types";
export declare abstract class Paymaster {
abstract getPaymasterCallData(userOperation: UserOperation, config: string[]): Promise<{
paymasterAndData: BytesLike;
} | JsonRpcError>;
abstract createPaymasterUserOperation(userOperation: UserOperation, bundlerRpc: string, context: CandidePaymasterContext, state_override_set?: StateOverrideSet): Promise<UserOperation>;
}
//# sourceMappingURL=Paymaster.d.ts.map

@@ -1,31 +0,34 @@

import type { BigNumberish, BytesLike } from "ethers";
export type UserOperation = {
sender: string;
nonce: BigNumberish;
initCode: BytesLike;
callData: BytesLike;
callGasLimit: BigNumberish;
verificationGasLimit: BigNumberish;
preVerificationGas: BigNumberish;
maxFeePerGas: BigNumberish;
maxPriorityFeePerGas: BigNumberish;
paymasterAndData: BytesLike;
signature: BytesLike;
nonce: bigint;
initCode: string;
callData: string;
callGasLimit: bigint;
verificationGasLimit: bigint;
preVerificationGas: bigint;
maxFeePerGas: bigint;
maxPriorityFeePerGas: bigint;
paymasterAndData: string;
signature: string;
};
export type AbiInputValue = string | BigNumberish | BytesLike | boolean | AbiInputValue[];
export type JsonRpcParam = string | BigNumberish | BytesLike | boolean | object | JsonRpcParam[];
export type AbiInputValue = string | bigint | number | boolean | AbiInputValue[];
export type JsonRpcParam = string | bigint | boolean | object | JsonRpcParam[];
export type JsonRpcResponse = {
id: number;
id: number | null;
jsonrpc: string;
result?: JsonRpcResult;
error?: JsonRpcError;
};
export type JsonRpcResult = string | string[] | GasEstimationResult | UserOperationByHashResult | UserOperationReceipt | UserOperationReceiptResult | SupportedERC20Tokens | PmSponsorUserOperationResult;
export type ChainIdResult = string;
export type SupportedEntryPointsResult = string[];
export type JsonRpcResult = ChainIdResult | SupportedEntryPointsResult | GasEstimationResult | UserOperationByHashResult | UserOperationReceipt | UserOperationReceiptResult | SupportedERC20TokensAndMetadata | PmUserOperationResult;
export type JsonRpcError = {
code: number;
message: string;
data: object;
};
export type GasEstimationResult = {
callGasLimit: BigNumberish;
preVerificationGas: BigNumberish;
verificationGasLimit: BigNumberish;
callGasLimit: bigint;
preVerificationGas: bigint;
verificationGasLimit: bigint;
};

@@ -35,37 +38,38 @@ export type UserOperationByHashResult = {

entryPoint: string;
blockNumber: BigNumberish;
blockHash: BytesLike;
transactionHash: BytesLike;
};
blockNumber: bigint | null;
blockHash: string | null;
transactionHash: string | null;
} | null;
export type UserOperationReceipt = {
blockHash: BytesLike;
blockNumber: BigNumberish;
blockHash: string;
blockNumber: bigint;
from: string;
cumulativeGasUsed: BigNumberish;
gasUsed: BigNumberish;
cumulativeGasUsed: bigint;
gasUsed: bigint;
logs: string;
logsBloom: string;
transactionHash: BytesLike;
transactionIndex: BigNumberish;
transactionHash: string;
transactionIndex: bigint;
effectiveGasPrice?: bigint;
};
export type UserOperationReceiptResult = {
userOpHash: BytesLike;
userOpHash: string;
entryPoint: string;
sender: string;
nonce: BigNumberish;
nonce: bigint;
paymaster: string;
actualGasCost: BigNumberish;
actualGasUsed: BigNumberish;
success: string;
actualGasCost: bigint;
actualGasUsed: bigint;
success: boolean;
logs: string;
receipt: UserOperationReceipt;
} | null;
export type PmUserOperationResult = {
paymasterAndData: string;
callGasLimit?: bigint;
preVerificationGas?: bigint;
verificationGasLimit?: bigint;
maxFeePerGas?: bigint;
maxPriorityFeePerGas?: bigint;
};
export type PmSponsorUserOperationResult = {
paymasterAndData: BytesLike;
callGasLimit?: BigNumberish;
preVerificationGas?: BigNumberish;
verificationGasLimit?: BigNumberish;
maxFeePerGas?: BigNumberish;
maxPriorityFeePerGas?: BigNumberish;
};
export declare enum Operation {

@@ -75,2 +79,8 @@ Call = 0,

}
export interface MetaTransaction {
to: string;
value: bigint;
data: string;
operation?: Operation;
}
export interface ERC20Token {

@@ -80,4 +90,4 @@ symbol: string;

decimal: number;
fee: number;
exchangeRate: string;
fee: bigint;
exchangeRate: bigint;
}

@@ -92,6 +102,24 @@ export interface PaymasterMetadata {

}
export interface SupportedERC20Tokens {
export interface SupportedERC20TokensAndMetadata {
paymasterMetadata: PaymasterMetadata;
tokens: ERC20Token[];
}
export interface Dictionary<T> {
[Key: string]: T;
}
export type AddressToState = {
balance?: bigint;
nonce?: bigint;
code?: string;
state?: Dictionary<string>;
stateDiff?: Dictionary<string>;
};
export type StateOverrideSet = {
[key: string]: AddressToState;
};
export declare enum GasOption {
Slow = 1,
Medium = 1.2,
Fast = 1.5
}
//# sourceMappingURL=types.d.ts.map

@@ -1,8 +0,10 @@

import type { BytesLike, BigNumberish } from "ethers";
import type { AbiInputValue, UserOperation, JsonRpcResponse, JsonRpcParam } from "./types";
export declare function getUserOperationHash(useroperation: UserOperation, entrypointAddress: string, chainId: BigNumberish): BytesLike;
export declare function getPackedUserOperation(useroperation: UserOperation): BytesLike;
export declare function getCallData(functionSelector: string, functionInputAbi: string[], functionInputParameters: AbiInputValue[]): BytesLike;
export declare function sendJsonRpcRequest(rpcUrl: string, method: string, params: JsonRpcParam): Promise<JsonRpcResponse>;
import { AbiInputValue, UserOperation, JsonRpcParam, GasOption, JsonRpcResult } from "./types";
export declare function createUserOperationHash(useroperation: UserOperation, entrypointAddress: string, chainId: bigint): string;
export declare function createPackedUserOperation(useroperation: UserOperation): string;
export declare function createCallData(functionSelector: string, functionInputAbi: string[], functionInputParameters: AbiInputValue[]): string;
export declare function sendJsonRpcRequest(rpcUrl: string, method: string, params: JsonRpcParam): Promise<JsonRpcResult>;
export declare function getFunctionSelector(functionSignature: string): string;
export declare function fetchAccountNonce(rpcUrl: string, entryPoint: string, account: string, key?: number): Promise<bigint>;
export declare function fetchGasPrice(provideRpc: string, gasLevel?: GasOption): Promise<[bigint, bigint]>;
export declare function calculateUserOperationMaxGasCost(useroperation: UserOperation): bigint;
//# sourceMappingURL=utils.d.ts.map

@@ -7,3 +7,3 @@ {

},
"version": "0.0.9",
"version": "0.1.0",
"description": "Account Abstraction 4337 SDK by Candidelabs",

@@ -17,4 +17,4 @@ "main": "dist/index.js",

"clean": "rm -rf dist",
"format": "prettier --write src/**/*.ts",
"lint": "eslint src/**/*.ts",
"format": "prettier --write src/*.ts src/**/*.ts src/**/**/*.ts",
"lint": "eslint -f unix \"src/**/*.{ts,tsx}\"",
"prepare": "husky install"

@@ -51,2 +51,3 @@ },

"eslint": "^8.46.0",
"eslint-plugin-tsdoc": "^0.2.17",
"husky": ">=6",

@@ -53,0 +54,0 @@ "lint-staged": ">=10",

<!-- PROJECT LOGO -->
<div align="center">
<img src="https://github.com/candidelabs/abstractionkit/assets/7014833/8f28ba83-003c-4ea9-b205-99f38819e09c">
<img src="https://github.com/candidelabs/abstractionkit/assets/7014833/6af73235-3f6b-4cb1-8a57-6b04ba2bf327">
</div>

@@ -12,7 +12,7 @@

Abstraction Kit is agnostic of:
- Ethereum **interface libraries**: ethers, web3.js, viem/wagmi
- **Bundler** implentation: Plug and play from any bundler provider
- **Paymaster**: use any 3rd party paymaster to sponsor gas, or build your own
- **Accounts**: Safe Account are supported, but you can use use Bundlers and Paymasters with your own accounts
AbstractionKit is agnostic of:
- **Ethereum interface libraries**: ethers, web3.js, viem/wagmi
- **Bundlers**: Plug and play from any bundler provider
- **Paymasters**: Candide Paymaster is supported , but you can use any 3rd party paymaster to sponsor gas
- **Accounts**: The Safe Account first class supported, but you can use use Bundlers and Paymasters with any account

@@ -31,20 +31,17 @@ ## Docs

### Smart Accounts
### Safe Account
Abstraction Kit currently features the Candide Account, a compliant EIP-4337 smart contract account based on Safe v1.4.0 contracts.
AbstractionKit features the Safe Account. It uses the original Safe Singleton and adds ERC-4337 functionality using a fallback handler module. The contracts have been developed by the Safe Team. It has been audited by Ackee Blockchain. To learn more about the contracts and audits, visit [safe-global/safe-modules](https://github.com/safe-global/safe-modules/tree/main/modules/4337).
In the next releases, it will feature Safe Accounts with the new architecture of Safe{Core}Protocol.
```typescript
import { CandideAccount } from "abstractionkit";
import { SafeAccountV0_2_0 as SafeAccount } from "abstractionkit";
const smartAccount = new CandideAccount();
const ownerPublicAddress = "0xBdbc5FBC9cA8C3F514D073eC3de840Ac84FC6D31";
const smartAccount = SafeAccount.initializeNewAccount([ownerPublicAddress]);
```
Then you can consume accout methods:
```typescript
import { Wallet } from "ethers";
const eoaSigner = new Wallet(privateKey);
const [newAccountAddress, initCode] = smartAccount.createNewAccount([
eoaSigner.address,
]);
const safeAddress = smartAccount.accountAddress;
```

@@ -54,3 +51,3 @@

Initialize a Bundler with your desired bundler RPC url
Initialize a Bundler with your desired bundler RPC url. Find more public bundler endpoints on our [docs](https://docs.candide.dev/wallet/bundler/rpc-endpoints/)
```typescript

@@ -60,5 +57,4 @@ import { Bundler } from "abstractionkit";

const bundlerRPC = "https://sepolia.voltaire.candidewallet.com/rpc";
const entrypointAddress = "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789";
const bundler: Bundler = new Bundler(bundlerRPC, entrypointAddress);
const bundler: Bundler = new Bundler(bundlerRPC);
```

@@ -72,13 +68,9 @@ Then you can consume Bundler methods:

### Paymaster
Initialize a Paymaster with your RPC url
Initialize a Candide Paymaster with your RPC url. Get one from the [dashboard](https://dashboard.candide.dev).
```typescript
import { CandideValidationPaymaster } from "abstractionkit";
import { CandidePaymaster } from "abstractionkit";
const paymasterRpc = "https://api.candide.dev/paymaster/v1/$network/$apikey";
const entrypointAddress = "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789";
const paymasterRpc = "https://api.candide.dev/paymaster/$version/$network/$apikey";
const paymaster: CandideValidationPaymaster = new CandideValidationPaymaster(
entrypointAddress,
paymasterRPC
);
const paymaster: CandidePaymaster = new CandidePaymaster(paymasterRPC);
```

@@ -88,3 +80,3 @@ Then you can consume Paymaster methods:

```typescript
const supportedGasTokens = await paymaster.getSupportedERC20Tokens();
const erc20s = await paymaster.getSupportedERC20TokensAndPaymasterMetadata();
```

@@ -91,0 +83,0 @@

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc