abstractionkit
Advanced tools
Comparing version 0.1.10 to 0.1.11
export { SmartAccount } from "./account/SmartAccount"; | ||
export { SocialRecoveryModule, RecoveryRequest } from "./account/Safe/modules/SocialRecoveryModule"; | ||
export { SafeAccountV0_2_0 } from "./account/Safe/SafeAccountV0_2_0"; | ||
export { SafeAccountWebAuth } from "./account/Safe/SafeAccountWebAuth"; | ||
export { SendUseroperationResponse } from "./account/SendUseroperationResponse"; | ||
@@ -9,3 +11,3 @@ export { SmartAccountFactory } from "./factory/SmartAccountFactory"; | ||
export { createUserOperationHash, createCallData, getFunctionSelector, fetchAccountNonce, calculateUserOperationMaxGasCost, } from "./utils"; | ||
export { CreateUserOperationOverrides, InitCodeOverrides, SafeModuleExecutorFunctionSelector, SafeUserOperationTypedDataDomain, SafeUserOperationTypedDataValues, } from "./account/Safe/types"; | ||
export { CreateUserOperationOverrides, InitCodeOverrides, SafeModuleExecutorFunctionSelector, SafeUserOperationTypedDataDomain, SafeUserOperationTypedDataValues, WebauthPublicKey, DummySignature, WebauthSignatureData, SignerSignaturePair } from "./account/Safe/types"; | ||
export { CandidePaymasterContext, PrependTokenPaymasterApproveAccount, } from "./paymaster/types"; | ||
@@ -12,0 +14,0 @@ export { UserOperation, AbiInputValue, JsonRpcParam, JsonRpcResponse, JsonRpcResult, GasEstimationResult, UserOperationByHashResult, UserOperationReceipt, UserOperationReceiptResult, JsonRpcError, StateOverrideSet, Operation, MetaTransaction, } from "./types"; |
@@ -1,26 +0,6 @@ | ||
import { SmartAccount } from "../SmartAccount"; | ||
import { MetaTransaction, Operation, StateOverrideSet, UserOperation } from "../../types"; | ||
import { SafeAccountFactory } from "../../factory/SafeAccountFactory"; | ||
import { CreateUserOperationOverrides, InitCodeOverrides, SafeModuleExecutorFunctionSelector } from "./types"; | ||
import { SendUseroperationResponse } from "../SendUseroperationResponse"; | ||
export declare class SafeAccountV0_2_0 extends SmartAccount { | ||
static readonly DEFAULT_ENTRYPOINT_ADDRESS = "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"; | ||
static readonly DEFAULT_SAFE_4337_MODULE_ADDRESS = "0xa581c4A4DB7175302464fF3C06380BC3270b4037"; | ||
static readonly DEFAULT_SINGLETON_ADDRESS = "0x29fcB43b46531BcA003ddC8FCB67FFE91900C762"; | ||
static readonly DEFAULT_ADD_MODULE_LIB_ADDRESS = "0x8EcD4ec46D4D2a6B64fE960B3D64e8B94B2234eb"; | ||
static readonly DEFAULT_MULTISEND_CONTRACT_ADDRESS = "0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526"; | ||
static readonly proxyByteCode: string; | ||
static readonly initializerFunctionSelector: string; | ||
static readonly initializerFunctionInputAbi: string[]; | ||
static readonly DEFAULT_EXECUTOR_FUCNTION_SELECTOR = SafeModuleExecutorFunctionSelector.executeUserOpWithErrorString; | ||
static readonly executorFunctionInputAbi: string[]; | ||
static readonly EIP712_SAFE_OPERATION_TYPE: { | ||
SafeOp: { | ||
type: string; | ||
name: string; | ||
}[]; | ||
}; | ||
readonly entrypointAddress: string; | ||
readonly safe4337ModuleAddress: string; | ||
private initCode; | ||
import { SafeAccount } from "./SafeAccount"; | ||
import { MetaTransaction, StateOverrideSet, UserOperation } from "../../types"; | ||
import { CreateUserOperationOverrides, InitCodeOverrides } from "./types"; | ||
import { SafeAccountFactory } from "src/factory/SafeAccountFactory"; | ||
export declare class SafeAccountV0_2_0 extends SafeAccount { | ||
constructor(accountAddress: string, safe4337ModuleAddress?: string, entrypointAddress?: string); | ||
@@ -30,18 +10,9 @@ static initializeNewAccount(owners: string[], overrides?: InitCodeOverrides): SafeAccountV0_2_0; | ||
static createAccountAddressAndInitCode(owners: string[], overrides?: InitCodeOverrides): [string, string]; | ||
private static createInitializerCallData; | ||
protected static createInitializerCallData(owners: string[], threshold: number, safe4337ModuleAddress?: string, addModuleLibAddress?: string): string; | ||
static createInitCode(owners: string[], threshold?: number, c2Nonce?: bigint, singletonAddress?: string, safeAccountFactory?: SafeAccountFactory, safe4337ModuleAddress?: string, addModuleLibAddress?: string): string; | ||
static createProxyAddress(initializerCallData: string, c2Nonce: bigint, safeFactoryAddress: string, singletonAddress: string): string; | ||
static createAccountCallDataSingleTransaction(metaTransaction: MetaTransaction): string; | ||
static createAccountCallDataBatchTransactions(metaTransactions: MetaTransaction[], multisendContractAddress?: string): string; | ||
static createAccountCallData(to: string, value: bigint, data: string, operation: Operation, safeModuleExecutorFunctionSelector?: SafeModuleExecutorFunctionSelector): string; | ||
static decodeAccountCallData(callData: string): [string, bigint, string, number]; | ||
prependTokenPaymasterApproveToCallData(callData: string, tokenAddress: string, paymasterAddress: string, approveAmount: bigint, multisendContractAddress?: string): string; | ||
static prependTokenPaymasterApproveToCallDataStatic(callData: string, tokenAddress: string, paymasterAddress: string, approveAmount: bigint, multisendContractAddress?: string): string; | ||
estimateUserOperationGas(userOperation: UserOperation, bundlerRpc: string, state_override_set?: StateOverrideSet, numberOfSigners?: number): Promise<[bigint, bigint, bigint]>; | ||
createUserOperation(transactions: MetaTransaction[], providerRpc?: string, bundlerRpc?: string, overrids?: CreateUserOperationOverrides): Promise<UserOperation>; | ||
signUserOperation(useroperation: UserOperation, privateKeys: string[], chainId: bigint, validAfter?: bigint, validUntil?: bigint): string; | ||
static formatEip712SignaturesToUseroperationSignature(signersAddresses: string[], signatures: string[], validAfter?: bigint, validUntil?: bigint): string; | ||
static formatEip712SingleSignatureToUseroperationSignature(signature: string, validAfter?: bigint, validUntil?: bigint): string; | ||
sendUserOperation(userOperation: UserOperation, bundlerRpc: string): Promise<SendUseroperationResponse>; | ||
} | ||
//# sourceMappingURL=SafeAccountV0_2_0.d.ts.map |
@@ -18,2 +18,3 @@ import type { StateOverrideSet } from "../../types"; | ||
state_override_set?: StateOverrideSet; | ||
dummySignatures?: DummySignature[] | null; | ||
} | ||
@@ -51,2 +52,23 @@ export interface InitCodeOverrides { | ||
} | ||
export type ECDSAPublicAddress = string; | ||
export interface WebauthPublicKey { | ||
x: bigint; | ||
y: bigint; | ||
} | ||
export type Signer = ECDSAPublicAddress | WebauthPublicKey; | ||
export declare enum DummySignature { | ||
eoa = "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", | ||
webAuthn = "5715d3b8fc6e09d43d24175720e98c1ed970661400000000000000000000000000000000000000000000000000000000000000410000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e0762c7349c04b09b85aa0b0d21ba70df2195d60c653877df252a16c3f62559fa02d0dbe584b8a794bcf5fc5263f42cf8d50d200c3bc15fe375508e24ca97002ad000000000000000000000000000000000000000000000000000000000000002549960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d9763050000000e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a1226f726967696e223a22687474703a2f2f6c6f63616c686f73743a35313733222c2263726f73734f726967696e223a66616c73652c226f746865725f6b6579735f63616e5f62655f61646465645f68657265223a22646f206e6f7420636f6d7061726520636c69656e74446174614a534f4e20616761696e737420612074656d706c6174652e205365652068747470733a2f2f676f6f2e676c2f7961625065782200000000000000000000000000000000000000000000000000000000000000" | ||
} | ||
export type ECDSASignature = string; | ||
export interface WebauthSignatureData { | ||
authenticatorData: ArrayBuffer; | ||
clientDataFields: string; | ||
rs: [bigint, bigint]; | ||
} | ||
export interface SignerSignaturePair { | ||
signer: Signer; | ||
signature: string; | ||
isContractSignature?: boolean; | ||
} | ||
//# sourceMappingURL=types.d.ts.map |
@@ -1,1 +0,1 @@ | ||
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 c(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,u(e,t)}function f(e){return f=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},f(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,f(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"},v=/*#__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 c(t,e),t}(/*#__PURE__*/l(Error));function h(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 v("BAD_DATA","getNonce returned ill formed data",{context:JSON.stringify(e)});try{return BigInt(e)}catch(e){var t=h(e);throw new v("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=h(e);throw new v("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 v(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 G(e){return(e.callGasLimit+e.verificationGasLimit*("0x"==e.paymasterAndData||null==e.paymasterAndData?3n:0n)+e.preVerificationGas)*e.maxFeePerGas}var E,D="0x0000000000000000000000000000000000000000",b={sender:D,nonce:0n,initCode:"0x",callData:"0x",callGasLimit:0n,verificationGasLimit:0n,preVerificationGas:0n,maxFeePerGas:0n,maxPriorityFeePerGas:0n,paymasterAndData:"0x",signature:"0x"},x=/*#__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}(),S=/*#__PURE__*/function(e){function t(t){return void 0===t&&(t="0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67"),e.call(this,t,"0x1688f0b9",["address","bytes","uint256"])||this}return c(t,e),t}(x);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 O(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}exports.SafeModuleExecutorFunctionSelector=void 0,(E=exports.SafeModuleExecutorFunctionSelector||(exports.SafeModuleExecutorFunctionSelector={})).executeUserOpWithErrorString="0x541d63c8",E.executeUserOp="0x7bb37428";var F=/*#__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(O(function(){return Promise.resolve(y(e.rpcUrl,"eth_chainId",[])).then(function(e){if("string"==typeof e)return e;throw new v("BAD_DATA","bundler eth_chainId rpc call failed")})},function(e){var t=h(e);throw new v("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(O(function(){return Promise.resolve(y(e.rpcUrl,"eth_supportedEntryPoints",[]))},function(e){var t=h(e);throw new v("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(O(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=h(e);throw new v("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(O(function(){return Promise.resolve(y(r.rpcUrl,"eth_sendUserOperation",[e,t]))},function(e){var t=h(e);throw new v("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(O(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=h(t);throw new v("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(O(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=h(t);throw new v("BUNDLER_ERROR","bundler eth_getUserOperationByHash rpc call failed",{cause:r,context:{useroperationhash:e}})}))}catch(e){return Promise.reject(e)}},e}();function _(e,t,r){if(!e.s){if(r instanceof L){if(!r.s)return void(r.o=_.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(_.bind(null,e,t),_.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{_(n,1,a(this.v))}catch(e){_(n,2,e)}return n}return this}return this.o=function(e){try{var i=e.v;1&e.s?_(n,1,t?t(i):i):r?_(n,1,r(i)):_(n,2,i)}catch(e){_(n,2,e)}},n},e}();function T(e){return e instanceof L&&1&e.s}var U=/*#__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 v("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(T(i)&&(i=i.v),!i)return a;if(i.then){n=0;break}var a=r();if(a&&a.then){if(!T(a)){n=1;break}a=a.s}if(t){var o=t();if(o&&o.then&&!T(o)){n=2;break}}}var s=new L,c=_.bind(null,s,2);return(0===n?i.then(u):1===n?a.then(f):o.then(l)).then(void 0,c),s;function f(n){a=n;do{if(t&&(o=t())&&o.then&&!T(o))return void o.then(l).then(void 0,c);if(!(i=e())||T(i)&&!i.v)return void _(s,1,a);if(i.then)return void i.then(u).then(void 0,c);T(a=r())&&(a=a.v)}while(!a||!a.then);a.then(f).then(void 0,c)}function u(e){e?(a=r())&&a.then?a.then(f).then(void 0,c):f(a):_(s,1,a)}function l(){(i=e())?i.then?i.then(u).then(void 0,c):u(i):_(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}c(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.createAccountAddress=function(e,t){return void 0===t&&(t={}),r.createAccountAddressAndInitCode(e,t)[0]},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 c=null!=(n=t.threshold)?n:1,f=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 S;null!=t.safeAccountFactoryAddress&&(p=new S(t.safeAccountFactoryAddress));var v=r.createInitializerCallData(e,c,l,d);return[this.createProxyAddress(v,f,p.address,u),p.getFactoryGeneratorFunctionCallData([u,v,f])]},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,D,0,D])},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 S),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 c=r.createInitializerCallData(e,t,o,s);return a.getFactoryGeneratorFunctionCallData([i,c,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]),c=e.keccak256(e.solidityPacked(["bytes","bytes"],[this.proxyByteCode,s]));return"0x"+e.solidityPackedKeccak256(["bytes1","address","bytes32","bytes32"],["0xff",n,o,c]).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])},r.decodeAccountCallData=function(t){if(t.startsWith(exports.SafeModuleExecutorFunctionSelector.executeUserOpWithErrorString)||t.startsWith(exports.SafeModuleExecutorFunctionSelector.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 v("BAD_DATA","Invalid calldata, should start with "+exports.SafeModuleExecutorFunctionSelector.executeUserOpWithErrorString+" or "+exports.SafeModuleExecutorFunctionSelector.executeUserOp,{context:{callData:t}})};var i=r.prototype;return i.prependTokenPaymasterApproveToCallData=function(e,t,n,i,a){return void 0===a&&(a=r.DEFAULT_MULTISEND_CONTRACT_ADDRESS),r.prependTokenPaymasterApproveToCallDataStatic(e,t,n,i,a)},r.prependTokenPaymasterApproveToCallDataStatic=function(t,n,i,a,o){void 0===o&&(o=r.DEFAULT_MULTISEND_CONTRACT_ADDRESS);var s=r.decodeAccountCallData(t),c=s[0],f=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}]),v="",h="0x8d80ff0a";if(d.startsWith(h)){var m=function(t){return e.AbiCoder.defaultAbiCoder().decode(["bytes"],"0x"+t.slice(10))[0]}(d);v=m+p.slice(2)}else v=R([{to:c,value:f,data:u,operation:l}])+p.slice(2);var y=P(h,["bytes"],[v]);return r.createAccountCallData(o,0n,y,exports.Operation.Delegate)},i.estimateUserOperationGas=function(e,t,r,n){void 0===n&&(n=1);try{if(n<1n)throw RangeError("numberOfSigners can't be less than 1");for(var i="",a=0;a<n;a++)i+="ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff";e.signature="0xffffffffffffffffffffffff"+i;var o=new F(t),s=e.maxFeePerGas,c=e.maxPriorityFeePerGas;return e.maxFeePerGas=0n,e.maxPriorityFeePerGas=0n,Promise.resolve(o.estimateUserOperationGas(e,this.entrypointAddress,r)).then(function(t){return e.maxFeePerGas=s,e.maxPriorityFeePerGas=c,[BigInt(t.preVerificationGas),BigInt(t.verificationGasLimit)+30000n*BigInt(n),BigInt(t.callGasLimit)]})}catch(e){return Promise.reject(e)}},i.createUserOperation=function(t,i,a,o){void 0===o&&(o={});try{var c=function(c){var l;function d(e){var t,r,n,i;function c(e){var t,r,n,i,a,s;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 l.preVerificationGas=null!=(t=o.preVerificationGas)?t:d*BigInt(Math.floor(((null!=(r=o.preVerificationGasPercentageMultiplier)?r:0)+100)/100)),l.verificationGasLimit=null!=(n=o.verificationGasLimit)?n:A*BigInt(Math.floor(((null!=(i=o.verificationGasLimitPercentageMultiplier)?i:0)+100)/100)),l.callGasLimit=null!=(a=o.callGasLimit)?a:P*BigInt(Math.floor(((null!=(s=o.callGasLimitPercentageMultiplier)?s:0)+100)/100)),l}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");m=null!=(t=o.maxFeePerGas)?t:m*BigInt(Math.floor(((null!=(r=o.maxFeePerGasPercentageMultiplier)?r:0)+100)/100)),y=null!=(n=o.maxPriorityFeePerGas)?n:y*BigInt(Math.floor(((null!=(i=o.maxPriorityFeePerGasPercentageMultiplier)?i:0)+100)/100));var l=s({},b,{sender:f.accountAddress,nonce:u,initCode:p,callData:h,maxFeePerGas:m,maxPriorityFeePerGas:y}),d=b.preVerificationGas,A=b.verificationGasLimit,P=b.callGasLimit,g=function(){if(null==o.preVerificationGas||null==o.verificationGasLimit||null==o.callGasLimit)return function(){if(null!=a){l.callGasLimit=0n,l.verificationGasLimit=0n,l.preVerificationGas=0n;var e=l.maxFeePerGas,t=l.maxPriorityFeePerGas;return l.maxFeePerGas=0n,l.maxPriorityFeePerGas=0n,Promise.resolve(f.estimateUserOperationGas(l,a,o.state_override_set,o.numberOfSigners)).then(function(r){d=r[0],A=r[1],P=r[2],l.maxFeePerGas=e,l.maxPriorityFeePerGas=t})}throw new v("BAD_DATA","bundlerRpc cant't be null if preVerificationGas,verificationGasLimit and callGasLimit are not overriden")}()}();return g&&g.then?g.then(c):c()}var p=null!=(l=o.initCode)?l:f.initCode;if((null==p||u>0n)&&(p="0x"),u<0n)throw RangeError("nonce can't be negative");var h="0x";h=null==o.callData?1==t.length?r.createAccountCallDataSingleTransaction(t[0]):r.createAccountCallDataBatchTransactions(t):o.callData;var m=b.maxFeePerGas,y=b.maxPriorityFeePerGas,A=function(){if(null==o.maxFeePerGas||null==o.maxPriorityFeePerGas)return function(){if(null!=i)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){0n==(m=e[0])&&(m=1n),0n==(y=e[1])&&(y=1n)});throw new v("BAD_DATA","providerRpc cant't be null if maxFeePerGas and maxPriorityFeePerGas are not overriden")}()}();return A&&A.then?A.then(d):d()},f=this;if(t.length<1)throw RangeError("There should be at least one transaction");var u=0n,l=function(){if(null==o.nonce)return function(){if(null!=i)return Promise.resolve(m(i,f.entrypointAddress,f.accountAddress)).then(function(e){u=e});throw new v("BAD_DATA","providerRpc cant't be null if nonce is not overriden")}();u=o.nonce}();return Promise.resolve(l&&l.then?l.then(c):c())}catch(e){return Promise.reject(e)}},i.signUserOperation=function(t,n,i,a,o){if(void 0===a&&(a=0n),void 0===o&&(o=0n),n.length<1)throw RangeError("There should be at least one privateKey");if(i<0n)throw RangeError("chainId can't be negative");if(a<0n)throw RangeError("validAfter can't be negative");if(o<0n)throw RangeError("validUntil can't be negative");for(var s,c={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:a,validUntil:o,entryPoint:this.entrypointAddress},f={chainId:i,verifyingContract:this.safe4337ModuleAddress},u=[],l=[],p=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.")}(n);!(s=p()).done;){var v=new e.Wallet(s.value),h=v.signingKey.sign(e.TypedDataEncoder.hash(f,r.EIP712_SAFE_OPERATION_TYPE,c)).serialized;u.push(v.address),l.push(h)}return r.formatEip712SignaturesToUseroperationSignature(u,l,a,o)},r.formatEip712SignaturesToUseroperationSignature=function(e,t,n,i){if(void 0===n&&(n=0n),void 0===i&&(i=0n),e.length!=t.length)throw RangeError("signersAddresses and signatures arrays should be the same length");var a=new Map;e.forEach(function(e,r){a.set(e.toLocaleLowerCase(),t[r])});var o=new Map(Array.from(a).sort()),s="0x"+Array.from(o.values()).reduce(function(e,t){return e+t.slice(2)},"");return r.formatEip712SingleSignatureToUseroperationSignature(s,n,i)},r.formatEip712SingleSignatureToUseroperationSignature=function(t,r,n){if(void 0===r&&(r=0n),void 0===n&&(n=0n),r<0n)throw RangeError("validAfter can't be negative");if(n<0n)throw RangeError("validUntil can't be negative");return e.solidityPacked(["uint48","uint48","bytes"],[r,n,t])},i.sendUserOperation=function(e,t){try{var r=this,n=new F(t);return Promise.resolve(n.sendUserOperation(e,r.entrypointAddress)).then(function(e){return new U(e,n,r.entrypointAddress)})}catch(e){return Promise.reject(e)}},r}(a);function I(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=exports.SafeModuleExecutorFunctionSelector.executeUserOpWithErrorString,w.executorFunctionInputAbi=["address","uint256","bytes","uint8"],w.EIP712_SAFE_OPERATION_TYPE={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"}]};var C=/*#__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}c(t,e);var r=t.prototype;return r.initialize=function(){try{var e=this;return Promise.resolve(I(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=h(e);throw new v("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?I(function(){return Promise.resolve(y(e.rpcUrl,"pm_supportedERC20Tokens",[])).then(function(e){return{tokens:e.tokens.map(function(e){return{symbol:e.symbol,address:e.address,decimal:Number(e.decimal),fee:BigInt(e.fee),exchangeRate:BigInt(e.exchangeRate)}}),paymasterMetadata:e.paymasterMetadata}})},function(e){var t=h(e);throw new v("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?I(function(){return Promise.resolve(y(e.rpcUrl,"pm_supportedEntryPoint",[]))},function(e){var t=h(e);throw new v("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.toLowerCase()===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={}),void 0===n&&(n={});try{var i=function(){return I(function(){function i(t){var i,f,u,l,d,p;if("bigint"==typeof n.preVerificationGas&&n.preVerificationGas<0n)throw RangeError("preVerificationGas overrid can't be negative");if("bigint"==typeof n.verificationGasLimit&&n.verificationGasLimit<0n)throw RangeError("verificationGasLimit overrid can't be negative");if("bigint"==typeof n.callGasLimit&&n.callGasLimit<0n)throw RangeError("callGasLimit overrid can't be negative");return e.preVerificationGas=null!=(i=n.preVerificationGas)?i:o*BigInt((null!=(f=n.preVerificationGasPercentageMultiplier)?f:0)+100)/100n,e.verificationGasLimit=null!=(u=n.verificationGasLimit)?u:s*BigInt((null!=(l=n.verificationGasLimitPercentageMultiplier)?l:0)+100)/100n,e.callGasLimit=null!=(d=n.callGasLimit)?d:c*BigInt((null!=(p=n.callGasLimitPercentageMultiplier)?p:0)+100)/100n,e.preVerificationGas=e.preVerificationGas+100n,e.verificationGasLimit=e.verificationGasLimit+10000n,Promise.resolve(y(a.rpcUrl,"pm_sponsorUserOperation",[e,a.entrypointAddress,r])).then(function(t){var r,n,i,a,o,s=t,c={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=c.paymasterAndData,e.callGasLimit=null!=(r=c.callGasLimit)?r:e.callGasLimit,e.preVerificationGas=null!=(n=c.preVerificationGas)?n:e.preVerificationGas,e.verificationGasLimit=null!=(i=c.verificationGasLimit)?i:e.verificationGasLimit,e.maxFeePerGas=null!=(a=c.maxFeePerGas)?a:e.maxFeePerGas,e.maxPriorityFeePerGas=null!=(o=c.maxPriorityFeePerGas)?o:e.maxPriorityFeePerGas,e})}e.paymasterAndData=a.paymasterMetadata.dummyPaymasterAndData;var o=e.preVerificationGas,s=e.verificationGasLimit,c=e.callGasLimit,f=function(){if(null==n.preVerificationGas||null==n.verificationGasLimit||null==n.callGasLimit)return function(){if(null!=t){var r=new F(t);e.callGasLimit=0n,e.verificationGasLimit=0n,e.preVerificationGas=0n;var i=e.maxFeePerGas,f=e.maxPriorityFeePerGas;return e.maxFeePerGas=0n,e.maxPriorityFeePerGas=0n,Promise.resolve(r.estimateUserOperationGas(e,a.entrypointAddress,n.state_override_set)).then(function(t){o<t.preVerificationGas&&(o=t.preVerificationGas),s<t.verificationGasLimit&&(s=t.verificationGasLimit),c<t.callGasLimit&&(c=t.callGasLimit),e.maxFeePerGas=i,e.maxPriorityFeePerGas=f})}throw new v("BAD_DATA","bundlerRpc cant't be null if preVerificationGas,verificationGasLimit and callGasLimit are not overriden")}()}();return f&&f.then?f.then(i):i()},function(e){var t=h(e);throw new v("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){void 0===r&&(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(I(function(){return Promise.resolve(a.calculateUserOperationErc20TokenMaxGasCost(t,r)).then(function(o){var s=2n*o;return Promise.resolve(a.getPaymasterMetaData()).then(function(o){var c=e.prependTokenPaymasterApproveToCallData(t.callData,r,o.address,s);return t.callData=c,Promise.resolve(a.createPaymasterUserOperation(t,n,{token:r},i))})})},function(e){var t=h(e);throw new v("PAYMASTER_ERROR","createTokenPaymasterUserOperation failed",{cause:t})}))}catch(e){return Promise.reject(e)}},r.calculateUserOperationErc20TokenMaxGasCost=function(e,t){try{var r=this;return Promise.resolve(I(function(){return Promise.resolve(r.getSupportedERC20TokenData(t)).then(function(n){if(null==n)return Promise.resolve(r.getSupportedERC20TokensAndPaymasterMetadata()).then(function(e){throw new v("PAYMASTER_ERROR",t+" token is not supported by the paymaster.",{context:{supportedERC20TokensAndPaymasterMetadata:JSON.stringify(e,function(e,t){return"bigint"==typeof t?"0x"+t.toString(16):t})}})});var i=G(e);return n.exchangeRate*i/BigInt(Math.pow(10,18))})},function(e){var t=h(e);throw new v("PAYMASTER_ERROR","calculateUserOperationErc20TokenMaxGasCost failed",{cause:t})}))}catch(e){return Promise.reject(e)}},t}(function(){}),M={__proto__:null,SmartAccount:a,SafeAccountV0_2_0:w,SendUseroperationResponse:U,SmartAccountFactory:x,SafeAccountFactory:S,Bundler:F,CandidePaymaster:C,createUserOperationHash:A,createCallData:P,getFunctionSelector:g,fetchAccountNonce:m,calculateUserOperationMaxGasCost:G,get SafeModuleExecutorFunctionSelector(){return exports.SafeModuleExecutorFunctionSelector},get Operation(){return exports.Operation},ZeroAddress:D,UserOperationDummyValues:b};exports.Bundler=F,exports.CandidePaymaster=C,exports.SafeAccountFactory=S,exports.SafeAccountV0_2_0=w,exports.SendUseroperationResponse=U,exports.SmartAccount=a,exports.SmartAccountFactory=x,exports.UserOperationDummyValues=b,exports.ZeroAddress=D,exports.abstractionkit=M,exports.calculateUserOperationMaxGasCost=G,exports.createCallData=P,exports.createUserOperationHash=A,exports.fetchAccountNonce=m,exports.getFunctionSelector=g; | ||
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,a,i=/*#__PURE__*/r(e),o=function(e){this.accountAddress=void 0,this.accountAddress=e};function s(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(s=function(){return!!e})()}function f(){return f=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},f.apply(this,arguments)}function c(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,d(e,t)}function u(e){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},u(e)}function d(e,t){return d=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},d(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(s())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,t);var a=new(e.bind.apply(e,n));return r&&d(a,r.prototype),a}(e,arguments,u(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),d(r,e)},l(e)}function v(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}function h(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 v(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)?v(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){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.")}o.proxyByteCode=void 0,o.initializerFunctionSelector=void 0,o.initializerFunctionInputAbi=void 0,o.executorFunctionSelector=void 0,o.executorFunctionInputAbi=void 0,exports.Operation=void 0,(n=exports.Operation||(exports.Operation={}))[n.Call=0]="Call",n[n.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 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"},m=/*#__PURE__*/function(e){function t(t,r,n){var a;void 0===n&&(n={});var i=n.errno,o=n.context;return(a=e.call(this,r,{cause:n.cause})||this).code=void 0,a.context=void 0,a.errno=void 0,a.name=a.constructor.name,a.code=t,a.errno=i,a.context=o,a}return c(t,e),t}(/*#__PURE__*/l(Error));function A(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 y=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)}},g=function(e,t,r,n){void 0===n&&(n=0);try{var a=[{from:"0x0000000000000000000000000000000000000000",to:t,data:D(P("getNonce(address,uint192)"),["address","uint192"],[r,n])},"latest"];return Promise.resolve(function(t,r){try{var n=Promise.resolve(E(e,"eth_call",a)).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=A(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=A(e);throw new m("BAD_DATA","getNonce failed",{cause:t})}))}catch(e){return Promise.reject(e)}},E=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 m(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 b(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 D(e,r,n){return e+t.AbiCoder.defaultAbiCoder().encode(r,n).slice(2)}function P(e){return t.id(e).slice(0,10)}function G(e){return(e.callGasLimit+e.verificationGasLimit*("0x"==e.paymasterAndData||null==e.paymasterAndData?3n:0n)+e.preVerificationGas)*e.maxFeePerGas}var _,T,S=function(e,t,r){try{var n=[t,r];return Promise.resolve(function(t,r){try{var a=Promise.resolve(E(e,"eth_call",n)).then(function(e){if("string"!=typeof e)throw new m("BAD_DATA","eth_call returned ill formed data",{context:JSON.stringify(e)});try{return e}catch(e){var t=A(e);throw new m("BAD_DATA","eth_call returned ill formed data",{cause:t})}})}catch(e){return r(e)}return a&&a.then?a.then(void 0,r):a}(0,function(e){var t=A(e);throw new m("BAD_DATA","eth_call failed",{cause:t})}))}catch(e){return Promise.reject(e)}},R=/*#__PURE__*/function(e){function r(t){return void 0===t&&(t=r.DEFAULT_SOCIAL_RECOVERY_ADDRESS),e.call(this,t)||this}c(r,e);var n=r.prototype;return n.createConfirmRecoveryMetaTransaction=function(e,t,r,n){var a=D(P("confirmRecovery(address,address[],uint256,bool)"),["address","address[]","uint256","bool"],[e,t,r,n]);return{to:this.moduleAddress,data:a,value:0n}},n.createMultiConfirmRecoveryMetaTransaction=function(e,t,r,n,a){var i=D(P("multiConfirmRecovery(address,address[],uint256,address[],bool)"),["address","address[]","uint256","address[]","bool"],[e,t,r,n,a]);return{to:this.moduleAddress,data:i,value:0n}},n.createExecuteRecoveryMetaTransaction=function(e,t,r){var n=D(P("executeRecovery(address,address[],uint256)"),["address","address[]","uint256"],[e,t,r]);return{to:this.moduleAddress,data:n,value:0n}},n.createFinalizeRecoveryMetaTransaction=function(e){var t=D(P("finalizeRecovery(address)"),["address"],[e]);return{to:this.moduleAddress,data:t,value:0n}},n.createCancelRecoveryMetaTransaction=function(e){var t=D(P("cancelRecovery(address)"),["address"],[e]);return{to:this.moduleAddress,data:t,value:0n}},n.createAddGuardianWithThresholdMetaTransaction=function(e,t,r){var n=D(P("addGuardianWithThreshold(address,address,uint256)"),["address","address","uint256"],[e,t,r]);return{to:this.moduleAddress,data:n,value:0n}},n.createRevokeGuardianWithThresholdMetaTransaction=function(e,t,r,n){var a=D(P("revokeGuardianWithThreshold(address,address,address,uint256)"),["address","address","address","uint256"],[e,t,r,n]);return{to:this.moduleAddress,data:a,value:0n}},n.createChangeThresholdMetaTransaction=function(e,t){var r=D(P("changeThreshold(address,uint256)"),["address","uint256"],[e,t]);return{to:this.moduleAddress,data:r,value:0n}},n.getRecoveryHash=function(e,t,r,n,a){try{var i=D(P("getRecoveryHash(address,address[],uint256,uint256)"),["address","address[]","uint256","uint256"],[t,r,n,a]);return S(e,{to:this.moduleAddress,data:i},"latest")}catch(e){return Promise.reject(e)}},n.getRecoveryRequest=function(e,r){try{var n=D(P("getRecoveryRequest(address)"),["address"],[r]);return Promise.resolve(S(e,{to:this.moduleAddress,data:n},"latest")).then(function(e){var r=t.AbiCoder.defaultAbiCoder().decode(["uint256","uint256","uint64","address[]"],e);return{guardiansApprovalCount:r[0],newThreshold:r[1],executeAfter:r[2],newOwners:r[3]}})}catch(e){return Promise.reject(e)}},n.getRecoveryApprovals=function(e,r,n,a){try{var i=D(P("getRecoveryApprovals(address,address[],uint256)"),["address","address[]","uint256"],[r,n,a]);return Promise.resolve(S(e,{to:this.moduleAddress,data:i},"latest")).then(function(e){var r=t.AbiCoder.defaultAbiCoder().decode(["uint256"],e);return BigInt(r[0])})}catch(e){return Promise.reject(e)}},n.hasGuardianApproved=function(e,r,n,a,i){try{var o=D(P("hasGuardianApproved(address,address,address[],uint256)"),["address","address","address[]","uint256"],[r,n,a,i]);return Promise.resolve(S(e,{to:this.moduleAddress,data:o},"latest")).then(function(e){var r=t.AbiCoder.defaultAbiCoder().decode(["bool"],e);return Boolean(r[0])})}catch(e){return Promise.reject(e)}},n.isGuardian=function(e,r,n){try{var a=D(P("isGuardian(address,address)"),["address","address"],[r,n]);return Promise.resolve(S(e,{to:this.moduleAddress,data:a},"latest")).then(function(e){var r=t.AbiCoder.defaultAbiCoder().decode(["bool"],e);return Boolean(r[0])})}catch(e){return Promise.reject(e)}},n.guardiansCount=function(e,r){try{var n=D(P("guardiansCount(address)"),["address"],[r]);return Promise.resolve(S(e,{to:this.moduleAddress,data:n},"latest")).then(function(e){var r=t.AbiCoder.defaultAbiCoder().decode(["uint256"],e);return BigInt(r[0])})}catch(e){return Promise.reject(e)}},n.threshold=function(e,r){try{var n=D(P("threshold(address)"),["address"],[r]);return Promise.resolve(S(e,{to:this.moduleAddress,data:n},"latest")).then(function(e){var r=t.AbiCoder.defaultAbiCoder().decode(["uint256"],e);return BigInt(r[0])})}catch(e){return Promise.reject(e)}},n.getGuardians=function(e,r){try{var n=D(P("getGuardians(address)"),["address"],[r]);return Promise.resolve(S(e,{to:this.moduleAddress,data:n},"latest")).then(function(e){return t.AbiCoder.defaultAbiCoder().decode(["address[]"],e)[0]})}catch(e){return Promise.reject(e)}},n.nonce=function(e,r){try{var n=D(P("nonce(address)"),["address"],[r]);return Promise.resolve(S(e,{to:this.moduleAddress,data:n},"latest")).then(function(e){var r=t.AbiCoder.defaultAbiCoder().decode(["uint256"],e);return BigInt(r[0])})}catch(e){return Promise.reject(e)}},r}(/*#__PURE__*/function(){function e(e){this.moduleAddress=void 0,this.moduleAddress=e}return e.prototype.createEnableModuleMetaTransaction=function(e){return{to:e,data:D(P("enableModule(address)"),["address"],[this.moduleAddress]),value:0n}},e}());function x(e){return"0x"+e.map(function(e){return a=null!=(n=(r=e).operation)?n:exports.Operation.Call,i=t.getBytes(r.data),t.solidityPacked(["uint8","address","uint256","uint256","bytes"],[a,r.to,r.value,i.length,i]).slice(2);var r,n,a,i}).join("")}function L(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}R.DEFAULT_SOCIAL_RECOVERY_ADDRESS="0xFc98B4a5120959511873a51daBd6c1889897412d",exports.SafeModuleExecutorFunctionSelector=void 0,(_=exports.SafeModuleExecutorFunctionSelector||(exports.SafeModuleExecutorFunctionSelector={})).executeUserOpWithErrorString="0x541d63c8",_.executeUserOp="0x7bb37428",exports.DummySignature=void 0,(T=exports.DummySignature||(exports.DummySignature={})).eoa="ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",T.webAuthn="5715d3b8fc6e09d43d24175720e98c1ed970661400000000000000000000000000000000000000000000000000000000000000410000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e0762c7349c04b09b85aa0b0d21ba70df2195d60c653877df252a16c3f62559fa02d0dbe584b8a794bcf5fc5263f42cf8d50d200c3bc15fe375508e24ca97002ad000000000000000000000000000000000000000000000000000000000000002549960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d9763050000000e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a1226f726967696e223a22687474703a2f2f6c6f63616c686f73743a35313733222c2263726f73734f726967696e223a66616c73652c226f746865725f6b6579735f63616e5f62655f61646465645f68657265223a22646f206e6f7420636f6d7061726520636c69656e74446174614a534f4e20616761696e737420612074656d706c6174652e205365652068747470733a2f2f676f6f2e676c2f7961625065782200000000000000000000000000000000000000000000000000000000000000";var F=/*#__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(L(function(){return Promise.resolve(E(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=A(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(L(function(){return Promise.resolve(E(e.rpcUrl,"eth_supportedEntryPoints",[]))},function(e){var t=A(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(L(function(){function a(){var e=i;return{callGasLimit:BigInt(e.callGasLimit),preVerificationGas:BigInt(e.preVerificationGas),verificationGasLimit:BigInt(e.verificationGasLimit)}}var i={},o=void 0===r?Promise.resolve(E(n.rpcUrl,"eth_estimateUserOperationGas",[e,t])).then(function(e){i=e}):Promise.resolve(E(n.rpcUrl,"eth_estimateUserOperationGas",[e,t,r])).then(function(e){i=e});return o&&o.then?o.then(a):a()},function(e){var t=A(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(L(function(){return Promise.resolve(E(r.rpcUrl,"eth_sendUserOperation",[e,t]))},function(e){var t=A(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(L(function(){return Promise.resolve(E(t.rpcUrl,"eth_getUserOperationReceipt",[e])).then(function(e){var t=e;if(null!=t){var r=f({},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 f({},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=A(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(L(function(){return Promise.resolve(E(t.rpcUrl,"eth_getUserOperationByHash",[e])).then(function(e){return null!=e?f({},e,{blockNumber:null==e.blockNumber?null:BigInt(e.blockNumber)}):null})},function(t){var r=A(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 U(e,t,r){if(!e.s){if(r instanceof O){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 O=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(t,r){var n=new e,a=this.s;if(a){var i=1&a?t:r;if(i){try{U(n,1,i(this.v))}catch(e){U(n,2,e)}return n}return this}return this.o=function(e){try{var a=e.v;1&e.s?U(n,1,t?t(a):a):r?U(n,1,r(a)):U(n,2,a)}catch(e){U(n,2,e)}},n},e}();function I(e){return e instanceof O&&1&e.s}var w=/*#__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:a.userOperationHash})},a=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 i=0,o=function(e,t,r){for(var n;;){var a=e();if(I(a)&&(a=a.v),!a)return i;if(a.then){n=0;break}var i=r();if(i&&i.then){if(!I(i)){n=1;break}i=i.s}if(t){var o=t();if(o&&o.then&&!I(o)){n=2;break}}}var s=new O,f=U.bind(null,s,2);return(0===n?a.then(u):1===n?i.then(c):o.then(d)).then(void 0,f),s;function c(n){i=n;do{if(t&&(o=t())&&o.then&&!I(o))return void o.then(d).then(void 0,f);if(!(a=e())||I(a)&&!a.v)return void U(s,1,i);if(a.then)return void a.then(u).then(void 0,f);I(i=r())&&(i=i.v)}while(!i||!i.then);i.then(c).then(void 0,f)}function u(e){e?(i=r())&&i.then?i.then(c).then(void 0,f):c(i):U(s,1,i)}function d(){(a=e())?a.then?a.then(u).then(void 0,f):u(a):U(s,1,i)}}(function(){return!r&&i<=e},void 0,function(){return Promise.resolve(a.delay(1e3*t)).then(function(){return Promise.resolve(a.bundler.getUserOperationReceipt(a.userOperationHash)).then(function(e){if(null!=e)return r=1,e;i++})})});return Promise.resolve(o&&o.then?o.then(n):n(o))}catch(e){return Promise.reject(e)}},e}(),C=/*#__PURE__*/function(e){function r(t,n,a){var i;return void 0===n&&(n=r.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===a&&(a=r.DEFAULT_ENTRYPOINT_ADDRESS),(i=e.call(this,t)||this).entrypointAddress=void 0,i.safe4337ModuleAddress=void 0,i.initCode=void 0,i.entrypointAddress=a,i.safe4337ModuleAddress=n,i.initCode=null,i}return c(r,e),r.createProxyAddress=function(e,r,n,a){if(r<0n)throw RangeError("c2Nonce can't be negative");var i=t.AbiCoder.defaultAbiCoder(),o=t.keccak256(t.solidityPacked(["bytes32","uint256"],[t.keccak256(e),r])),s=i.encode(["uint256"],[a]),f=t.keccak256(t.solidityPacked(["bytes","bytes"],[this.proxyByteCode,s]));return"0x"+t.solidityPackedKeccak256(["bytes1","address","bytes32","bytes32"],["0xff",n,o,f]).slice(-40)},r.createAccountCallDataSingleTransaction=function(e){var t,n,a,i=null!=(t=e.value)?t:0,o=null!=(n=e.data)?n:"0x",s=null!=(a=e.operation)?a:exports.Operation.Call;return r.createAccountCallData(e.to,i,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=D("0x8d80ff0a",["bytes"],[x(e)]);return r.createAccountCallData(t,0n,n,exports.Operation.Delegate)},r.createAccountCallData=function(e,t,n,a,i){return void 0===i&&(i=r.DEFAULT_EXECUTOR_FUCNTION_SELECTOR),D(i,r.executorFunctionInputAbi,[e,t,n,a])},r.decodeAccountCallData=function(e){if(e.startsWith(exports.SafeModuleExecutorFunctionSelector.executeUserOpWithErrorString)||e.startsWith(exports.SafeModuleExecutorFunctionSelector.executeUserOp)){var r=t.AbiCoder.defaultAbiCoder(),n="0x"+e.slice(10),a=r.decode(["address","uint256","bytes","uint8"],n);return[a[0],BigInt(a[1]),a[2],Number(a[3])]}throw new m("BAD_DATA","Invalid calldata, should start with "+exports.SafeModuleExecutorFunctionSelector.executeUserOpWithErrorString+" or "+exports.SafeModuleExecutorFunctionSelector.executeUserOp,{context:{callData:e}})},r.prependTokenPaymasterApproveToCallDataStatic=function(e,n,a,i,o){void 0===o&&(o=r.DEFAULT_MULTISEND_CONTRACT_ADDRESS);var s=r.decodeAccountCallData(e),f=s[0],c=s[1],u=s[2],d=s[3],l="";l="string"!=typeof u?(new TextDecoder).decode(u):u;var v=x([{to:n,value:0n,data:D(P("approve(address,uint256)"),["address","uint256"],[a,i]),operation:exports.Operation.Call}]),h="",p="0x8d80ff0a";if(l.startsWith(p)){var m=function(e){return t.AbiCoder.defaultAbiCoder().decode(["bytes"],"0x"+e.slice(10))[0]}(l);h=m+v.slice(2)}else h=x([{to:f,value:c,data:u,operation:d}])+v.slice(2);var A=D(p,["bytes"],[h]);return r.createAccountCallData(o,0n,A,exports.Operation.Delegate)},r.formatEip712SignaturesToUseroperationSignature=function(e,t,n,a){if(void 0===n&&(n=0n),void 0===a&&(a=0n),e.length!=t.length)throw RangeError("signersAddresses and signatures arrays should be the same length");var i=new Map;e.forEach(function(e,r){i.set(e.toLocaleLowerCase(),t[r])});var o=new Map(Array.from(i).sort()),s="0x"+Array.from(o.values()).reduce(function(e,t){return e+t.slice(2)},"");return r.formatEip712SingleSignatureToUseroperationSignature(s,n,a)},r.getUserOperationEip712Hash=function(e,n,a,i,o){return void 0===a&&(a=0n),void 0===i&&(i=0n),t.TypedDataEncoder.hash({chainId:n,verifyingContract:r.DEFAULT_SAFE_4337_MODULE_ADDRESS},r.EIP712_SAFE_OPERATION_TYPE,{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:a,validUntil:i,entryPoint:o})},r.formatEip712SingleSignatureToUseroperationSignature=function(e,r,n){if(void 0===r&&(r=0n),void 0===n&&(n=0n),r<0n)throw RangeError("validAfter can't be negative");if(n<0n)throw RangeError("validUntil can't be negative");return t.solidityPacked(["uint48","uint48","bytes"],[r,n,e])},r.prototype.sendUserOperation=function(e,t){try{var r=this,n=new F(t);return Promise.resolve(n.sendUserOperation(e,r.entrypointAddress)).then(function(e){return new w(e,n,r.entrypointAddress)})}catch(e){return Promise.reject(e)}},r}(o);C.DEFAULT_ENTRYPOINT_ADDRESS="0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",C.DEFAULT_SAFE_4337_MODULE_ADDRESS="0xa581c4A4DB7175302464fF3C06380BC3270b4037",C.DEFAULT_SINGLETON_ADDRESS="0x29fcB43b46531BcA003ddC8FCB67FFE91900C762",C.DEFAULT_ADD_MODULE_LIB_ADDRESS="0x8EcD4ec46D4D2a6B64fE960B3D64e8B94B2234eb",C.DEFAULT_MULTISEND_CONTRACT_ADDRESS="0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526",C.proxyByteCode="0x608060405234801561001057600080fd5b506040516101e63803806101e68339818101604052602081101561003357600080fd5b8101908080519060200190929190505050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156100ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806101c46022913960400191505060405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505060ab806101196000396000f3fe608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea264697066735822122003d1488ee65e08fa41e58e888a9865554c535f2c77126a82cb4c0f917f31441364736f6c63430007060033496e76616c69642073696e676c65746f6e20616464726573732070726f7669646564",C.initializerFunctionSelector="0xb63e800d",C.initializerFunctionInputAbi=["address[]","uint256","address","bytes","address","address","uint256","address"],C.DEFAULT_EXECUTOR_FUCNTION_SELECTOR=exports.SafeModuleExecutorFunctionSelector.executeUserOpWithErrorString,C.executorFunctionInputAbi=["address","uint256","bytes","uint8"],C.EIP712_SAFE_OPERATION_TYPE={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"}]};var N="0x0000000000000000000000000000000000000000",B={sender:N,nonce:0n,initCode:"0x",callData:"0x",callGasLimit:0n,verificationGasLimit:0n,preVerificationGas:0n,maxFeePerGas:0n,maxPriorityFeePerGas:0n,paymasterAndData:"0x",signature:"0x"},M=/*#__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=D(this.generatorFunctionSelector,this.generatorFunctionInputAbi,e);return this.address+t.slice(2)},e}(),k=/*#__PURE__*/function(e){function t(t){return void 0===t&&(t="0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67"),e.call(this,t,"0x1688f0b9",["address","bytes","uint256"])||this}return c(t,e),t}(M),V=/*#__PURE__*/function(e){function r(t,n,a){return void 0===n&&(n=r.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===a&&(a=r.DEFAULT_ENTRYPOINT_ADDRESS),e.call(this,t,n,a)||this}c(r,e),r.initializeNewAccount=function(e,t){void 0===t&&(t={});var n=r.createAccountAddressAndInitCode(e,t),a=n[1],i=new r(n[0]);return i.initCode=a,i},r.createAccountAddress=function(e,t){return void 0===t&&(t={}),r.createAccountAddressAndInitCode(e,t)[0]},r.createAccountAddressAndInitCode=function(e,t){var n,a,i,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!=(a=t.c2Nonce)?a:0n,u=null!=(i=t.singletonAddress)?i:C.DEFAULT_SINGLETON_ADDRESS,d=null!=(o=t.safe4337ModuleAddress)?o:C.DEFAULT_SAFE_4337_MODULE_ADDRESS,l=null!=(s=t.addModuleLibAddress)?s:C.DEFAULT_ADD_MODULE_LIB_ADDRESS,v=new k;null!=t.safeAccountFactoryAddress&&(v=new k(t.safeAccountFactoryAddress));var h=r.createInitializerCallData(e,f,d,l);return[this.createProxyAddress(h,c,v.address,u),v.getFactoryGeneratorFunctionCallData([u,h,c])]},r.createInitializerCallData=function(e,t,r,n){if(void 0===r&&(r=C.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===n&&(n=C.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=D("0x8d0dc49f",["address[]"],[[r]]);return D(C.initializerFunctionSelector,C.initializerFunctionInputAbi,[e,t,n,a,r,N,0,N])},r.createInitCode=function(e,t,n,a,i,o,s){if(void 0===t&&(t=1),void 0===n&&(n=0n),void 0===a&&(a=C.DEFAULT_SINGLETON_ADDRESS),void 0===i&&(i=new k),void 0===o&&(o=C.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===s&&(s=C.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 i.getFactoryGeneratorFunctionCallData([a,f,n])};var n=r.prototype;return n.prependTokenPaymasterApproveToCallData=function(e,t,n,a,i){return void 0===i&&(i=r.DEFAULT_MULTISEND_CONTRACT_ADDRESS),r.prependTokenPaymasterApproveToCallDataStatic(e,t,n,a,i)},n.estimateUserOperationGas=function(e,t,r,n){void 0===n&&(n=1);try{if(n<1n)throw RangeError("numberOfSigners can't be less than 1");for(var a="",i=0;i<n;i++)a+="ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff";e.signature="0xffffffffffffffffffffffff"+a;var o=new F(t),s=e.maxFeePerGas,f=e.maxPriorityFeePerGas;return e.maxFeePerGas=0n,e.maxPriorityFeePerGas=0n,Promise.resolve(o.estimateUserOperationGas(e,this.entrypointAddress,r)).then(function(t){return e.maxFeePerGas=s,e.maxPriorityFeePerGas=f,[BigInt(t.preVerificationGas),BigInt(t.verificationGasLimit)+20000n*BigInt(n),BigInt(t.callGasLimit)]})}catch(e){return Promise.reject(e)}},n.createUserOperation=function(e,t,n,a){void 0===a&&(a={});try{var i=function(i){var c;function u(e){var t,r,i,c;function u(e){var t,r,n,i,o,s;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 p.preVerificationGas=null!=(t=a.preVerificationGas)?t:A*BigInt(Math.floor(((null!=(r=a.preVerificationGasPercentageMultiplier)?r:0)+100)/100)),p.verificationGasLimit=null!=(n=a.verificationGasLimit)?n:y*BigInt(Math.floor(((null!=(i=a.verificationGasLimitPercentageMultiplier)?i:0)+100)/100)),p.callGasLimit=null!=(o=a.callGasLimit)?o:g*BigInt(Math.floor(((null!=(s=a.callGasLimitPercentageMultiplier)?s:0)+100)/100)),p}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");v=null!=(t=a.maxFeePerGas)?t:v*BigInt(Math.floor(((null!=(r=a.maxFeePerGasPercentageMultiplier)?r:0)+100)/100)),h=null!=(i=a.maxPriorityFeePerGas)?i:h*BigInt(Math.floor(((null!=(c=a.maxPriorityFeePerGasPercentageMultiplier)?c:0)+100)/100));var p=f({},B,{sender:o.accountAddress,nonce:s,initCode:d,callData:l,maxFeePerGas:v,maxPriorityFeePerGas:h}),A=B.preVerificationGas,y=B.verificationGasLimit,g=B.callGasLimit,E=function(){if(null==a.preVerificationGas||null==a.verificationGasLimit||null==a.callGasLimit)return function(){if(null!=n){p.callGasLimit=0n,p.verificationGasLimit=0n,p.preVerificationGas=0n;var e=p.maxFeePerGas,t=p.maxPriorityFeePerGas;return p.maxFeePerGas=0n,p.maxPriorityFeePerGas=0n,Promise.resolve(o.estimateUserOperationGas(p,n,a.state_override_set,a.numberOfSigners)).then(function(r){A=r[0],y=r[1],g=r[2],p.maxFeePerGas=e,p.maxPriorityFeePerGas=t})}throw new m("BAD_DATA","bundlerRpc cant't be null if preVerificationGas,verificationGasLimit and callGasLimit are not overriden")}()}();return E&&E.then?E.then(u):u()}var d=null!=(c=a.initCode)?c:o.initCode;if((null==d||s>0n)&&(d="0x"),s<0n)throw RangeError("nonce can't be negative");var l="0x";l=null==a.callData?1==e.length?r.createAccountCallDataSingleTransaction(e[0]):r.createAccountCallDataBatchTransactions(e):a.callData;var v=B.maxFeePerGas,h=B.maxPriorityFeePerGas,p=function(){if(null==a.maxFeePerGas||null==a.maxPriorityFeePerGas)return function(){if(null!=t)return Promise.resolve(y(t)).then(function(e){v=e[0],h=e[1]});throw new m("BAD_DATA","providerRpc cant't be null if maxFeePerGas and maxPriorityFeePerGas are not overriden")}()}();return p&&p.then?p.then(u):u()},o=this;if(e.length<1)throw RangeError("There should be at least one transaction");var s=0n,c=function(){if(null==a.nonce)return function(){if(null!=t)return Promise.resolve(g(t,o.entrypointAddress,o.accountAddress)).then(function(e){s=e});throw new m("BAD_DATA","providerRpc cant't be null if nonce is not overriden")}();s=a.nonce}();return Promise.resolve(c&&c.then?c.then(i):i())}catch(e){return Promise.reject(e)}},n.signUserOperation=function(e,n,a,i,o){if(void 0===i&&(i=0n),void 0===o&&(o=0n),n.length<1)throw RangeError("There should be at least one privateKey");if(a<0n)throw RangeError("chainId can't be negative");if(i<0n)throw RangeError("validAfter can't be negative");if(o<0n)throw RangeError("validUntil can't be negative");for(var s,f=C.getUserOperationEip712Hash(e,a,i,o,this.entrypointAddress),c=[],u=[],d=h(n);!(s=d()).done;){var l=new t.Wallet(s.value),v=l.signingKey.sign(f).serialized;c.push(l.address),u.push(v)}return r.formatEip712SignaturesToUseroperationSignature(c,u,i,o)},r}(C),j=/*#__PURE__*/function(e){function r(t,n,a){var i;return void 0===n&&(n=r.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===a&&(a=r.DEFAULT_ENTRYPOINT_ADDRESS),(i=e.call(this,t,n,a)||this).isInitWebAuthn=void 0,i.x=0n,i.y=0n,i.isInitWebAuthn=!1,i}c(r,e),r.initializeNewAccount=function(e,t){void 0===t&&(t={});for(var n,a=!1,i=0n,o=0n,s=h(e);!(n=s()).done;){var f=n.value;"string"!=typeof f&&(a=!0,i=f.x,o=f.y)}var c=r.createAccountAddressAndInitCode(e,t),u=c[1],d=new r(c[0]);return d.initCode=u,d.isInitWebAuthn=a,d.x=i,d.y=o,d},r.createAccountAddress=function(e,t){return void 0===t&&(t={}),r.createAccountAddressAndInitCode(e,t)[0]},r.createAccountAddressAndInitCode=function(e,t){var n,a,i,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!=(a=t.c2Nonce)?a:0n,u=null!=(i=t.singletonAddress)?i:C.DEFAULT_SINGLETON_ADDRESS,d=null!=(o=t.safe4337ModuleAddress)?o:C.DEFAULT_SAFE_4337_MODULE_ADDRESS,l=null!=(s=t.addModuleLibAddress)?s:C.DEFAULT_ADD_MODULE_LIB_ADDRESS,v=new k;null!=t.safeAccountFactoryAddress&&(v=new k(t.safeAccountFactoryAddress));var h=r.createInitializerCallData(e,f,d,l);return[this.createProxyAddress(h,c,v.address,u),v.getFactoryGeneratorFunctionCallData([u,h,c])]},r.createInitializerCallData=function(e,t,n,a){if(void 0===n&&(n=C.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===a&&(a=C.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 i={to:a,value:0n,data:D("0x8d0dc49f",["address[]"],[[n]]),operation:exports.Operation.Delegate},o=[];o.push(i);for(var s,f=[],c=0,u=h(e);!(s=u()).done;){var d=s.value;if("string"!=typeof d){if(c>0)throw RangeError("Only one WebAuthn owner can be set during initialization");var l=D("0xf9c6055b",["uint256","uint256"],[d.x,d.y]),v={to:r.DEFAULT_WEB_AUTHN_SIGNATURE_VALIDATOR_SINGLETON,value:0n,data:l,operation:exports.Operation.Delegate};o.push(v),f.push(r.DEFAULT_WEB_AUTHN_SIGNATURE_VALIDATOR_SINGLETON),c++}else f.push(d)}var p=D("0x8d80ff0a",["bytes"],[x(o)]);return D(C.initializerFunctionSelector,C.initializerFunctionInputAbi,[f,t,r.DEFAULT_MULTISEND_CONTRACT_ADDRESS,p,n,N,0,N])},r.createInitCode=function(e,t,n,a,i,o,s){if(void 0===t&&(t=1),void 0===n&&(n=0n),void 0===a&&(a=C.DEFAULT_SINGLETON_ADDRESS),void 0===i&&(i=new k),void 0===o&&(o=C.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===s&&(s=C.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 i.getFactoryGeneratorFunctionCallData([a,f,n])};var n=r.prototype;return n.prependTokenPaymasterApproveToCallData=function(e,t,n,a,i){return void 0===i&&(i=r.DEFAULT_MULTISEND_CONTRACT_ADDRESS),r.prependTokenPaymasterApproveToCallDataStatic(e,t,n,a,i)},n.estimateUserOperationGas=function(e,t,r,n,a){void 0===n&&(n=1),void 0===a&&(a=null);try{if(n<1n)throw RangeError("numberOfSigners can't be less than 1");if(null!=a&&n!=a.length)throw RangeError("dummySignatures list should has the length of numberOfSigners");for(var i="",o=0;o<n;o++)null==a&&exports,i+=a;e.signature="0xffffffffffffffffffffffffffffffffffffffffffffffff"+i;var s=new F(t);return Promise.resolve(s.estimateUserOperationGas(e,this.entrypointAddress,r)).then(function(e){return[BigInt(e.preVerificationGas),BigInt(e.verificationGasLimit)+20000n*BigInt(n),BigInt(e.callGasLimit)]})}catch(e){return Promise.reject(e)}},n.createUserOperation=function(e,t,n,a){void 0===a&&(a={});try{var i=function(i){var c;function u(e){var t,r,i,c;function u(e){var t,r,n,i,o,s;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 l.preVerificationGas=null!=(t=a.preVerificationGas)?t:v*BigInt((null!=(r=a.preVerificationGasPercentageMultiplier)?r:0)+100)/100n,l.verificationGasLimit=null!=(n=a.verificationGasLimit)?n:h*BigInt((null!=(i=a.verificationGasLimitPercentageMultiplier)?i:0)+100)/100n,l.callGasLimit=null!=(o=a.callGasLimit)?o:p*BigInt((null!=(s=a.callGasLimitPercentageMultiplier)?s:0)+100)/100n,l}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");b=null!=(t=a.maxFeePerGas)?t:b*BigInt((null!=(r=a.maxFeePerGasPercentageMultiplier)?r:0)+100)/100n,P=null!=(i=a.maxPriorityFeePerGas)?i:P*BigInt((null!=(c=a.maxPriorityFeePerGasPercentageMultiplier)?c:0)+100)/100n;var l=f({},B,{sender:o.accountAddress,nonce:s,initCode:d,callData:E,maxFeePerGas:b,maxPriorityFeePerGas:P}),v=B.preVerificationGas,h=B.verificationGasLimit,p=B.callGasLimit,A=function(){if(null==a.preVerificationGas||null==a.verificationGasLimit||null==a.callGasLimit)return function(){if(null!=n)return Promise.resolve(o.estimateUserOperationGas(l,n,a.state_override_set,a.numberOfSigners,a.dummySignatures)).then(function(e){v=e[0],h=e[1],p=e[2]});throw new m("BAD_DATA","bundlerRpc cant't be null if preVerificationGas,verificationGasLimit and callGasLimit are not overriden")}()}();return A&&A.then?A.then(u):u()}var d=null!=(c=a.initCode)?c:o.initCode;if(null==d||s>0n)d="0x";else if(o.isInitWebAuthn){var l=D("0x080fbebf",["uint256","uint256","address"],[o.x,o.y,r.DEFAULT_WEB_AUTHN_VERIFIER]),v=D("0x1688f0b9",["address","bytes","uint256"],[r.DEFAULT_SIGNATURE_VALIDATOR,l,0]),h={to:r.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,value:0n,data:v},p=r.createWebAuthnSignerVerifierAddress(o.x,o.y),A=D("0xe318b52b",["address","address","address"],["0x0000000000000000000000000000000000000001",r.DEFAULT_WEB_AUTHN_SIGNATURE_VALIDATOR_SINGLETON,p]),g={to:r.DEFAULT_WEB_AUTHN_SIGNATURE_VALIDATOR_SINGLETON,value:0n,data:"0x578c7a83",operation:exports.Operation.Delegate};e=[h,{to:o.accountAddress,value:0n,data:A},g].concat(e)}if(s<0n)throw RangeError("nonce can't be negative");var E="0x";E=null==a.callData?1==e.length?r.createAccountCallDataSingleTransaction(e[0]):r.createAccountCallDataBatchTransactions(e):a.callData;var b=B.maxFeePerGas,P=B.maxPriorityFeePerGas,G=function(){if(null==a.maxFeePerGas||null==a.maxPriorityFeePerGas)return function(){if(null!=t)return Promise.resolve(y(t)).then(function(e){b=e[0],P=e[1]});throw new m("BAD_DATA","providerRpc cant't be null if maxFeePerGas and maxPriorityFeePerGas are not overriden")}()}();return G&&G.then?G.then(u):u()},o=this;if(e.length<1)throw RangeError("There should be at least one transaction");var s=0n,c=function(){if(null==a.nonce)return function(){if(null!=t)return Promise.resolve(g(t,o.entrypointAddress,o.accountAddress)).then(function(e){s=e});throw new m("BAD_DATA","providerRpc cant't be null if nonce is not overriden")}();s=a.nonce}();return Promise.resolve(c&&c.then?c.then(i):i())}catch(e){return Promise.reject(e)}},n.signUserOperation=function(e,n,a,i,o){if(void 0===i&&(i=0n),void 0===o&&(o=0n),n.length<1)throw RangeError("There should be at least one privateKey");if(a<0n)throw RangeError("chainId can't be negative");if(i<0n)throw RangeError("validAfter can't be negative");if(o<0n)throw RangeError("validUntil can't be negative");for(var s,f={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:o,entryPoint:this.entrypointAddress},c={chainId:a,verifyingContract:this.safe4337ModuleAddress},u=[],d=[],l=h(n);!(s=l()).done;){var v=new t.Wallet(s.value),p=v.signingKey.sign(t.TypedDataEncoder.hash(c,r.EIP712_SAFE_OPERATION_TYPE,f)).serialized;u.push(v.address),d.push(p)}return r.formatEip712SignaturesToUseroperationSignature(u,d,i,o)},r.createWebAuthnSignerVerifierAddress=function(e,n){var a=D("0x080fbebf",["uint256","uint256","address"],[e,n,r.DEFAULT_WEB_AUTHN_VERIFIER]),i=t.AbiCoder.defaultAbiCoder(),o=t.keccak256(t.solidityPacked(["bytes32","uint256"],[t.keccak256(a),0])),s=i.encode(["uint256"],[r.DEFAULT_SIGNATURE_VALIDATOR]),f=t.keccak256(t.solidityPacked(["bytes","bytes"],[r.DEFAULT_WEB_AUTHN_SIGNER_CREATION_CODE,s]));return"0x"+t.solidityPackedKeccak256(["bytes1","address","bytes32","bytes32"],["0xff",r.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,o,f]).slice(-40)},r.formatSignaturesToUseroperationSignature=function(e,n,a,i){void 0===n&&(n=null),void 0===a&&(a=0n),void 0===i&&(i=0n);var o=r.buildSignatures(e,n);return t.solidityPacked(["uint48","uint48","bytes"],[a,i,o])},r.getLowerCaseAddress=function(e){return"string"==typeof e?e.toLowerCase():r.createWebAuthnSignerVerifierAddress(e.x,e.y)},r.sortSignatures=function(e){e.sort(function(e,t){return r.getLowerCaseAddress(e.signer).localeCompare(r.getLowerCaseAddress(t.signer))})},r.buildSignatures=function(e,n){void 0===n&&(n=null),r.sortSignatures(e);var a=65*e.length,i=e.reduce(function(e,i){var o=e.segments,s=e.offset,f=i.signer,c=i.signature,u=i.isContractSignature;if(u=u||"string"!=typeof f){if("string"==typeof f)return{segments:[].concat(o,[t.ethers.solidityPacked(["uint256","uint256","uint8"],[f,a+s,0])]),offset:s+32+t.ethers.dataLength(c)};if(null==n)throw RangeError("Must define isInit parameter when using WebAuthn");return f=n?r.DEFAULT_WEB_AUTHN_SIGNATURE_VALIDATOR_SINGLETON:r.createWebAuthnSignerVerifierAddress(f.x,f.y),{segments:[].concat(o,[t.ethers.solidityPacked(["uint256","uint256","uint8"],[f,a+s,0])]),offset:s+32+t.ethers.dataLength(c)}}return{segments:[].concat(o,[t.ethers.solidityPacked(["bytes"],[c])]),offset:0}},{segments:[],offset:0});return t.ethers.concat([].concat(i.segments,e.map(function(e){var r=e.signature;return t.ethers.solidityPacked(["uint256","bytes"],[t.ethers.dataLength(r),r])})))},r.createWebAuthnSignature=function(e){return t.ethers.AbiCoder.defaultAbiCoder().encode(["bytes","bytes","uint256[2]"],[new Uint8Array(e.authenticatorData),e.clientDataFields,e.rs])},r}(C);function W(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}j.DEFAULT_WEB_AUTHN_SIGNATURE_VALIDATOR_SINGLETON="0xcA66C5A0eEAb0Fe74F343bb4A539042c68aE45F9",j.DEFAULT_WEB_AUTHN_SIGNER_FACTORY="0xEae2AD611c0e8E14604B8cc611a89d5e9d138B49",j.DEFAULT_WEB_AUTHN_VERIFIER="0xCAc51aDF726E4b269645a7fD6a43296A1Ff53e8d",j.DEFAULT_SIGNATURE_VALIDATOR="0x21E4747C7215fe6E343376034F08261bBD9ac497",j.DEFAULT_WEB_AUTHN_SIGNER_CREATION_CODE="0x608060405234801561001057600080fd5b5060405161017238038061017283398101604081905261002f916100b9565b6001600160a01b0381166100945760405162461bcd60e51b815260206004820152602260248201527f496e76616c69642073696e676c65746f6e20616464726573732070726f766964604482015261195960f21b606482015260840160405180910390fd5b600080546001600160a01b0319166001600160a01b03929092169190911790556100e9565b6000602082840312156100cb57600080fd5b81516001600160a01b03811681146100e257600080fd5b9392505050565b607b806100f76000396000f3fe608060405260008054632cf35bc960e11b8235016027576001600160f41b0381168252602082f35b3682833781823684845af490503d82833e806040573d82fd5b503d81f3fea264697066735822122062f4785a59897477a798d8218290ac5cf89f803649d66b453fa58689dd461e3164736f6c63430008140033";var H=/*#__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}c(t,e);var r=t.prototype;return r.initialize=function(){try{var e=this;return Promise.resolve(W(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=A(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?W(function(){return Promise.resolve(E(e.rpcUrl,"pm_supportedERC20Tokens",[])).then(function(e){return{tokens:e.tokens.map(function(e){return{symbol:e.symbol,address:e.address,decimal:Number(e.decimal),fee:BigInt(e.fee),exchangeRate:BigInt(e.exchangeRate)}}),paymasterMetadata:e.paymasterMetadata}})},function(e){var t=A(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?W(function(){return Promise.resolve(E(e.rpcUrl,"pm_supportedEntryPoint",[]))},function(e){var t=A(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.toLowerCase()===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={}),void 0===n&&(n={});try{var a=function(){return W(function(){function a(t){var a,c,u,d,l,v;if("bigint"==typeof n.preVerificationGas&&n.preVerificationGas<0n)throw RangeError("preVerificationGas overrid can't be negative");if("bigint"==typeof n.verificationGasLimit&&n.verificationGasLimit<0n)throw RangeError("verificationGasLimit overrid can't be negative");if("bigint"==typeof n.callGasLimit&&n.callGasLimit<0n)throw RangeError("callGasLimit overrid can't be negative");return e.preVerificationGas=null!=(a=n.preVerificationGas)?a:o*BigInt((null!=(c=n.preVerificationGasPercentageMultiplier)?c:0)+100)/100n,e.verificationGasLimit=null!=(u=n.verificationGasLimit)?u:s*BigInt((null!=(d=n.verificationGasLimitPercentageMultiplier)?d:0)+100)/100n,e.callGasLimit=null!=(l=n.callGasLimit)?l:f*BigInt((null!=(v=n.callGasLimitPercentageMultiplier)?v:0)+100)/100n,e.preVerificationGas=e.preVerificationGas+100n,e.verificationGasLimit=e.verificationGasLimit+10000n,Promise.resolve(E(i.rpcUrl,"pm_sponsorUserOperation",[e,i.entrypointAddress,r])).then(function(t){var r,n,a,i,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!=(a=f.verificationGasLimit)?a:e.verificationGasLimit,e.maxFeePerGas=null!=(i=f.maxFeePerGas)?i:e.maxFeePerGas,e.maxPriorityFeePerGas=null!=(o=f.maxPriorityFeePerGas)?o:e.maxPriorityFeePerGas,e})}e.paymasterAndData=i.paymasterMetadata.dummyPaymasterAndData;var o=e.preVerificationGas,s=e.verificationGasLimit,f=e.callGasLimit,c=function(){if(null==n.preVerificationGas||null==n.verificationGasLimit||null==n.callGasLimit)return function(){if(null!=t){var r=new F(t);e.callGasLimit=0n,e.verificationGasLimit=0n,e.preVerificationGas=0n;var a=e.maxFeePerGas,c=e.maxPriorityFeePerGas;return e.maxFeePerGas=0n,e.maxPriorityFeePerGas=0n,Promise.resolve(r.estimateUserOperationGas(e,i.entrypointAddress,n.state_override_set)).then(function(t){o<t.preVerificationGas&&(o=t.preVerificationGas),s<t.verificationGasLimit&&(s=t.verificationGasLimit),f<t.callGasLimit&&(f=t.callGasLimit),e.maxFeePerGas=a,e.maxPriorityFeePerGas=c})}throw new m("BAD_DATA","bundlerRpc cant't be null if preVerificationGas,verificationGasLimit and callGasLimit are not overriden")}()}();return c&&c.then?c.then(a):a()},function(e){var t=A(e);throw new m("PAYMASTER_ERROR","pm_sponsorUserOperation failed",{cause:t})})},i=this,o=function(){if(null==i.entrypointAddress||null==i.supportedTokens||null==i.paymasterMetadata)return Promise.resolve(i.initialize()).then(function(){})}();return Promise.resolve(o&&o.then?o.then(a):a())}catch(e){return Promise.reject(e)}},r.createSponsorPaymasterUserOperation=function(e,t,r){void 0===r&&(r={});try{return Promise.resolve(this.createPaymasterUserOperation(e,t,{},r))}catch(e){return Promise.reject(e)}},r.createTokenPaymasterUserOperation=function(e,t,r,n,a){void 0===a&&(a={});try{var i=this;return Promise.resolve(W(function(){return Promise.resolve(i.calculateUserOperationErc20TokenMaxGasCost(t,r)).then(function(o){var s=2n*o;return Promise.resolve(i.getPaymasterMetaData()).then(function(o){var f=e.prependTokenPaymasterApproveToCallData(t.callData,r,o.address,s);return t.callData=f,Promise.resolve(i.createPaymasterUserOperation(t,n,{token:r},a))})})},function(e){var t=A(e);throw new m("PAYMASTER_ERROR","createTokenPaymasterUserOperation failed",{cause:t})}))}catch(e){return Promise.reject(e)}},r.calculateUserOperationErc20TokenMaxGasCost=function(e,t){try{var r=this;return Promise.resolve(W(function(){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,function(e,t){return"bigint"==typeof t?"0x"+t.toString(16):t})}})});var a=G(e);return n.exchangeRate*a/BigInt(Math.pow(10,18))})},function(e){var t=A(e);throw new m("PAYMASTER_ERROR","calculateUserOperationErc20TokenMaxGasCost failed",{cause:t})}))}catch(e){return Promise.reject(e)}},t}(function(){}),z={__proto__:null,SmartAccount:o,SocialRecoveryModule:R,SafeAccountV0_2_0:V,SafeAccountWebAuth:j,SendUseroperationResponse:w,SmartAccountFactory:M,SafeAccountFactory:k,Bundler:F,CandidePaymaster:H,createUserOperationHash:b,createCallData:D,getFunctionSelector:P,fetchAccountNonce:g,calculateUserOperationMaxGasCost:G,get SafeModuleExecutorFunctionSelector(){return exports.SafeModuleExecutorFunctionSelector},get DummySignature(){return exports.DummySignature},get Operation(){return exports.Operation},ZeroAddress:N,UserOperationDummyValues:B};exports.Bundler=F,exports.CandidePaymaster=H,exports.SafeAccountFactory=k,exports.SafeAccountV0_2_0=V,exports.SafeAccountWebAuth=j,exports.SendUseroperationResponse=w,exports.SmartAccount=o,exports.SmartAccountFactory=M,exports.SocialRecoveryModule=R,exports.UserOperationDummyValues=B,exports.ZeroAddress=N,exports.abstractionkit=z,exports.calculateUserOperationMaxGasCost=G,exports.createCallData=D,exports.createUserOperationHash=b,exports.fetchAccountNonce=g,exports.getFunctionSelector=P; |
@@ -1,1 +0,1 @@ | ||
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 v(){return v=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},v.apply(this,arguments)}function m(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,y(e,t)}function h(e){return h=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},h(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,h(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"},G=/*#__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 m(t,e),t}(/*#__PURE__*/A(Error));function E(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 D=function(e,t,r,n){void 0===n&&(n=0);try{var i=[{from:"0x0000000000000000000000000000000000000000",to:t,data:_(S("getNonce(address,uint192)"),["address","uint192"],[r,n])},"latest"];return Promise.resolve(function(t,r){try{var n=Promise.resolve(b(e,"eth_call",i)).then(function(e){if("string"!=typeof e)throw new G("BAD_DATA","getNonce returned ill formed data",{context:JSON.stringify(e)});try{return BigInt(e)}catch(e){var t=E(e);throw new G("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=E(e);throw new G("BAD_DATA","getNonce failed",{cause:t})}))}catch(e){return Promise.reject(e)}},b=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 G(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 _(e,r,n){return e+t.defaultAbiCoder().encode(r,n).slice(2)}function S(e){return r(e).slice(0,10)}function L(e){return(e.callGasLimit+e.verificationGasLimit*("0x"==e.paymasterAndData||null==e.paymasterAndData?3n:0n)+e.preVerificationGas)*e.maxFeePerGas}var T,x="0x0000000000000000000000000000000000000000",F={sender:x,nonce:0n,initCode:"0x",callData:"0x",callGasLimit:0n,verificationGasLimit:0n,preVerificationGas:0n,maxFeePerGas:0n,maxPriorityFeePerGas:0n,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=_(this.generatorFunctionSelector,this.generatorFunctionInputAbi,e);return this.address+t.slice(2)},e}(),U=/*#__PURE__*/function(e){function t(t){return void 0===t&&(t="0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67"),e.call(this,t,"0x1688f0b9",["address","bytes","uint256"])||this}return m(t,e),t}(O);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"}(T||(T={}));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(b(e.rpcUrl,"eth_chainId",[])).then(function(e){if("string"==typeof e)return e;throw new G("BAD_DATA","bundler eth_chainId rpc call failed")})},function(e){var t=E(e);throw new G("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(b(e.rpcUrl,"eth_supportedEntryPoints",[]))},function(e){var t=E(e);throw new G("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(b(n.rpcUrl,"eth_estimateUserOperationGas",[e,t])).then(function(e){a=e}):Promise.resolve(b(n.rpcUrl,"eth_estimateUserOperationGas",[e,t,r])).then(function(e){a=e});return o&&o.then?o.then(i):i()},function(e){var t=E(e);throw new G("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(b(r.rpcUrl,"eth_sendUserOperation",[e,t]))},function(e){var t=E(e);throw new G("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(b(t.rpcUrl,"eth_getUserOperationReceipt",[e])).then(function(e){var t=e;if(null!=t){var r=v({},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 v({},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=E(t);throw new G("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(b(t.rpcUrl,"eth_getUserOperationByHash",[e])).then(function(e){return null!=e?v({},e,{blockNumber:null==e.blockNumber?null:BigInt(e.blockNumber)}):null})},function(t){var r=E(t);throw new G("BUNDLER_ERROR","bundler eth_getUserOperationByHash rpc call failed",{cause:r,context:{useroperationhash:e}})}))}catch(e){return Promise.reject(e)}},e}();function B(e,t,r){if(!e.s){if(r instanceof M){if(!r.s)return void(r.o=B.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(B.bind(null,e,t),B.bind(null,e,2));e.s=t,e.v=r;const n=e.o;n&&n(e)}}var M=/*#__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{B(n,1,a(this.v))}catch(e){B(n,2,e)}return n}return this}return this.o=function(e){try{var i=e.v;1&e.s?B(n,1,t?t(i):i):r?B(n,1,r(i)):B(n,2,i)}catch(e){B(n,2,e)}},n},e}();function N(e){return e instanceof M&&1&e.s}var V=/*#__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 G("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(N(i)&&(i=i.v),!i)return a;if(i.then){n=0;break}var a=r();if(a&&a.then){if(!N(a)){n=1;break}a=a.s}if(t){var o=t();if(o&&o.then&&!N(o)){n=2;break}}}var s=new M,f=B.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&&!N(o))return void o.then(l).then(void 0,f);if(!(i=e())||N(i)&&!i.v)return void B(s,1,a);if(i.then)return void i.then(u).then(void 0,f);N(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):B(s,1,a)}function l(){(i=e())?i.then?i.then(u).then(void 0,f):u(i):B(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}m(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.createAccountAddress=function(e,t){return void 0===t&&(t={}),i.createAccountAddressAndInitCode(e,t)[0]},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 U;null!=t.safeAccountFactoryAddress&&(p=new U(t.safeAccountFactoryAddress));var v=i.createInitializerCallData(e,f,l,d);return[this.createProxyAddress(v,c,p.address,u),p.getFactoryGeneratorFunctionCallData([u,v,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=_("0x8d0dc49f",["address[]"],[[r]]);return _(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 U),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=_("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),_(a,i.executorFunctionInputAbi,[e,t,r,n])},i.decodeAccountCallData=function(e){if(e.startsWith(T.executeUserOpWithErrorString)||e.startsWith(T.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 G("BAD_DATA","Invalid calldata, should start with "+T.executeUserOpWithErrorString+" or "+T.executeUserOp,{context:{callData:e}})};var c=i.prototype;return c.prependTokenPaymasterApproveToCallData=function(e,t,r,n,a){return void 0===a&&(a=i.DEFAULT_MULTISEND_CONTRACT_ADDRESS),i.prependTokenPaymasterApproveToCallDataStatic(e,t,r,n,a)},i.prependTokenPaymasterApproveToCallDataStatic=function(e,r,n,a,o){void 0===o&&(o=i.DEFAULT_MULTISEND_CONTRACT_ADDRESS);var s=i.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 v=w([{to:r,value:0n,data:_(S("approve(address,uint256)"),["address","uint256"],[n,a]),operation:u.Call}]),m="",h="0x8d80ff0a";if(p.startsWith(h)){var y=function(e){return t.defaultAbiCoder().decode(["bytes"],"0x"+e.slice(10))[0]}(p);m=y+v.slice(2)}else m=w([{to:f,value:c,data:l,operation:d}])+v.slice(2);var A=_(h,["bytes"],[m]);return i.createAccountCallData(o,0n,A,u.Delegate)},c.estimateUserOperationGas=function(e,t,r,n){void 0===n&&(n=1);try{if(n<1n)throw RangeError("numberOfSigners can't be less than 1");for(var i="",a=0;a<n;a++)i+="ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff";e.signature="0xffffffffffffffffffffffff"+i;var o=new C(t),s=e.maxFeePerGas,f=e.maxPriorityFeePerGas;return e.maxFeePerGas=0n,e.maxPriorityFeePerGas=0n,Promise.resolve(o.estimateUserOperationGas(e,this.entrypointAddress,r)).then(function(t){return e.maxFeePerGas=s,e.maxPriorityFeePerGas=f,[BigInt(t.preVerificationGas),BigInt(t.verificationGasLimit)+30000n*BigInt(n),BigInt(t.callGasLimit)]})}catch(e){return Promise.reject(e)}},c.createUserOperation=function(e,t,r,a){void 0===a&&(a={});try{var o=function(o){var c;function u(e){var t,n,i,o;function c(e){var t,r,n,i,o,s;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 u.preVerificationGas=null!=(t=a.preVerificationGas)?t:l*BigInt(Math.floor(((null!=(r=a.preVerificationGasPercentageMultiplier)?r:0)+100)/100)),u.verificationGasLimit=null!=(n=a.verificationGasLimit)?n:y*BigInt(Math.floor(((null!=(i=a.verificationGasLimitPercentageMultiplier)?i:0)+100)/100)),u.callGasLimit=null!=(o=a.callGasLimit)?o:A*BigInt(Math.floor(((null!=(s=a.callGasLimitPercentageMultiplier)?s:0)+100)/100)),u}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");m=null!=(t=a.maxFeePerGas)?t:m*BigInt(Math.floor(((null!=(n=a.maxFeePerGasPercentageMultiplier)?n:0)+100)/100)),h=null!=(i=a.maxPriorityFeePerGas)?i:h*BigInt(Math.floor(((null!=(o=a.maxPriorityFeePerGasPercentageMultiplier)?o:0)+100)/100));var u=v({},F,{sender:s.accountAddress,nonce:f,initCode:d,callData:p,maxFeePerGas:m,maxPriorityFeePerGas:h}),l=F.preVerificationGas,y=F.verificationGasLimit,A=F.callGasLimit,P=function(){if(null==a.preVerificationGas||null==a.verificationGasLimit||null==a.callGasLimit)return function(){if(null!=r){u.callGasLimit=0n,u.verificationGasLimit=0n,u.preVerificationGas=0n;var e=u.maxFeePerGas,t=u.maxPriorityFeePerGas;return u.maxFeePerGas=0n,u.maxPriorityFeePerGas=0n,Promise.resolve(s.estimateUserOperationGas(u,r,a.state_override_set,a.numberOfSigners)).then(function(r){l=r[0],y=r[1],A=r[2],u.maxFeePerGas=e,u.maxPriorityFeePerGas=t})}throw new G("BAD_DATA","bundlerRpc cant't be null if preVerificationGas,verificationGasLimit and callGasLimit are not overriden")}()}();return P&&P.then?P.then(c):c()}var d=null!=(c=a.initCode)?c:s.initCode;if((null==d||f>0n)&&(d="0x"),f<0n)throw RangeError("nonce can't be negative");var p="0x";p=null==a.callData?1==e.length?i.createAccountCallDataSingleTransaction(e[0]):i.createAccountCallDataBatchTransactions(e):a.callData;var m=F.maxFeePerGas,h=F.maxPriorityFeePerGas,y=function(){if(null==a.maxFeePerGas||null==a.maxPriorityFeePerGas)return function(){if(null!=t)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){0n==(m=e[0])&&(m=1n),0n==(h=e[1])&&(h=1n)});throw new G("BAD_DATA","providerRpc cant't be null if maxFeePerGas and maxPriorityFeePerGas are not overriden")}()}();return y&&y.then?y.then(u):u()},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 function(){if(null!=t)return Promise.resolve(D(t,s.entrypointAddress,s.accountAddress)).then(function(e){f=e});throw new G("BAD_DATA","providerRpc cant't be null if nonce is not overriden")}();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,a){if(void 0===n&&(n=0n),void 0===a&&(a=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(a<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:a,entryPoint:this.entrypointAddress},u={chainId:r,verifyingContract:this.safe4337ModuleAddress},l=[],d=[],p=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=p()).done;){var v=new s(o.value),m=v.signingKey.sign(f.hash(u,i.EIP712_SAFE_OPERATION_TYPE,c)).serialized;l.push(v.address),d.push(m)}return i.formatEip712SignaturesToUseroperationSignature(l,d,n,a)},i.formatEip712SignaturesToUseroperationSignature=function(e,t,r,n){if(void 0===r&&(r=0n),void 0===n&&(n=0n),e.length!=t.length)throw RangeError("signersAddresses and signatures arrays should be the same length");var a=new Map;e.forEach(function(e,r){a.set(e.toLocaleLowerCase(),t[r])});var o=new Map(Array.from(a).sort()),s="0x"+Array.from(o.values()).reduce(function(e,t){return e+t.slice(2)},"");return i.formatEip712SingleSignatureToUseroperationSignature(s,r,n)},i.formatEip712SingleSignatureToUseroperationSignature=function(e,t,r){if(void 0===t&&(t=0n),void 0===r&&(r=0n),t<0n)throw RangeError("validAfter can't be negative");if(r<0n)throw RangeError("validUntil can't be negative");return a(["uint48","uint48","bytes"],[t,r,e])},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 V(e,n,r.entrypointAddress)})}catch(e){return Promise.reject(e)}},i}(d);function j(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=T.executeUserOpWithErrorString,k.executorFunctionInputAbi=["address","uint256","bytes","uint8"],k.EIP712_SAFE_OPERATION_TYPE={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"}]};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}m(t,e);var r=t.prototype;return r.initialize=function(){try{var e=this;return Promise.resolve(j(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=E(e);throw new G("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?j(function(){return Promise.resolve(b(e.rpcUrl,"pm_supportedERC20Tokens",[])).then(function(e){return{tokens:e.tokens.map(function(e){return{symbol:e.symbol,address:e.address,decimal:Number(e.decimal),fee:BigInt(e.fee),exchangeRate:BigInt(e.exchangeRate)}}),paymasterMetadata:e.paymasterMetadata}})},function(e){var t=E(e);throw new G("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?j(function(){return Promise.resolve(b(e.rpcUrl,"pm_supportedEntryPoint",[]))},function(e){var t=E(e);throw new G("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.toLowerCase()===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={}),void 0===n&&(n={});try{var i=function(){return j(function(){function i(t){var i,c,u,l,d,p;if("bigint"==typeof n.preVerificationGas&&n.preVerificationGas<0n)throw RangeError("preVerificationGas overrid can't be negative");if("bigint"==typeof n.verificationGasLimit&&n.verificationGasLimit<0n)throw RangeError("verificationGasLimit overrid can't be negative");if("bigint"==typeof n.callGasLimit&&n.callGasLimit<0n)throw RangeError("callGasLimit overrid can't be negative");return e.preVerificationGas=null!=(i=n.preVerificationGas)?i:o*BigInt((null!=(c=n.preVerificationGasPercentageMultiplier)?c:0)+100)/100n,e.verificationGasLimit=null!=(u=n.verificationGasLimit)?u:s*BigInt((null!=(l=n.verificationGasLimitPercentageMultiplier)?l:0)+100)/100n,e.callGasLimit=null!=(d=n.callGasLimit)?d:f*BigInt((null!=(p=n.callGasLimitPercentageMultiplier)?p:0)+100)/100n,e.preVerificationGas=e.preVerificationGas+100n,e.verificationGasLimit=e.verificationGasLimit+10000n,Promise.resolve(b(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})}e.paymasterAndData=a.paymasterMetadata.dummyPaymasterAndData;var o=e.preVerificationGas,s=e.verificationGasLimit,f=e.callGasLimit,c=function(){if(null==n.preVerificationGas||null==n.verificationGasLimit||null==n.callGasLimit)return function(){if(null!=t){var r=new C(t);e.callGasLimit=0n,e.verificationGasLimit=0n,e.preVerificationGas=0n;var i=e.maxFeePerGas,c=e.maxPriorityFeePerGas;return e.maxFeePerGas=0n,e.maxPriorityFeePerGas=0n,Promise.resolve(r.estimateUserOperationGas(e,a.entrypointAddress,n.state_override_set)).then(function(t){o<t.preVerificationGas&&(o=t.preVerificationGas),s<t.verificationGasLimit&&(s=t.verificationGasLimit),f<t.callGasLimit&&(f=t.callGasLimit),e.maxFeePerGas=i,e.maxPriorityFeePerGas=c})}throw new G("BAD_DATA","bundlerRpc cant't be null if preVerificationGas,verificationGasLimit and callGasLimit are not overriden")}()}();return c&&c.then?c.then(i):i()},function(e){var t=E(e);throw new G("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){void 0===r&&(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(j(function(){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))})})},function(e){var t=E(e);throw new G("PAYMASTER_ERROR","createTokenPaymasterUserOperation failed",{cause:t})}))}catch(e){return Promise.reject(e)}},r.calculateUserOperationErc20TokenMaxGasCost=function(e,t){try{var r=this;return Promise.resolve(j(function(){return Promise.resolve(r.getSupportedERC20TokenData(t)).then(function(n){if(null==n)return Promise.resolve(r.getSupportedERC20TokensAndPaymasterMetadata()).then(function(e){throw new G("PAYMASTER_ERROR",t+" token is not supported by the paymaster.",{context:{supportedERC20TokensAndPaymasterMetadata:JSON.stringify(e,function(e,t){return"bigint"==typeof t?"0x"+t.toString(16):t})}})});var i=L(e);return n.exchangeRate*i/BigInt(Math.pow(10,18))})},function(e){var t=E(e);throw new G("PAYMASTER_ERROR","calculateUserOperationErc20TokenMaxGasCost failed",{cause:t})}))}catch(e){return Promise.reject(e)}},t}(function(){}),Y={__proto__:null,SmartAccount:d,SafeAccountV0_2_0:k,SendUseroperationResponse:V,SmartAccountFactory:O,SafeAccountFactory:U,Bundler:C,CandidePaymaster:z,createUserOperationHash:R,createCallData:_,getFunctionSelector:S,fetchAccountNonce:D,calculateUserOperationMaxGasCost:L,get SafeModuleExecutorFunctionSelector(){return T},get Operation(){return u},ZeroAddress:x,UserOperationDummyValues:F};export{C as Bundler,z as CandidePaymaster,u as Operation,U as SafeAccountFactory,k as SafeAccountV0_2_0,T as SafeModuleExecutorFunctionSelector,V as SendUseroperationResponse,d as SmartAccount,O as SmartAccountFactory,F as UserOperationDummyValues,x as ZeroAddress,Y as abstractionkit,L as calculateUserOperationMaxGasCost,_ as createCallData,R as createUserOperationHash,D as fetchAccountNonce,S as getFunctionSelector}; | ||
import*as e from"isomorphic-unfetch";import{keccak256 as t,AbiCoder as r,id as n,JsonRpcProvider as a,getBytes as i,solidityPacked as o,solidityPackedKeccak256 as s,TypedDataEncoder as f,Wallet as c,ethers as u}from"ethers";var d,l,v=function(e){this.accountAddress=void 0,this.accountAddress=e};function h(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(h=function(){return!!e})()}function m(){return m=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},m.apply(this,arguments)}function p(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,g(e,t)}function A(e){return A=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},A(e)}function g(e,t){return g=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},g(e,t)}function y(e){var t="function"==typeof Map?new Map:void 0;return y=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(h())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,t);var a=new(e.bind.apply(e,n));return r&&g(a,r.prototype),a}(e,arguments,A(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),g(r,e)},y(e)}function E(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}function D(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 E(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)?E(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){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.")}v.proxyByteCode=void 0,v.initializerFunctionSelector=void 0,v.initializerFunctionInputAbi=void 0,v.executorFunctionSelector=void 0,v.executorFunctionInputAbi=void 0,function(e){e[e.Call=0]="Call",e[e.Delegate=1]="Delegate"}(d||(d={})),function(e){e[e.Slow=1]="Slow",e[e.Medium=1.2]="Medium",e[e.Fast=1.5]="Fast"}(l||(l={}));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"},b=/*#__PURE__*/function(e){function t(t,r,n){var a;void 0===n&&(n={});var i=n.errno,o=n.context;return(a=e.call(this,r,{cause:n.cause})||this).code=void 0,a.context=void 0,a.errno=void 0,a.name=a.constructor.name,a.code=t,a.errno=i,a.context=o,a}return p(t,e),t}(/*#__PURE__*/y(Error));function G(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 _=function(e,t){try{void 0===t&&(t=l.Medium);var r=new a(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=function(e,t,r,n){void 0===n&&(n=0);try{var a=[{from:"0x0000000000000000000000000000000000000000",to:t,data:S(F("getNonce(address,uint192)"),["address","uint192"],[r,n])},"latest"];return Promise.resolve(function(t,r){try{var n=Promise.resolve(R(e,"eth_call",a)).then(function(e){if("string"!=typeof e)throw new b("BAD_DATA","getNonce returned ill formed data",{context:JSON.stringify(e)});try{return BigInt(e)}catch(e){var t=G(e);throw new b("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=G(e);throw new b("BAD_DATA","getNonce failed",{cause:t})}))}catch(e){return Promise.reject(e)}},R=function(t,r,n){try{var a=e.default||e,i={method:"POST",body:JSON.stringify({method:r,params:n,id:(new Date).getTime(),jsonrpc:"2.0"},function(e,t){return"bigint"==typeof t?"0x"+t.toString(16):t}),redirect:"follow"};return Promise.resolve(a(t,i)).then(function(e){return Promise.resolve(e.json()).then(function(e){if("result"in e)return e.result;var r=e.error,n=String(r.code);throw new b(n in P?P[n]:"UNKNOWN_ERROR",r.message,{errno:r.code,context:{url:t,requestOptions:JSON.stringify(i)}})})})}catch(e){return Promise.reject(e)}};function L(e,n,a){var i=t(function(e){var n=[e.sender,e.nonce,t(e.initCode),t(e.callData),e.callGasLimit,e.verificationGasLimit,e.preVerificationGas,e.maxFeePerGas,e.maxPriorityFeePerGas,t(e.paymasterAndData)];return r.defaultAbiCoder().encode(["address","uint256","bytes32","bytes32","uint256","uint256","uint256","uint256","uint256","bytes32"],n)}(e)),o=r.defaultAbiCoder().encode(["bytes32","address","uint256"],[i,n,a]);return t(o)}function S(e,t,n){return e+r.defaultAbiCoder().encode(t,n).slice(2)}function F(e){return n(e).slice(0,10)}function U(e){return(e.callGasLimit+e.verificationGasLimit*("0x"==e.paymasterAndData||null==e.paymasterAndData?3n:0n)+e.preVerificationGas)*e.maxFeePerGas}var I,x,O=function(e,t,r){try{var n=[t,r];return Promise.resolve(function(t,r){try{var a=Promise.resolve(R(e,"eth_call",n)).then(function(e){if("string"!=typeof e)throw new b("BAD_DATA","eth_call returned ill formed data",{context:JSON.stringify(e)});try{return e}catch(e){var t=G(e);throw new b("BAD_DATA","eth_call returned ill formed data",{cause:t})}})}catch(e){return r(e)}return a&&a.then?a.then(void 0,r):a}(0,function(e){var t=G(e);throw new b("BAD_DATA","eth_call failed",{cause:t})}))}catch(e){return Promise.reject(e)}},w=/*#__PURE__*/function(e){function t(r){return void 0===r&&(r=t.DEFAULT_SOCIAL_RECOVERY_ADDRESS),e.call(this,r)||this}p(t,e);var n=t.prototype;return n.createConfirmRecoveryMetaTransaction=function(e,t,r,n){var a=S(F("confirmRecovery(address,address[],uint256,bool)"),["address","address[]","uint256","bool"],[e,t,r,n]);return{to:this.moduleAddress,data:a,value:0n}},n.createMultiConfirmRecoveryMetaTransaction=function(e,t,r,n,a){var i=S(F("multiConfirmRecovery(address,address[],uint256,address[],bool)"),["address","address[]","uint256","address[]","bool"],[e,t,r,n,a]);return{to:this.moduleAddress,data:i,value:0n}},n.createExecuteRecoveryMetaTransaction=function(e,t,r){var n=S(F("executeRecovery(address,address[],uint256)"),["address","address[]","uint256"],[e,t,r]);return{to:this.moduleAddress,data:n,value:0n}},n.createFinalizeRecoveryMetaTransaction=function(e){var t=S(F("finalizeRecovery(address)"),["address"],[e]);return{to:this.moduleAddress,data:t,value:0n}},n.createCancelRecoveryMetaTransaction=function(e){var t=S(F("cancelRecovery(address)"),["address"],[e]);return{to:this.moduleAddress,data:t,value:0n}},n.createAddGuardianWithThresholdMetaTransaction=function(e,t,r){var n=S(F("addGuardianWithThreshold(address,address,uint256)"),["address","address","uint256"],[e,t,r]);return{to:this.moduleAddress,data:n,value:0n}},n.createRevokeGuardianWithThresholdMetaTransaction=function(e,t,r,n){var a=S(F("revokeGuardianWithThreshold(address,address,address,uint256)"),["address","address","address","uint256"],[e,t,r,n]);return{to:this.moduleAddress,data:a,value:0n}},n.createChangeThresholdMetaTransaction=function(e,t){var r=S(F("changeThreshold(address,uint256)"),["address","uint256"],[e,t]);return{to:this.moduleAddress,data:r,value:0n}},n.getRecoveryHash=function(e,t,r,n,a){try{var i=S(F("getRecoveryHash(address,address[],uint256,uint256)"),["address","address[]","uint256","uint256"],[t,r,n,a]);return O(e,{to:this.moduleAddress,data:i},"latest")}catch(e){return Promise.reject(e)}},n.getRecoveryRequest=function(e,t){try{var n=S(F("getRecoveryRequest(address)"),["address"],[t]);return Promise.resolve(O(e,{to:this.moduleAddress,data:n},"latest")).then(function(e){var t=r.defaultAbiCoder().decode(["uint256","uint256","uint64","address[]"],e);return{guardiansApprovalCount:t[0],newThreshold:t[1],executeAfter:t[2],newOwners:t[3]}})}catch(e){return Promise.reject(e)}},n.getRecoveryApprovals=function(e,t,n,a){try{var i=S(F("getRecoveryApprovals(address,address[],uint256)"),["address","address[]","uint256"],[t,n,a]);return Promise.resolve(O(e,{to:this.moduleAddress,data:i},"latest")).then(function(e){var t=r.defaultAbiCoder().decode(["uint256"],e);return BigInt(t[0])})}catch(e){return Promise.reject(e)}},n.hasGuardianApproved=function(e,t,n,a,i){try{var o=S(F("hasGuardianApproved(address,address,address[],uint256)"),["address","address","address[]","uint256"],[t,n,a,i]);return Promise.resolve(O(e,{to:this.moduleAddress,data:o},"latest")).then(function(e){var t=r.defaultAbiCoder().decode(["bool"],e);return Boolean(t[0])})}catch(e){return Promise.reject(e)}},n.isGuardian=function(e,t,n){try{var a=S(F("isGuardian(address,address)"),["address","address"],[t,n]);return Promise.resolve(O(e,{to:this.moduleAddress,data:a},"latest")).then(function(e){var t=r.defaultAbiCoder().decode(["bool"],e);return Boolean(t[0])})}catch(e){return Promise.reject(e)}},n.guardiansCount=function(e,t){try{var n=S(F("guardiansCount(address)"),["address"],[t]);return Promise.resolve(O(e,{to:this.moduleAddress,data:n},"latest")).then(function(e){var t=r.defaultAbiCoder().decode(["uint256"],e);return BigInt(t[0])})}catch(e){return Promise.reject(e)}},n.threshold=function(e,t){try{var n=S(F("threshold(address)"),["address"],[t]);return Promise.resolve(O(e,{to:this.moduleAddress,data:n},"latest")).then(function(e){var t=r.defaultAbiCoder().decode(["uint256"],e);return BigInt(t[0])})}catch(e){return Promise.reject(e)}},n.getGuardians=function(e,t){try{var n=S(F("getGuardians(address)"),["address"],[t]);return Promise.resolve(O(e,{to:this.moduleAddress,data:n},"latest")).then(function(e){return r.defaultAbiCoder().decode(["address[]"],e)[0]})}catch(e){return Promise.reject(e)}},n.nonce=function(e,t){try{var n=S(F("nonce(address)"),["address"],[t]);return Promise.resolve(O(e,{to:this.moduleAddress,data:n},"latest")).then(function(e){var t=r.defaultAbiCoder().decode(["uint256"],e);return BigInt(t[0])})}catch(e){return Promise.reject(e)}},t}(/*#__PURE__*/function(){function e(e){this.moduleAddress=void 0,this.moduleAddress=e}return e.prototype.createEnableModuleMetaTransaction=function(e){return{to:e,data:S(F("enableModule(address)"),["address"],[this.moduleAddress]),value:0n}},e}());function C(e){return"0x"+e.map(function(e){return n=null!=(r=(t=e).operation)?r:d.Call,a=i(t.data),o(["uint8","address","uint256","uint256","bytes"],[n,t.to,t.value,a.length,a]).slice(2);var t,r,n,a}).join("")}function N(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}w.DEFAULT_SOCIAL_RECOVERY_ADDRESS="0xFc98B4a5120959511873a51daBd6c1889897412d",function(e){e.executeUserOpWithErrorString="0x541d63c8",e.executeUserOp="0x7bb37428"}(I||(I={})),function(e){e.eoa="ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",e.webAuthn="5715d3b8fc6e09d43d24175720e98c1ed970661400000000000000000000000000000000000000000000000000000000000000410000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e0762c7349c04b09b85aa0b0d21ba70df2195d60c653877df252a16c3f62559fa02d0dbe584b8a794bcf5fc5263f42cf8d50d200c3bc15fe375508e24ca97002ad000000000000000000000000000000000000000000000000000000000000002549960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d9763050000000e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a1226f726967696e223a22687474703a2f2f6c6f63616c686f73743a35313733222c2263726f73734f726967696e223a66616c73652c226f746865725f6b6579735f63616e5f62655f61646465645f68657265223a22646f206e6f7420636f6d7061726520636c69656e74446174614a534f4e20616761696e737420612074656d706c6174652e205365652068747470733a2f2f676f6f2e676c2f7961625065782200000000000000000000000000000000000000000000000000000000000000"}(x||(x={}));var B=/*#__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(N(function(){return Promise.resolve(R(e.rpcUrl,"eth_chainId",[])).then(function(e){if("string"==typeof e)return e;throw new b("BAD_DATA","bundler eth_chainId rpc call failed")})},function(e){var t=G(e);throw new b("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(N(function(){return Promise.resolve(R(e.rpcUrl,"eth_supportedEntryPoints",[]))},function(e){var t=G(e);throw new b("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(N(function(){function a(){var e=i;return{callGasLimit:BigInt(e.callGasLimit),preVerificationGas:BigInt(e.preVerificationGas),verificationGasLimit:BigInt(e.verificationGasLimit)}}var i={},o=void 0===r?Promise.resolve(R(n.rpcUrl,"eth_estimateUserOperationGas",[e,t])).then(function(e){i=e}):Promise.resolve(R(n.rpcUrl,"eth_estimateUserOperationGas",[e,t,r])).then(function(e){i=e});return o&&o.then?o.then(a):a()},function(e){var t=G(e);throw new b("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(N(function(){return Promise.resolve(R(r.rpcUrl,"eth_sendUserOperation",[e,t]))},function(e){var t=G(e);throw new b("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(N(function(){return Promise.resolve(R(t.rpcUrl,"eth_getUserOperationReceipt",[e])).then(function(e){var t=e;if(null!=t){var r=m({},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 m({},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=G(t);throw new b("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(N(function(){return Promise.resolve(R(t.rpcUrl,"eth_getUserOperationByHash",[e])).then(function(e){return null!=e?m({},e,{blockNumber:null==e.blockNumber?null:BigInt(e.blockNumber)}):null})},function(t){var r=G(t);throw new b("BUNDLER_ERROR","bundler eth_getUserOperationByHash rpc call failed",{cause:r,context:{useroperationhash:e}})}))}catch(e){return Promise.reject(e)}},e}();function M(e,t,r){if(!e.s){if(r instanceof V){if(!r.s)return void(r.o=M.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(M.bind(null,e,t),M.bind(null,e,2));e.s=t,e.v=r;const n=e.o;n&&n(e)}}var V=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(t,r){var n=new e,a=this.s;if(a){var i=1&a?t:r;if(i){try{M(n,1,i(this.v))}catch(e){M(n,2,e)}return n}return this}return this.o=function(e){try{var a=e.v;1&e.s?M(n,1,t?t(a):a):r?M(n,1,r(a)):M(n,2,a)}catch(e){M(n,2,e)}},n},e}();function j(e){return e instanceof V&&1&e.s}var k=/*#__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 b("TIMEOUT","can't find useroperation",{context:a.userOperationHash})},a=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 i=0,o=function(e,t,r){for(var n;;){var a=e();if(j(a)&&(a=a.v),!a)return i;if(a.then){n=0;break}var i=r();if(i&&i.then){if(!j(i)){n=1;break}i=i.s}if(t){var o=t();if(o&&o.then&&!j(o)){n=2;break}}}var s=new V,f=M.bind(null,s,2);return(0===n?a.then(u):1===n?i.then(c):o.then(d)).then(void 0,f),s;function c(n){i=n;do{if(t&&(o=t())&&o.then&&!j(o))return void o.then(d).then(void 0,f);if(!(a=e())||j(a)&&!a.v)return void M(s,1,i);if(a.then)return void a.then(u).then(void 0,f);j(i=r())&&(i=i.v)}while(!i||!i.then);i.then(c).then(void 0,f)}function u(e){e?(i=r())&&i.then?i.then(c).then(void 0,f):c(i):M(s,1,i)}function d(){(a=e())?a.then?a.then(u).then(void 0,f):u(a):M(s,1,i)}}(function(){return!r&&i<=e},void 0,function(){return Promise.resolve(a.delay(1e3*t)).then(function(){return Promise.resolve(a.bundler.getUserOperationReceipt(a.userOperationHash)).then(function(e){if(null!=e)return r=1,e;i++})})});return Promise.resolve(o&&o.then?o.then(n):n(o))}catch(e){return Promise.reject(e)}},e}(),W=/*#__PURE__*/function(e){function n(t,r,a){var i;return void 0===r&&(r=n.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===a&&(a=n.DEFAULT_ENTRYPOINT_ADDRESS),(i=e.call(this,t)||this).entrypointAddress=void 0,i.safe4337ModuleAddress=void 0,i.initCode=void 0,i.entrypointAddress=a,i.safe4337ModuleAddress=r,i.initCode=null,i}return p(n,e),n.createProxyAddress=function(e,n,a,i){if(n<0n)throw RangeError("c2Nonce can't be negative");var f=r.defaultAbiCoder(),c=t(o(["bytes32","uint256"],[t(e),n])),u=f.encode(["uint256"],[i]),d=t(o(["bytes","bytes"],[this.proxyByteCode,u]));return"0x"+s(["bytes1","address","bytes32","bytes32"],["0xff",a,c,d]).slice(-40)},n.createAccountCallDataSingleTransaction=function(e){var t,r,a,i=null!=(t=e.value)?t:0,o=null!=(r=e.data)?r:"0x",s=null!=(a=e.operation)?a:d.Call;return n.createAccountCallData(e.to,i,o,s)},n.createAccountCallDataBatchTransactions=function(e,t){if(void 0===t&&(t=n.DEFAULT_MULTISEND_CONTRACT_ADDRESS),e.length<1)throw RangeError("There should be at least one metaTransaction");var r=S("0x8d80ff0a",["bytes"],[C(e)]);return n.createAccountCallData(t,0n,r,d.Delegate)},n.createAccountCallData=function(e,t,r,a,i){return void 0===i&&(i=n.DEFAULT_EXECUTOR_FUCNTION_SELECTOR),S(i,n.executorFunctionInputAbi,[e,t,r,a])},n.decodeAccountCallData=function(e){if(e.startsWith(I.executeUserOpWithErrorString)||e.startsWith(I.executeUserOp)){var t=r.defaultAbiCoder(),n="0x"+e.slice(10),a=t.decode(["address","uint256","bytes","uint8"],n);return[a[0],BigInt(a[1]),a[2],Number(a[3])]}throw new b("BAD_DATA","Invalid calldata, should start with "+I.executeUserOpWithErrorString+" or "+I.executeUserOp,{context:{callData:e}})},n.prependTokenPaymasterApproveToCallDataStatic=function(e,t,a,i,o){void 0===o&&(o=n.DEFAULT_MULTISEND_CONTRACT_ADDRESS);var s=n.decodeAccountCallData(e),f=s[0],c=s[1],u=s[2],l=s[3],v="";v="string"!=typeof u?(new TextDecoder).decode(u):u;var h=C([{to:t,value:0n,data:S(F("approve(address,uint256)"),["address","uint256"],[a,i]),operation:d.Call}]),m="",p="0x8d80ff0a";if(v.startsWith(p)){var A=function(e){return r.defaultAbiCoder().decode(["bytes"],"0x"+e.slice(10))[0]}(v);m=A+h.slice(2)}else m=C([{to:f,value:c,data:u,operation:l}])+h.slice(2);var g=S(p,["bytes"],[m]);return n.createAccountCallData(o,0n,g,d.Delegate)},n.formatEip712SignaturesToUseroperationSignature=function(e,t,r,a){if(void 0===r&&(r=0n),void 0===a&&(a=0n),e.length!=t.length)throw RangeError("signersAddresses and signatures arrays should be the same length");var i=new Map;e.forEach(function(e,r){i.set(e.toLocaleLowerCase(),t[r])});var o=new Map(Array.from(i).sort()),s="0x"+Array.from(o.values()).reduce(function(e,t){return e+t.slice(2)},"");return n.formatEip712SingleSignatureToUseroperationSignature(s,r,a)},n.getUserOperationEip712Hash=function(e,t,r,a,i){return void 0===r&&(r=0n),void 0===a&&(a=0n),f.hash({chainId:t,verifyingContract:n.DEFAULT_SAFE_4337_MODULE_ADDRESS},n.EIP712_SAFE_OPERATION_TYPE,{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:r,validUntil:a,entryPoint:i})},n.formatEip712SingleSignatureToUseroperationSignature=function(e,t,r){if(void 0===t&&(t=0n),void 0===r&&(r=0n),t<0n)throw RangeError("validAfter can't be negative");if(r<0n)throw RangeError("validUntil can't be negative");return o(["uint48","uint48","bytes"],[t,r,e])},n.prototype.sendUserOperation=function(e,t){try{var r=this,n=new B(t);return Promise.resolve(n.sendUserOperation(e,r.entrypointAddress)).then(function(e){return new k(e,n,r.entrypointAddress)})}catch(e){return Promise.reject(e)}},n}(v);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=I.executeUserOpWithErrorString,W.executorFunctionInputAbi=["address","uint256","bytes","uint8"],W.EIP712_SAFE_OPERATION_TYPE={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"}]};var H="0x0000000000000000000000000000000000000000",z={sender:H,nonce:0n,initCode:"0x",callData:"0x",callGasLimit:0n,verificationGasLimit:0n,preVerificationGas:0n,maxFeePerGas:0n,maxPriorityFeePerGas:0n,paymasterAndData:"0x",signature:"0x"},Y=/*#__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=S(this.generatorFunctionSelector,this.generatorFunctionInputAbi,e);return this.address+t.slice(2)},e}(),J=/*#__PURE__*/function(e){function t(t){return void 0===t&&(t="0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67"),e.call(this,t,"0x1688f0b9",["address","bytes","uint256"])||this}return p(t,e),t}(Y),K=/*#__PURE__*/function(e){function t(r,n,a){return void 0===n&&(n=t.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===a&&(a=t.DEFAULT_ENTRYPOINT_ADDRESS),e.call(this,r,n,a)||this}p(t,e),t.initializeNewAccount=function(e,r){void 0===r&&(r={});var n=t.createAccountAddressAndInitCode(e,r),a=n[1],i=new t(n[0]);return i.initCode=a,i},t.createAccountAddress=function(e,r){return void 0===r&&(r={}),t.createAccountAddressAndInitCode(e,r)[0]},t.createAccountAddressAndInitCode=function(e,r){var n,a,i,o,s;if(void 0===r&&(r={}),e.length<1)throw RangeError("There should be at least one owner");var f=null!=(n=r.threshold)?n:1,c=null!=(a=r.c2Nonce)?a:0n,u=null!=(i=r.singletonAddress)?i:W.DEFAULT_SINGLETON_ADDRESS,d=null!=(o=r.safe4337ModuleAddress)?o:W.DEFAULT_SAFE_4337_MODULE_ADDRESS,l=null!=(s=r.addModuleLibAddress)?s:W.DEFAULT_ADD_MODULE_LIB_ADDRESS,v=new J;null!=r.safeAccountFactoryAddress&&(v=new J(r.safeAccountFactoryAddress));var h=t.createInitializerCallData(e,f,d,l);return[this.createProxyAddress(h,c,v.address,u),v.getFactoryGeneratorFunctionCallData([u,h,c])]},t.createInitializerCallData=function(e,t,r,n){if(void 0===r&&(r=W.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===n&&(n=W.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=S("0x8d0dc49f",["address[]"],[[r]]);return S(W.initializerFunctionSelector,W.initializerFunctionInputAbi,[e,t,n,a,r,H,0,H])},t.createInitCode=function(e,r,n,a,i,o,s){if(void 0===r&&(r=1),void 0===n&&(n=0n),void 0===a&&(a=W.DEFAULT_SINGLETON_ADDRESS),void 0===i&&(i=new J),void 0===o&&(o=W.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===s&&(s=W.DEFAULT_ADD_MODULE_LIB_ADDRESS),e.length<1)throw RangeError("There should be at least one owner");if(r<1)throw RangeError("threshold should be at least one");if(r>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=t.createInitializerCallData(e,r,o,s);return i.getFactoryGeneratorFunctionCallData([a,f,n])};var r=t.prototype;return r.prependTokenPaymasterApproveToCallData=function(e,r,n,a,i){return void 0===i&&(i=t.DEFAULT_MULTISEND_CONTRACT_ADDRESS),t.prependTokenPaymasterApproveToCallDataStatic(e,r,n,a,i)},r.estimateUserOperationGas=function(e,t,r,n){void 0===n&&(n=1);try{if(n<1n)throw RangeError("numberOfSigners can't be less than 1");for(var a="",i=0;i<n;i++)a+="ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff";e.signature="0xffffffffffffffffffffffff"+a;var o=new B(t),s=e.maxFeePerGas,f=e.maxPriorityFeePerGas;return e.maxFeePerGas=0n,e.maxPriorityFeePerGas=0n,Promise.resolve(o.estimateUserOperationGas(e,this.entrypointAddress,r)).then(function(t){return e.maxFeePerGas=s,e.maxPriorityFeePerGas=f,[BigInt(t.preVerificationGas),BigInt(t.verificationGasLimit)+20000n*BigInt(n),BigInt(t.callGasLimit)]})}catch(e){return Promise.reject(e)}},r.createUserOperation=function(e,r,n,a){void 0===a&&(a={});try{var i=function(i){var f;function c(e){var t,r,i,f;function c(e){var t,r,n,i,o,s;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 h.preVerificationGas=null!=(t=a.preVerificationGas)?t:p*BigInt(Math.floor(((null!=(r=a.preVerificationGasPercentageMultiplier)?r:0)+100)/100)),h.verificationGasLimit=null!=(n=a.verificationGasLimit)?n:A*BigInt(Math.floor(((null!=(i=a.verificationGasLimitPercentageMultiplier)?i:0)+100)/100)),h.callGasLimit=null!=(o=a.callGasLimit)?o:g*BigInt(Math.floor(((null!=(s=a.callGasLimitPercentageMultiplier)?s:0)+100)/100)),h}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");l=null!=(t=a.maxFeePerGas)?t:l*BigInt(Math.floor(((null!=(r=a.maxFeePerGasPercentageMultiplier)?r:0)+100)/100)),v=null!=(i=a.maxPriorityFeePerGas)?i:v*BigInt(Math.floor(((null!=(f=a.maxPriorityFeePerGasPercentageMultiplier)?f:0)+100)/100));var h=m({},z,{sender:o.accountAddress,nonce:s,initCode:u,callData:d,maxFeePerGas:l,maxPriorityFeePerGas:v}),p=z.preVerificationGas,A=z.verificationGasLimit,g=z.callGasLimit,y=function(){if(null==a.preVerificationGas||null==a.verificationGasLimit||null==a.callGasLimit)return function(){if(null!=n){h.callGasLimit=0n,h.verificationGasLimit=0n,h.preVerificationGas=0n;var e=h.maxFeePerGas,t=h.maxPriorityFeePerGas;return h.maxFeePerGas=0n,h.maxPriorityFeePerGas=0n,Promise.resolve(o.estimateUserOperationGas(h,n,a.state_override_set,a.numberOfSigners)).then(function(r){p=r[0],A=r[1],g=r[2],h.maxFeePerGas=e,h.maxPriorityFeePerGas=t})}throw new b("BAD_DATA","bundlerRpc cant't be null if preVerificationGas,verificationGasLimit and callGasLimit are not overriden")}()}();return y&&y.then?y.then(c):c()}var u=null!=(f=a.initCode)?f:o.initCode;if((null==u||s>0n)&&(u="0x"),s<0n)throw RangeError("nonce can't be negative");var d="0x";d=null==a.callData?1==e.length?t.createAccountCallDataSingleTransaction(e[0]):t.createAccountCallDataBatchTransactions(e):a.callData;var l=z.maxFeePerGas,v=z.maxPriorityFeePerGas,h=function(){if(null==a.maxFeePerGas||null==a.maxPriorityFeePerGas)return function(){if(null!=r)return Promise.resolve(_(r)).then(function(e){l=e[0],v=e[1]});throw new b("BAD_DATA","providerRpc cant't be null if maxFeePerGas and maxPriorityFeePerGas are not overriden")}()}();return h&&h.then?h.then(c):c()},o=this;if(e.length<1)throw RangeError("There should be at least one transaction");var s=0n,f=function(){if(null==a.nonce)return function(){if(null!=r)return Promise.resolve(T(r,o.entrypointAddress,o.accountAddress)).then(function(e){s=e});throw new b("BAD_DATA","providerRpc cant't be null if nonce is not overriden")}();s=a.nonce}();return Promise.resolve(f&&f.then?f.then(i):i())}catch(e){return Promise.reject(e)}},r.signUserOperation=function(e,r,n,a,i){if(void 0===a&&(a=0n),void 0===i&&(i=0n),r.length<1)throw RangeError("There should be at least one privateKey");if(n<0n)throw RangeError("chainId can't be negative");if(a<0n)throw RangeError("validAfter can't be negative");if(i<0n)throw RangeError("validUntil can't be negative");for(var o,s=W.getUserOperationEip712Hash(e,n,a,i,this.entrypointAddress),f=[],u=[],d=D(r);!(o=d()).done;){var l=new c(o.value),v=l.signingKey.sign(s).serialized;f.push(l.address),u.push(v)}return t.formatEip712SignaturesToUseroperationSignature(f,u,a,i)},t}(W),q=/*#__PURE__*/function(e){function n(t,r,a){var i;return void 0===r&&(r=n.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===a&&(a=n.DEFAULT_ENTRYPOINT_ADDRESS),(i=e.call(this,t,r,a)||this).isInitWebAuthn=void 0,i.x=0n,i.y=0n,i.isInitWebAuthn=!1,i}p(n,e),n.initializeNewAccount=function(e,t){void 0===t&&(t={});for(var r,a=!1,i=0n,o=0n,s=D(e);!(r=s()).done;){var f=r.value;"string"!=typeof f&&(a=!0,i=f.x,o=f.y)}var c=n.createAccountAddressAndInitCode(e,t),u=c[1],d=new n(c[0]);return d.initCode=u,d.isInitWebAuthn=a,d.x=i,d.y=o,d},n.createAccountAddress=function(e,t){return void 0===t&&(t={}),n.createAccountAddressAndInitCode(e,t)[0]},n.createAccountAddressAndInitCode=function(e,t){var r,a,i,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!=(a=t.c2Nonce)?a:0n,u=null!=(i=t.singletonAddress)?i:W.DEFAULT_SINGLETON_ADDRESS,d=null!=(o=t.safe4337ModuleAddress)?o:W.DEFAULT_SAFE_4337_MODULE_ADDRESS,l=null!=(s=t.addModuleLibAddress)?s:W.DEFAULT_ADD_MODULE_LIB_ADDRESS,v=new J;null!=t.safeAccountFactoryAddress&&(v=new J(t.safeAccountFactoryAddress));var h=n.createInitializerCallData(e,f,d,l);return[this.createProxyAddress(h,c,v.address,u),v.getFactoryGeneratorFunctionCallData([u,h,c])]},n.createInitializerCallData=function(e,t,r,a){if(void 0===r&&(r=W.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===a&&(a=W.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 i=S("0x8d0dc49f",["address[]"],[[r]]),o=[];o.push({to:a,value:0n,data:i,operation:d.Delegate});for(var s,f=[],c=0,u=D(e);!(s=u()).done;){var l=s.value;if("string"!=typeof l){if(c>0)throw RangeError("Only one WebAuthn owner can be set during initialization");var v=S("0xf9c6055b",["uint256","uint256"],[l.x,l.y]);o.push({to:n.DEFAULT_WEB_AUTHN_SIGNATURE_VALIDATOR_SINGLETON,value:0n,data:v,operation:d.Delegate}),f.push(n.DEFAULT_WEB_AUTHN_SIGNATURE_VALIDATOR_SINGLETON),c++}else f.push(l)}var h=S("0x8d80ff0a",["bytes"],[C(o)]);return S(W.initializerFunctionSelector,W.initializerFunctionInputAbi,[f,t,n.DEFAULT_MULTISEND_CONTRACT_ADDRESS,h,r,H,0,H])},n.createInitCode=function(e,t,r,a,i,o,s){if(void 0===t&&(t=1),void 0===r&&(r=0n),void 0===a&&(a=W.DEFAULT_SINGLETON_ADDRESS),void 0===i&&(i=new J),void 0===o&&(o=W.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===s&&(s=W.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 i.getFactoryGeneratorFunctionCallData([a,f,r])};var a=n.prototype;return a.prependTokenPaymasterApproveToCallData=function(e,t,r,a,i){return void 0===i&&(i=n.DEFAULT_MULTISEND_CONTRACT_ADDRESS),n.prependTokenPaymasterApproveToCallDataStatic(e,t,r,a,i)},a.estimateUserOperationGas=function(e,t,r,n,a){void 0===n&&(n=1),void 0===a&&(a=null);try{if(n<1n)throw RangeError("numberOfSigners can't be less than 1");if(null!=a&&n!=a.length)throw RangeError("dummySignatures list should has the length of numberOfSigners");for(var i="",o=0;o<n;o++)i+=a;e.signature="0xffffffffffffffffffffffffffffffffffffffffffffffff"+i;var s=new B(t);return Promise.resolve(s.estimateUserOperationGas(e,this.entrypointAddress,r)).then(function(e){return[BigInt(e.preVerificationGas),BigInt(e.verificationGasLimit)+20000n*BigInt(n),BigInt(e.callGasLimit)]})}catch(e){return Promise.reject(e)}},a.createUserOperation=function(e,t,r,a){void 0===a&&(a={});try{var i=function(i){var f;function c(e){var t,n,i,f;function c(e){var t,r,n,i,o,s;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 d.preVerificationGas=null!=(t=a.preVerificationGas)?t:l*BigInt((null!=(r=a.preVerificationGasPercentageMultiplier)?r:0)+100)/100n,d.verificationGasLimit=null!=(n=a.verificationGasLimit)?n:v*BigInt((null!=(i=a.verificationGasLimitPercentageMultiplier)?i:0)+100)/100n,d.callGasLimit=null!=(o=a.callGasLimit)?o:h*BigInt((null!=(s=a.callGasLimitPercentageMultiplier)?s:0)+100)/100n,d}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");y=null!=(t=a.maxFeePerGas)?t:y*BigInt((null!=(n=a.maxFeePerGasPercentageMultiplier)?n:0)+100)/100n,E=null!=(i=a.maxPriorityFeePerGas)?i:E*BigInt((null!=(f=a.maxPriorityFeePerGasPercentageMultiplier)?f:0)+100)/100n;var d=m({},z,{sender:o.accountAddress,nonce:s,initCode:u,callData:g,maxFeePerGas:y,maxPriorityFeePerGas:E}),l=z.preVerificationGas,v=z.verificationGasLimit,h=z.callGasLimit,p=function(){if(null==a.preVerificationGas||null==a.verificationGasLimit||null==a.callGasLimit)return function(){if(null!=r)return Promise.resolve(o.estimateUserOperationGas(d,r,a.state_override_set,a.numberOfSigners,a.dummySignatures)).then(function(e){l=e[0],v=e[1],h=e[2]});throw new b("BAD_DATA","bundlerRpc cant't be null if preVerificationGas,verificationGasLimit and callGasLimit are not overriden")}()}();return p&&p.then?p.then(c):c()}var u=null!=(f=a.initCode)?f:o.initCode;if(null==u||s>0n)u="0x";else if(o.isInitWebAuthn){var l=S("0x080fbebf",["uint256","uint256","address"],[o.x,o.y,n.DEFAULT_WEB_AUTHN_VERIFIER]),v=S("0x1688f0b9",["address","bytes","uint256"],[n.DEFAULT_SIGNATURE_VALIDATOR,l,0]),h={to:n.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,value:0n,data:v},p=n.createWebAuthnSignerVerifierAddress(o.x,o.y),A=S("0xe318b52b",["address","address","address"],["0x0000000000000000000000000000000000000001",n.DEFAULT_WEB_AUTHN_SIGNATURE_VALIDATOR_SINGLETON,p]);e=[h,{to:o.accountAddress,value:0n,data:A},{to:n.DEFAULT_WEB_AUTHN_SIGNATURE_VALIDATOR_SINGLETON,value:0n,data:"0x578c7a83",operation:d.Delegate}].concat(e)}if(s<0n)throw RangeError("nonce can't be negative");var g="0x";g=null==a.callData?1==e.length?n.createAccountCallDataSingleTransaction(e[0]):n.createAccountCallDataBatchTransactions(e):a.callData;var y=z.maxFeePerGas,E=z.maxPriorityFeePerGas,D=function(){if(null==a.maxFeePerGas||null==a.maxPriorityFeePerGas)return function(){if(null!=t)return Promise.resolve(_(t)).then(function(e){y=e[0],E=e[1]});throw new b("BAD_DATA","providerRpc cant't be null if maxFeePerGas and maxPriorityFeePerGas are not overriden")}()}();return D&&D.then?D.then(c):c()},o=this;if(e.length<1)throw RangeError("There should be at least one transaction");var s=0n,f=function(){if(null==a.nonce)return function(){if(null!=t)return Promise.resolve(T(t,o.entrypointAddress,o.accountAddress)).then(function(e){s=e});throw new b("BAD_DATA","providerRpc cant't be null if nonce is not overriden")}();s=a.nonce}();return Promise.resolve(f&&f.then?f.then(i):i())}catch(e){return Promise.reject(e)}},a.signUserOperation=function(e,t,r,a,i){if(void 0===a&&(a=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(a<0n)throw RangeError("validAfter can't be negative");if(i<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:a,validUntil:i,entryPoint:this.entrypointAddress},u={chainId:r,verifyingContract:this.safe4337ModuleAddress},d=[],l=[],v=D(t);!(o=v()).done;){var h=new c(o.value),m=h.signingKey.sign(f.hash(u,n.EIP712_SAFE_OPERATION_TYPE,s)).serialized;d.push(h.address),l.push(m)}return n.formatEip712SignaturesToUseroperationSignature(d,l,a,i)},n.createWebAuthnSignerVerifierAddress=function(e,a){var i=S("0x080fbebf",["uint256","uint256","address"],[e,a,n.DEFAULT_WEB_AUTHN_VERIFIER]),f=r.defaultAbiCoder(),c=t(o(["bytes32","uint256"],[t(i),0])),u=f.encode(["uint256"],[n.DEFAULT_SIGNATURE_VALIDATOR]),d=t(o(["bytes","bytes"],[n.DEFAULT_WEB_AUTHN_SIGNER_CREATION_CODE,u]));return"0x"+s(["bytes1","address","bytes32","bytes32"],["0xff",n.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,c,d]).slice(-40)},n.formatSignaturesToUseroperationSignature=function(e,t,r,a){void 0===t&&(t=null),void 0===r&&(r=0n),void 0===a&&(a=0n);var i=n.buildSignatures(e,t);return o(["uint48","uint48","bytes"],[r,a,i])},n.getLowerCaseAddress=function(e){return"string"==typeof e?e.toLowerCase():n.createWebAuthnSignerVerifierAddress(e.x,e.y)},n.sortSignatures=function(e){e.sort(function(e,t){return n.getLowerCaseAddress(e.signer).localeCompare(n.getLowerCaseAddress(t.signer))})},n.buildSignatures=function(e,t){void 0===t&&(t=null),n.sortSignatures(e);var r=65*e.length,a=e.reduce(function(e,a){var i=e.segments,o=e.offset,s=a.signer,f=a.signature,c=a.isContractSignature;if(c=c||"string"!=typeof s){if("string"==typeof s)return{segments:[].concat(i,[u.solidityPacked(["uint256","uint256","uint8"],[s,r+o,0])]),offset:o+32+u.dataLength(f)};if(null==t)throw RangeError("Must define isInit parameter when using WebAuthn");return s=t?n.DEFAULT_WEB_AUTHN_SIGNATURE_VALIDATOR_SINGLETON:n.createWebAuthnSignerVerifierAddress(s.x,s.y),{segments:[].concat(i,[u.solidityPacked(["uint256","uint256","uint8"],[s,r+o,0])]),offset:o+32+u.dataLength(f)}}return{segments:[].concat(i,[u.solidityPacked(["bytes"],[f])]),offset:0}},{segments:[],offset:0});return u.concat([].concat(a.segments,e.map(function(e){var t=e.signature;return u.solidityPacked(["uint256","bytes"],[u.dataLength(t),t])})))},n.createWebAuthnSignature=function(e){return u.AbiCoder.defaultAbiCoder().encode(["bytes","bytes","uint256[2]"],[new Uint8Array(e.authenticatorData),e.clientDataFields,e.rs])},n}(W);function X(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}q.DEFAULT_WEB_AUTHN_SIGNATURE_VALIDATOR_SINGLETON="0xcA66C5A0eEAb0Fe74F343bb4A539042c68aE45F9",q.DEFAULT_WEB_AUTHN_SIGNER_FACTORY="0xEae2AD611c0e8E14604B8cc611a89d5e9d138B49",q.DEFAULT_WEB_AUTHN_VERIFIER="0xCAc51aDF726E4b269645a7fD6a43296A1Ff53e8d",q.DEFAULT_SIGNATURE_VALIDATOR="0x21E4747C7215fe6E343376034F08261bBD9ac497",q.DEFAULT_WEB_AUTHN_SIGNER_CREATION_CODE="0x608060405234801561001057600080fd5b5060405161017238038061017283398101604081905261002f916100b9565b6001600160a01b0381166100945760405162461bcd60e51b815260206004820152602260248201527f496e76616c69642073696e676c65746f6e20616464726573732070726f766964604482015261195960f21b606482015260840160405180910390fd5b600080546001600160a01b0319166001600160a01b03929092169190911790556100e9565b6000602082840312156100cb57600080fd5b81516001600160a01b03811681146100e257600080fd5b9392505050565b607b806100f76000396000f3fe608060405260008054632cf35bc960e11b8235016027576001600160f41b0381168252602082f35b3682833781823684845af490503d82833e806040573d82fd5b503d81f3fea264697066735822122062f4785a59897477a798d8218290ac5cf89f803649d66b453fa58689dd461e3164736f6c63430008140033";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}p(t,e);var r=t.prototype;return r.initialize=function(){try{var e=this;return Promise.resolve(X(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=G(e);throw new b("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?X(function(){return Promise.resolve(R(e.rpcUrl,"pm_supportedERC20Tokens",[])).then(function(e){return{tokens:e.tokens.map(function(e){return{symbol:e.symbol,address:e.address,decimal:Number(e.decimal),fee:BigInt(e.fee),exchangeRate:BigInt(e.exchangeRate)}}),paymasterMetadata:e.paymasterMetadata}})},function(e){var t=G(e);throw new b("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?X(function(){return Promise.resolve(R(e.rpcUrl,"pm_supportedEntryPoint",[]))},function(e){var t=G(e);throw new b("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.toLowerCase()===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={}),void 0===n&&(n={});try{var a=function(){return X(function(){function a(t){var a,c,u,d,l,v;if("bigint"==typeof n.preVerificationGas&&n.preVerificationGas<0n)throw RangeError("preVerificationGas overrid can't be negative");if("bigint"==typeof n.verificationGasLimit&&n.verificationGasLimit<0n)throw RangeError("verificationGasLimit overrid can't be negative");if("bigint"==typeof n.callGasLimit&&n.callGasLimit<0n)throw RangeError("callGasLimit overrid can't be negative");return e.preVerificationGas=null!=(a=n.preVerificationGas)?a:o*BigInt((null!=(c=n.preVerificationGasPercentageMultiplier)?c:0)+100)/100n,e.verificationGasLimit=null!=(u=n.verificationGasLimit)?u:s*BigInt((null!=(d=n.verificationGasLimitPercentageMultiplier)?d:0)+100)/100n,e.callGasLimit=null!=(l=n.callGasLimit)?l:f*BigInt((null!=(v=n.callGasLimitPercentageMultiplier)?v:0)+100)/100n,e.preVerificationGas=e.preVerificationGas+100n,e.verificationGasLimit=e.verificationGasLimit+10000n,Promise.resolve(R(i.rpcUrl,"pm_sponsorUserOperation",[e,i.entrypointAddress,r])).then(function(t){var r,n,a,i,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!=(a=f.verificationGasLimit)?a:e.verificationGasLimit,e.maxFeePerGas=null!=(i=f.maxFeePerGas)?i:e.maxFeePerGas,e.maxPriorityFeePerGas=null!=(o=f.maxPriorityFeePerGas)?o:e.maxPriorityFeePerGas,e})}e.paymasterAndData=i.paymasterMetadata.dummyPaymasterAndData;var o=e.preVerificationGas,s=e.verificationGasLimit,f=e.callGasLimit,c=function(){if(null==n.preVerificationGas||null==n.verificationGasLimit||null==n.callGasLimit)return function(){if(null!=t){var r=new B(t);e.callGasLimit=0n,e.verificationGasLimit=0n,e.preVerificationGas=0n;var a=e.maxFeePerGas,c=e.maxPriorityFeePerGas;return e.maxFeePerGas=0n,e.maxPriorityFeePerGas=0n,Promise.resolve(r.estimateUserOperationGas(e,i.entrypointAddress,n.state_override_set)).then(function(t){o<t.preVerificationGas&&(o=t.preVerificationGas),s<t.verificationGasLimit&&(s=t.verificationGasLimit),f<t.callGasLimit&&(f=t.callGasLimit),e.maxFeePerGas=a,e.maxPriorityFeePerGas=c})}throw new b("BAD_DATA","bundlerRpc cant't be null if preVerificationGas,verificationGasLimit and callGasLimit are not overriden")}()}();return c&&c.then?c.then(a):a()},function(e){var t=G(e);throw new b("PAYMASTER_ERROR","pm_sponsorUserOperation failed",{cause:t})})},i=this,o=function(){if(null==i.entrypointAddress||null==i.supportedTokens||null==i.paymasterMetadata)return Promise.resolve(i.initialize()).then(function(){})}();return Promise.resolve(o&&o.then?o.then(a):a())}catch(e){return Promise.reject(e)}},r.createSponsorPaymasterUserOperation=function(e,t,r){void 0===r&&(r={});try{return Promise.resolve(this.createPaymasterUserOperation(e,t,{},r))}catch(e){return Promise.reject(e)}},r.createTokenPaymasterUserOperation=function(e,t,r,n,a){void 0===a&&(a={});try{var i=this;return Promise.resolve(X(function(){return Promise.resolve(i.calculateUserOperationErc20TokenMaxGasCost(t,r)).then(function(o){var s=2n*o;return Promise.resolve(i.getPaymasterMetaData()).then(function(o){var f=e.prependTokenPaymasterApproveToCallData(t.callData,r,o.address,s);return t.callData=f,Promise.resolve(i.createPaymasterUserOperation(t,n,{token:r},a))})})},function(e){var t=G(e);throw new b("PAYMASTER_ERROR","createTokenPaymasterUserOperation failed",{cause:t})}))}catch(e){return Promise.reject(e)}},r.calculateUserOperationErc20TokenMaxGasCost=function(e,t){try{var r=this;return Promise.resolve(X(function(){return Promise.resolve(r.getSupportedERC20TokenData(t)).then(function(n){if(null==n)return Promise.resolve(r.getSupportedERC20TokensAndPaymasterMetadata()).then(function(e){throw new b("PAYMASTER_ERROR",t+" token is not supported by the paymaster.",{context:{supportedERC20TokensAndPaymasterMetadata:JSON.stringify(e,function(e,t){return"bigint"==typeof t?"0x"+t.toString(16):t})}})});var a=U(e);return n.exchangeRate*a/BigInt(Math.pow(10,18))})},function(e){var t=G(e);throw new b("PAYMASTER_ERROR","calculateUserOperationErc20TokenMaxGasCost failed",{cause:t})}))}catch(e){return Promise.reject(e)}},t}(function(){}),$={__proto__:null,SmartAccount:v,SocialRecoveryModule:w,SafeAccountV0_2_0:K,SafeAccountWebAuth:q,SendUseroperationResponse:k,SmartAccountFactory:Y,SafeAccountFactory:J,Bundler:B,CandidePaymaster:Z,createUserOperationHash:L,createCallData:S,getFunctionSelector:F,fetchAccountNonce:T,calculateUserOperationMaxGasCost:U,get SafeModuleExecutorFunctionSelector(){return I},get DummySignature(){return x},get Operation(){return d},ZeroAddress:H,UserOperationDummyValues:z};export{B as Bundler,Z as CandidePaymaster,x as DummySignature,d as Operation,J as SafeAccountFactory,K as SafeAccountV0_2_0,q as SafeAccountWebAuth,I as SafeModuleExecutorFunctionSelector,k as SendUseroperationResponse,v as SmartAccount,Y as SmartAccountFactory,w as SocialRecoveryModule,z as UserOperationDummyValues,H as ZeroAddress,$ as abstractionkit,U as calculateUserOperationMaxGasCost,S as createCallData,L as createUserOperationHash,T as fetchAccountNonce,F as getFunctionSelector}; |
@@ -1,1 +0,1 @@ | ||
!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 c(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(c=function(){return!!e})()}function f(){return f=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},f.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(c())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 v(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 h={"-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:G(E("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 h?h[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 G(e,r,n){return e+t.AbiCoder.defaultAbiCoder().encode(r,n).slice(2)}function E(e){return t.id(e).slice(0,10)}function b(e){return(e.callGasLimit+e.verificationGasLimit*("0x"==e.paymasterAndData||null==e.paymasterAndData?3n:0n)+e.preVerificationGas)*e.maxFeePerGas}var D,S="0x0000000000000000000000000000000000000000",R={sender:S,nonce:0n,initCode:"0x",callData:"0x",callGasLimit:0n,verificationGasLimit:0n,preVerificationGas:0n,maxFeePerGas:0n,maxPriorityFeePerGas:0n,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=G(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 u(t,e),t}(O);function F(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 _(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}e.SafeModuleExecutorFunctionSelector=void 0,(D=e.SafeModuleExecutorFunctionSelector||(e.SafeModuleExecutorFunctionSelector={})).executeUserOpWithErrorString="0x541d63c8",D.executeUserOp="0x7bb37428";var L=/*#__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(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(_(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(_(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(_(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(_(function(){return Promise.resolve(P(t.rpcUrl,"eth_getUserOperationReceipt",[e])).then(function(e){var t=e;if(null!=t){var r=f({},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 f({},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(_(function(){return Promise.resolve(P(t.rpcUrl,"eth_getUserOperationByHash",[e])).then(function(e){return null!=e?f({},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 T(e,t,r){if(!e.s){if(r instanceof U){if(!r.s)return void(r.o=T.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(T.bind(null,e,t),T.bind(null,e,2));e.s=t,e.v=r;const n=e.o;n&&n(e)}}var U=/*#__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{T(n,1,a(this.v))}catch(e){T(n,2,e)}return n}return this}return this.o=function(e){try{var i=e.v;1&e.s?T(n,1,t?t(i):i):r?T(n,1,r(i)):T(n,2,i)}catch(e){T(n,2,e)}},n},e}();function w(e){return e instanceof U&&1&e.s}var I=/*#__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 U,c=T.bind(null,s,2);return(0===n?i.then(u):1===n?a.then(f):o.then(l)).then(void 0,c),s;function f(n){a=n;do{if(t&&(o=t())&&o.then&&!w(o))return void o.then(l).then(void 0,c);if(!(i=e())||w(i)&&!i.v)return void T(s,1,a);if(i.then)return void i.then(u).then(void 0,c);w(a=r())&&(a=a.v)}while(!a||!a.then);a.then(f).then(void 0,c)}function u(e){e?(a=r())&&a.then?a.then(f).then(void 0,c):f(a):T(s,1,a)}function l(){(i=e())?i.then?i.then(u).then(void 0,c):u(i):T(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}(),C=/*#__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.createAccountAddress=function(e,t){return void 0===t&&(t={}),n.createAccountAddressAndInitCode(e,t)[0]},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 c=null!=(r=t.threshold)?r:1,f=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 x;null!=t.safeAccountFactoryAddress&&(p=new x(t.safeAccountFactoryAddress));var v=n.createInitializerCallData(e,c,l,d);return[this.createProxyAddress(v,f,p.address,u),p.getFactoryGeneratorFunctionCallData([u,v,f])]},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=G("0x8d0dc49f",["address[]"],[[r]]);return G(n.initializerFunctionSelector,n.initializerFunctionInputAbi,[e,t,i,a,r,S,0,S])},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 x),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 c=n.createInitializerCallData(e,t,o,s);return a.getFactoryGeneratorFunctionCallData([i,c,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]),c=t.keccak256(t.solidityPacked(["bytes","bytes"],[this.proxyByteCode,s]));return"0x"+t.solidityPackedKeccak256(["bytes1","address","bytes32","bytes32"],["0xff",n,o,c]).slice(-40)},n.createAccountCallDataSingleTransaction=function(t){var r,i,a,o=null!=(r=t.value)?r:0,s=null!=(i=t.data)?i:"0x",c=null!=(a=t.operation)?a:e.Operation.Call;return n.createAccountCallData(t.to,o,s,c)},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=G("0x8d80ff0a",["bytes"],[F(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),G(a,n.executorFunctionInputAbi,[e,t,r,i])},n.decodeAccountCallData=function(r){if(r.startsWith(e.SafeModuleExecutorFunctionSelector.executeUserOpWithErrorString)||r.startsWith(e.SafeModuleExecutorFunctionSelector.executeUserOp)){var n=t.AbiCoder.defaultAbiCoder(),i="0x"+r.slice(10),a=n.decode(["address","uint256","bytes","uint8"],i);return[a[0],BigInt(a[1]),a[2],Number(a[3])]}throw new m("BAD_DATA","Invalid calldata, should start with "+e.SafeModuleExecutorFunctionSelector.executeUserOpWithErrorString+" or "+e.SafeModuleExecutorFunctionSelector.executeUserOp,{context:{callData:r}})};var i=n.prototype;return i.prependTokenPaymasterApproveToCallData=function(e,t,r,i,a){return void 0===a&&(a=n.DEFAULT_MULTISEND_CONTRACT_ADDRESS),n.prependTokenPaymasterApproveToCallDataStatic(e,t,r,i,a)},n.prependTokenPaymasterApproveToCallDataStatic=function(r,i,a,o,s){void 0===s&&(s=n.DEFAULT_MULTISEND_CONTRACT_ADDRESS);var c=n.decodeAccountCallData(r),f=c[0],u=c[1],l=c[2],d=c[3],p="";p="string"!=typeof l?(new TextDecoder).decode(l):l;var v=F([{to:i,value:0n,data:G(E("approve(address,uint256)"),["address","uint256"],[a,o]),operation:e.Operation.Call}]),h="",m="0x8d80ff0a";if(p.startsWith(m)){var y=function(e){return t.AbiCoder.defaultAbiCoder().decode(["bytes"],"0x"+e.slice(10))[0]}(p);h=y+v.slice(2)}else h=F([{to:f,value:u,data:l,operation:d}])+v.slice(2);var A=G(m,["bytes"],[h]);return n.createAccountCallData(s,0n,A,e.Operation.Delegate)},i.estimateUserOperationGas=function(e,t,r,n){void 0===n&&(n=1);try{if(n<1n)throw RangeError("numberOfSigners can't be less than 1");for(var i="",a=0;a<n;a++)i+="ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff";e.signature="0xffffffffffffffffffffffff"+i;var o=new L(t),s=e.maxFeePerGas,c=e.maxPriorityFeePerGas;return e.maxFeePerGas=0n,e.maxPriorityFeePerGas=0n,Promise.resolve(o.estimateUserOperationGas(e,this.entrypointAddress,r)).then(function(t){return e.maxFeePerGas=s,e.maxPriorityFeePerGas=c,[BigInt(t.preVerificationGas),BigInt(t.verificationGasLimit)+30000n*BigInt(n),BigInt(t.callGasLimit)]})}catch(e){return Promise.reject(e)}},i.createUserOperation=function(e,r,i,o){void 0===o&&(o={});try{var s=function(s){var l;function d(e){var t,r,n,a;function s(e){var t,r,n,i,a,s;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 l.preVerificationGas=null!=(t=o.preVerificationGas)?t:d*BigInt(Math.floor(((null!=(r=o.preVerificationGasPercentageMultiplier)?r:0)+100)/100)),l.verificationGasLimit=null!=(n=o.verificationGasLimit)?n:A*BigInt(Math.floor(((null!=(i=o.verificationGasLimitPercentageMultiplier)?i:0)+100)/100)),l.callGasLimit=null!=(a=o.callGasLimit)?a:P*BigInt(Math.floor(((null!=(s=o.callGasLimitPercentageMultiplier)?s:0)+100)/100)),l}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!=(t=o.maxFeePerGas)?t:h*BigInt(Math.floor(((null!=(r=o.maxFeePerGasPercentageMultiplier)?r:0)+100)/100)),y=null!=(n=o.maxPriorityFeePerGas)?n:y*BigInt(Math.floor(((null!=(a=o.maxPriorityFeePerGasPercentageMultiplier)?a:0)+100)/100));var l=f({},R,{sender:c.accountAddress,nonce:u,initCode:p,callData:v,maxFeePerGas:h,maxPriorityFeePerGas:y}),d=R.preVerificationGas,A=R.verificationGasLimit,P=R.callGasLimit,g=function(){if(null==o.preVerificationGas||null==o.verificationGasLimit||null==o.callGasLimit)return function(){if(null!=i){l.callGasLimit=0n,l.verificationGasLimit=0n,l.preVerificationGas=0n;var e=l.maxFeePerGas,t=l.maxPriorityFeePerGas;return l.maxFeePerGas=0n,l.maxPriorityFeePerGas=0n,Promise.resolve(c.estimateUserOperationGas(l,i,o.state_override_set,o.numberOfSigners)).then(function(r){d=r[0],A=r[1],P=r[2],l.maxFeePerGas=e,l.maxPriorityFeePerGas=t})}throw new m("BAD_DATA","bundlerRpc cant't be null if preVerificationGas,verificationGasLimit and callGasLimit are not overriden")}()}();return g&&g.then?g.then(s):s()}var p=null!=(l=o.initCode)?l:c.initCode;if((null==p||u>0n)&&(p="0x"),u<0n)throw RangeError("nonce can't be negative");var v="0x";v=null==o.callData?1==e.length?n.createAccountCallDataSingleTransaction(e[0]):n.createAccountCallDataBatchTransactions(e):o.callData;var h=R.maxFeePerGas,y=R.maxPriorityFeePerGas,A=function(){if(null==o.maxFeePerGas||null==o.maxPriorityFeePerGas)return function(){if(null!=r)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){0n==(h=e[0])&&(h=1n),0n==(y=e[1])&&(y=1n)});throw new m("BAD_DATA","providerRpc cant't be null if maxFeePerGas and maxPriorityFeePerGas are not overriden")}()}();return A&&A.then?A.then(d):d()},c=this;if(e.length<1)throw RangeError("There should be at least one transaction");var u=0n,l=function(){if(null==o.nonce)return function(){if(null!=r)return Promise.resolve(A(r,c.entrypointAddress,c.accountAddress)).then(function(e){u=e});throw new m("BAD_DATA","providerRpc cant't be null if nonce is not overriden")}();u=o.nonce}();return Promise.resolve(l&&l.then?l.then(s):s())}catch(e){return Promise.reject(e)}},i.signUserOperation=function(e,r,i,a,o){if(void 0===a&&(a=0n),void 0===o&&(o=0n),r.length<1)throw RangeError("There should be at least one privateKey");if(i<0n)throw RangeError("chainId can't be negative");if(a<0n)throw RangeError("validAfter can't be negative");if(o<0n)throw RangeError("validUntil can't be negative");for(var s,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:a,validUntil:o,entryPoint:this.entrypointAddress},f={chainId:i,verifyingContract:this.safe4337ModuleAddress},u=[],l=[],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 v(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)?v(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);!(s=d()).done;){var p=new t.Wallet(s.value),h=p.signingKey.sign(t.TypedDataEncoder.hash(f,n.EIP712_SAFE_OPERATION_TYPE,c)).serialized;u.push(p.address),l.push(h)}return n.formatEip712SignaturesToUseroperationSignature(u,l,a,o)},n.formatEip712SignaturesToUseroperationSignature=function(e,t,r,i){if(void 0===r&&(r=0n),void 0===i&&(i=0n),e.length!=t.length)throw RangeError("signersAddresses and signatures arrays should be the same length");var a=new Map;e.forEach(function(e,r){a.set(e.toLocaleLowerCase(),t[r])});var o=new Map(Array.from(a).sort()),s="0x"+Array.from(o.values()).reduce(function(e,t){return e+t.slice(2)},"");return n.formatEip712SingleSignatureToUseroperationSignature(s,r,i)},n.formatEip712SingleSignatureToUseroperationSignature=function(e,r,n){if(void 0===r&&(r=0n),void 0===n&&(n=0n),r<0n)throw RangeError("validAfter can't be negative");if(n<0n)throw RangeError("validUntil can't be negative");return t.solidityPacked(["uint48","uint48","bytes"],[r,n,e])},i.sendUserOperation=function(e,t){try{var r=this,n=new L(t);return Promise.resolve(n.sendUserOperation(e,r.entrypointAddress)).then(function(e){return new I(e,n,r.entrypointAddress)})}catch(e){return Promise.reject(e)}},n}(s);function M(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}C.DEFAULT_ENTRYPOINT_ADDRESS="0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",C.DEFAULT_SAFE_4337_MODULE_ADDRESS="0xa581c4A4DB7175302464fF3C06380BC3270b4037",C.DEFAULT_SINGLETON_ADDRESS="0x29fcB43b46531BcA003ddC8FCB67FFE91900C762",C.DEFAULT_ADD_MODULE_LIB_ADDRESS="0x8EcD4ec46D4D2a6B64fE960B3D64e8B94B2234eb",C.DEFAULT_MULTISEND_CONTRACT_ADDRESS="0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526",C.proxyByteCode="0x608060405234801561001057600080fd5b506040516101e63803806101e68339818101604052602081101561003357600080fd5b8101908080519060200190929190505050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156100ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806101c46022913960400191505060405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505060ab806101196000396000f3fe608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea264697066735822122003d1488ee65e08fa41e58e888a9865554c535f2c77126a82cb4c0f917f31441364736f6c63430007060033496e76616c69642073696e676c65746f6e20616464726573732070726f7669646564",C.initializerFunctionSelector="0xb63e800d",C.initializerFunctionInputAbi=["address[]","uint256","address","bytes","address","address","uint256","address"],C.DEFAULT_EXECUTOR_FUCNTION_SELECTOR=e.SafeModuleExecutorFunctionSelector.executeUserOpWithErrorString,C.executorFunctionInputAbi=["address","uint256","bytes","uint8"],C.EIP712_SAFE_OPERATION_TYPE={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"}]};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(M(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?M(function(){return Promise.resolve(P(e.rpcUrl,"pm_supportedERC20Tokens",[])).then(function(e){return{tokens:e.tokens.map(function(e){return{symbol:e.symbol,address:e.address,decimal:Number(e.decimal),fee:BigInt(e.fee),exchangeRate:BigInt(e.exchangeRate)}}),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?M(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.toLowerCase()===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={}),void 0===n&&(n={});try{var i=function(){return M(function(){function i(t){var i,f,u,l,d,p;if("bigint"==typeof n.preVerificationGas&&n.preVerificationGas<0n)throw RangeError("preVerificationGas overrid can't be negative");if("bigint"==typeof n.verificationGasLimit&&n.verificationGasLimit<0n)throw RangeError("verificationGasLimit overrid can't be negative");if("bigint"==typeof n.callGasLimit&&n.callGasLimit<0n)throw RangeError("callGasLimit overrid can't be negative");return e.preVerificationGas=null!=(i=n.preVerificationGas)?i:o*BigInt((null!=(f=n.preVerificationGasPercentageMultiplier)?f:0)+100)/100n,e.verificationGasLimit=null!=(u=n.verificationGasLimit)?u:s*BigInt((null!=(l=n.verificationGasLimitPercentageMultiplier)?l:0)+100)/100n,e.callGasLimit=null!=(d=n.callGasLimit)?d:c*BigInt((null!=(p=n.callGasLimitPercentageMultiplier)?p:0)+100)/100n,e.preVerificationGas=e.preVerificationGas+100n,e.verificationGasLimit=e.verificationGasLimit+10000n,Promise.resolve(P(a.rpcUrl,"pm_sponsorUserOperation",[e,a.entrypointAddress,r])).then(function(t){var r,n,i,a,o,s=t,c={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=c.paymasterAndData,e.callGasLimit=null!=(r=c.callGasLimit)?r:e.callGasLimit,e.preVerificationGas=null!=(n=c.preVerificationGas)?n:e.preVerificationGas,e.verificationGasLimit=null!=(i=c.verificationGasLimit)?i:e.verificationGasLimit,e.maxFeePerGas=null!=(a=c.maxFeePerGas)?a:e.maxFeePerGas,e.maxPriorityFeePerGas=null!=(o=c.maxPriorityFeePerGas)?o:e.maxPriorityFeePerGas,e})}e.paymasterAndData=a.paymasterMetadata.dummyPaymasterAndData;var o=e.preVerificationGas,s=e.verificationGasLimit,c=e.callGasLimit,f=function(){if(null==n.preVerificationGas||null==n.verificationGasLimit||null==n.callGasLimit)return function(){if(null!=t){var r=new L(t);e.callGasLimit=0n,e.verificationGasLimit=0n,e.preVerificationGas=0n;var i=e.maxFeePerGas,f=e.maxPriorityFeePerGas;return e.maxFeePerGas=0n,e.maxPriorityFeePerGas=0n,Promise.resolve(r.estimateUserOperationGas(e,a.entrypointAddress,n.state_override_set)).then(function(t){o<t.preVerificationGas&&(o=t.preVerificationGas),s<t.verificationGasLimit&&(s=t.verificationGasLimit),c<t.callGasLimit&&(c=t.callGasLimit),e.maxFeePerGas=i,e.maxPriorityFeePerGas=f})}throw new m("BAD_DATA","bundlerRpc cant't be null if preVerificationGas,verificationGasLimit and callGasLimit are not overriden")}()}();return f&&f.then?f.then(i):i()},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){void 0===r&&(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(M(function(){return Promise.resolve(a.calculateUserOperationErc20TokenMaxGasCost(t,r)).then(function(o){var s=2n*o;return Promise.resolve(a.getPaymasterMetaData()).then(function(o){var c=e.prependTokenPaymasterApproveToCallData(t.callData,r,o.address,s);return t.callData=c,Promise.resolve(a.createPaymasterUserOperation(t,n,{token:r},i))})})},function(e){var t=y(e);throw new m("PAYMASTER_ERROR","createTokenPaymasterUserOperation failed",{cause:t})}))}catch(e){return Promise.reject(e)}},r.calculateUserOperationErc20TokenMaxGasCost=function(e,t){try{var r=this;return Promise.resolve(M(function(){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,function(e,t){return"bigint"==typeof t?"0x"+t.toString(16):t})}})});var i=b(e);return n.exchangeRate*i/BigInt(Math.pow(10,18))})},function(e){var t=y(e);throw new m("PAYMASTER_ERROR","calculateUserOperationErc20TokenMaxGasCost failed",{cause:t})}))}catch(e){return Promise.reject(e)}},t}(function(){}),N={__proto__:null,SmartAccount:s,SafeAccountV0_2_0:C,SendUseroperationResponse:I,SmartAccountFactory:O,SafeAccountFactory:x,Bundler:L,CandidePaymaster:B,createUserOperationHash:g,createCallData:G,getFunctionSelector:E,fetchAccountNonce:A,calculateUserOperationMaxGasCost:b,get SafeModuleExecutorFunctionSelector(){return e.SafeModuleExecutorFunctionSelector},get Operation(){return e.Operation},ZeroAddress:S,UserOperationDummyValues:R};e.Bundler=L,e.CandidePaymaster=B,e.SafeAccountFactory=x,e.SafeAccountV0_2_0=C,e.SendUseroperationResponse=I,e.SmartAccount=s,e.SmartAccountFactory=O,e.UserOperationDummyValues=R,e.ZeroAddress=S,e.abstractionkit=N,e.calculateUserOperationMaxGasCost=b,e.createCallData=G,e.createUserOperationHash=g,e.fetchAccountNonce=A,e.getFunctionSelector=E}); | ||
!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 a,i,o=/*#__PURE__*/n(t),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,l(e,t)}function d(e){return d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},d(e)}function l(e,t){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},l(e,t)}function h(e){var t="function"==typeof Map?new Map:void 0;return h=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 a=new(e.bind.apply(e,n));return r&&l(a,r.prototype),a}(e,arguments,d(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),l(r,e)},h(e)}function v(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}function p(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 v(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)?v(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){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.")}s.proxyByteCode=void 0,s.initializerFunctionSelector=void 0,s.initializerFunctionInputAbi=void 0,s.executorFunctionSelector=void 0,s.executorFunctionInputAbi=void 0,e.Operation=void 0,(a=e.Operation||(e.Operation={}))[a.Call=0]="Call",a[a.Delegate=1]="Delegate",function(e){e[e.Slow=1]="Slow",e[e.Medium=1.2]="Medium",e[e.Fast=1.5]="Fast"}(i||(i={}));var m={"-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"},A=/*#__PURE__*/function(e){function t(t,r,n){var a;void 0===n&&(n={});var i=n.errno,o=n.context;return(a=e.call(this,r,{cause:n.cause})||this).code=void 0,a.context=void 0,a.errno=void 0,a.name=a.constructor.name,a.code=t,a.errno=i,a.context=o,a}return u(t,e),t}(/*#__PURE__*/h(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 g=function(e,t){try{void 0===t&&(t=i.Medium);var n=new r.JsonRpcProvider(e);return Promise.resolve(n.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)}},E=function(e,t,r,n){void 0===n&&(n=0);try{var a=[{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(b(e,"eth_call",a)).then(function(e){if("string"!=typeof e)throw new A("BAD_DATA","getNonce returned ill formed data",{context:JSON.stringify(e)});try{return BigInt(e)}catch(e){var t=y(e);throw new A("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 A("BAD_DATA","getNonce failed",{cause:t})}))}catch(e){return Promise.reject(e)}},b=function(e,t,r){try{var n=o.default||o,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 A(n in m?m[n]:"UNKNOWN_ERROR",r.message,{errno:r.code,context:{url:e,requestOptions:JSON.stringify(a)}})})})}catch(e){return Promise.reject(e)}};function D(e,t,n){var a=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)),i=r.AbiCoder.defaultAbiCoder().encode(["bytes32","address","uint256"],[a,t,n]);return r.keccak256(i)}function P(e,t,n){return e+r.AbiCoder.defaultAbiCoder().encode(t,n).slice(2)}function G(e){return r.id(e).slice(0,10)}function _(e){return(e.callGasLimit+e.verificationGasLimit*("0x"==e.paymasterAndData||null==e.paymasterAndData?3n:0n)+e.preVerificationGas)*e.maxFeePerGas}var T,S,R=function(e,t,r){try{var n=[t,r];return Promise.resolve(function(t,r){try{var a=Promise.resolve(b(e,"eth_call",n)).then(function(e){if("string"!=typeof e)throw new A("BAD_DATA","eth_call returned ill formed data",{context:JSON.stringify(e)});try{return e}catch(e){var t=y(e);throw new A("BAD_DATA","eth_call returned ill formed data",{cause:t})}})}catch(e){return r(e)}return a&&a.then?a.then(void 0,r):a}(0,function(e){var t=y(e);throw new A("BAD_DATA","eth_call failed",{cause:t})}))}catch(e){return Promise.reject(e)}},L=/*#__PURE__*/function(e){function t(r){return void 0===r&&(r=t.DEFAULT_SOCIAL_RECOVERY_ADDRESS),e.call(this,r)||this}u(t,e);var n=t.prototype;return n.createConfirmRecoveryMetaTransaction=function(e,t,r,n){var a=P(G("confirmRecovery(address,address[],uint256,bool)"),["address","address[]","uint256","bool"],[e,t,r,n]);return{to:this.moduleAddress,data:a,value:0n}},n.createMultiConfirmRecoveryMetaTransaction=function(e,t,r,n,a){var i=P(G("multiConfirmRecovery(address,address[],uint256,address[],bool)"),["address","address[]","uint256","address[]","bool"],[e,t,r,n,a]);return{to:this.moduleAddress,data:i,value:0n}},n.createExecuteRecoveryMetaTransaction=function(e,t,r){var n=P(G("executeRecovery(address,address[],uint256)"),["address","address[]","uint256"],[e,t,r]);return{to:this.moduleAddress,data:n,value:0n}},n.createFinalizeRecoveryMetaTransaction=function(e){var t=P(G("finalizeRecovery(address)"),["address"],[e]);return{to:this.moduleAddress,data:t,value:0n}},n.createCancelRecoveryMetaTransaction=function(e){var t=P(G("cancelRecovery(address)"),["address"],[e]);return{to:this.moduleAddress,data:t,value:0n}},n.createAddGuardianWithThresholdMetaTransaction=function(e,t,r){var n=P(G("addGuardianWithThreshold(address,address,uint256)"),["address","address","uint256"],[e,t,r]);return{to:this.moduleAddress,data:n,value:0n}},n.createRevokeGuardianWithThresholdMetaTransaction=function(e,t,r,n){var a=P(G("revokeGuardianWithThreshold(address,address,address,uint256)"),["address","address","address","uint256"],[e,t,r,n]);return{to:this.moduleAddress,data:a,value:0n}},n.createChangeThresholdMetaTransaction=function(e,t){var r=P(G("changeThreshold(address,uint256)"),["address","uint256"],[e,t]);return{to:this.moduleAddress,data:r,value:0n}},n.getRecoveryHash=function(e,t,r,n,a){try{var i=P(G("getRecoveryHash(address,address[],uint256,uint256)"),["address","address[]","uint256","uint256"],[t,r,n,a]);return R(e,{to:this.moduleAddress,data:i},"latest")}catch(e){return Promise.reject(e)}},n.getRecoveryRequest=function(e,t){try{var n=P(G("getRecoveryRequest(address)"),["address"],[t]);return Promise.resolve(R(e,{to:this.moduleAddress,data:n},"latest")).then(function(e){var t=r.AbiCoder.defaultAbiCoder().decode(["uint256","uint256","uint64","address[]"],e);return{guardiansApprovalCount:t[0],newThreshold:t[1],executeAfter:t[2],newOwners:t[3]}})}catch(e){return Promise.reject(e)}},n.getRecoveryApprovals=function(e,t,n,a){try{var i=P(G("getRecoveryApprovals(address,address[],uint256)"),["address","address[]","uint256"],[t,n,a]);return Promise.resolve(R(e,{to:this.moduleAddress,data:i},"latest")).then(function(e){var t=r.AbiCoder.defaultAbiCoder().decode(["uint256"],e);return BigInt(t[0])})}catch(e){return Promise.reject(e)}},n.hasGuardianApproved=function(e,t,n,a,i){try{var o=P(G("hasGuardianApproved(address,address,address[],uint256)"),["address","address","address[]","uint256"],[t,n,a,i]);return Promise.resolve(R(e,{to:this.moduleAddress,data:o},"latest")).then(function(e){var t=r.AbiCoder.defaultAbiCoder().decode(["bool"],e);return Boolean(t[0])})}catch(e){return Promise.reject(e)}},n.isGuardian=function(e,t,n){try{var a=P(G("isGuardian(address,address)"),["address","address"],[t,n]);return Promise.resolve(R(e,{to:this.moduleAddress,data:a},"latest")).then(function(e){var t=r.AbiCoder.defaultAbiCoder().decode(["bool"],e);return Boolean(t[0])})}catch(e){return Promise.reject(e)}},n.guardiansCount=function(e,t){try{var n=P(G("guardiansCount(address)"),["address"],[t]);return Promise.resolve(R(e,{to:this.moduleAddress,data:n},"latest")).then(function(e){var t=r.AbiCoder.defaultAbiCoder().decode(["uint256"],e);return BigInt(t[0])})}catch(e){return Promise.reject(e)}},n.threshold=function(e,t){try{var n=P(G("threshold(address)"),["address"],[t]);return Promise.resolve(R(e,{to:this.moduleAddress,data:n},"latest")).then(function(e){var t=r.AbiCoder.defaultAbiCoder().decode(["uint256"],e);return BigInt(t[0])})}catch(e){return Promise.reject(e)}},n.getGuardians=function(e,t){try{var n=P(G("getGuardians(address)"),["address"],[t]);return Promise.resolve(R(e,{to:this.moduleAddress,data:n},"latest")).then(function(e){return r.AbiCoder.defaultAbiCoder().decode(["address[]"],e)[0]})}catch(e){return Promise.reject(e)}},n.nonce=function(e,t){try{var n=P(G("nonce(address)"),["address"],[t]);return Promise.resolve(R(e,{to:this.moduleAddress,data:n},"latest")).then(function(e){var t=r.AbiCoder.defaultAbiCoder().decode(["uint256"],e);return BigInt(t[0])})}catch(e){return Promise.reject(e)}},t}(/*#__PURE__*/function(){function e(e){this.moduleAddress=void 0,this.moduleAddress=e}return e.prototype.createEnableModuleMetaTransaction=function(e){return{to:e,data:P(G("enableModule(address)"),["address"],[this.moduleAddress]),value:0n}},e}());function F(t){return"0x"+t.map(function(t){return i=null!=(a=(n=t).operation)?a:e.Operation.Call,o=r.getBytes(n.data),r.solidityPacked(["uint8","address","uint256","uint256","bytes"],[i,n.to,n.value,o.length,o]).slice(2);var n,a,i,o}).join("")}function U(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}L.DEFAULT_SOCIAL_RECOVERY_ADDRESS="0xFc98B4a5120959511873a51daBd6c1889897412d",e.SafeModuleExecutorFunctionSelector=void 0,(T=e.SafeModuleExecutorFunctionSelector||(e.SafeModuleExecutorFunctionSelector={})).executeUserOpWithErrorString="0x541d63c8",T.executeUserOp="0x7bb37428",e.DummySignature=void 0,(S=e.DummySignature||(e.DummySignature={})).eoa="ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",S.webAuthn="5715d3b8fc6e09d43d24175720e98c1ed970661400000000000000000000000000000000000000000000000000000000000000410000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e0762c7349c04b09b85aa0b0d21ba70df2195d60c653877df252a16c3f62559fa02d0dbe584b8a794bcf5fc5263f42cf8d50d200c3bc15fe375508e24ca97002ad000000000000000000000000000000000000000000000000000000000000002549960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d9763050000000e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a1226f726967696e223a22687474703a2f2f6c6f63616c686f73743a35313733222c2263726f73734f726967696e223a66616c73652c226f746865725f6b6579735f63616e5f62655f61646465645f68657265223a22646f206e6f7420636f6d7061726520636c69656e74446174614a534f4e20616761696e737420612074656d706c6174652e205365652068747470733a2f2f676f6f2e676c2f7961625065782200000000000000000000000000000000000000000000000000000000000000";var O=/*#__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(U(function(){return Promise.resolve(b(e.rpcUrl,"eth_chainId",[])).then(function(e){if("string"==typeof e)return e;throw new A("BAD_DATA","bundler eth_chainId rpc call failed")})},function(e){var t=y(e);throw new A("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(U(function(){return Promise.resolve(b(e.rpcUrl,"eth_supportedEntryPoints",[]))},function(e){var t=y(e);throw new A("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(U(function(){function a(){var e=i;return{callGasLimit:BigInt(e.callGasLimit),preVerificationGas:BigInt(e.preVerificationGas),verificationGasLimit:BigInt(e.verificationGasLimit)}}var i={},o=void 0===r?Promise.resolve(b(n.rpcUrl,"eth_estimateUserOperationGas",[e,t])).then(function(e){i=e}):Promise.resolve(b(n.rpcUrl,"eth_estimateUserOperationGas",[e,t,r])).then(function(e){i=e});return o&&o.then?o.then(a):a()},function(e){var t=y(e);throw new A("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(U(function(){return Promise.resolve(b(r.rpcUrl,"eth_sendUserOperation",[e,t]))},function(e){var t=y(e);throw new A("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(U(function(){return Promise.resolve(b(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 A("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(U(function(){return Promise.resolve(b(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 A("BUNDLER_ERROR","bundler eth_getUserOperationByHash rpc call failed",{cause:r,context:{useroperationhash:e}})}))}catch(e){return Promise.reject(e)}},e}();function x(e,t,r){if(!e.s){if(r instanceof I){if(!r.s)return void(r.o=x.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(x.bind(null,e,t),x.bind(null,e,2));e.s=t,e.v=r;const n=e.o;n&&n(e)}}var I=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(t,r){var n=new e,a=this.s;if(a){var i=1&a?t:r;if(i){try{x(n,1,i(this.v))}catch(e){x(n,2,e)}return n}return this}return this.o=function(e){try{var a=e.v;1&e.s?x(n,1,t?t(a):a):r?x(n,1,r(a)):x(n,2,a)}catch(e){x(n,2,e)}},n},e}();function w(e){return e instanceof I&&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 A("TIMEOUT","can't find useroperation",{context:a.userOperationHash})},a=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 i=0,o=function(e,t,r){for(var n;;){var a=e();if(w(a)&&(a=a.v),!a)return i;if(a.then){n=0;break}var i=r();if(i&&i.then){if(!w(i)){n=1;break}i=i.s}if(t){var o=t();if(o&&o.then&&!w(o)){n=2;break}}}var s=new I,f=x.bind(null,s,2);return(0===n?a.then(u):1===n?i.then(c):o.then(d)).then(void 0,f),s;function c(n){i=n;do{if(t&&(o=t())&&o.then&&!w(o))return void o.then(d).then(void 0,f);if(!(a=e())||w(a)&&!a.v)return void x(s,1,i);if(a.then)return void a.then(u).then(void 0,f);w(i=r())&&(i=i.v)}while(!i||!i.then);i.then(c).then(void 0,f)}function u(e){e?(i=r())&&i.then?i.then(c).then(void 0,f):c(i):x(s,1,i)}function d(){(a=e())?a.then?a.then(u).then(void 0,f):u(a):x(s,1,i)}}(function(){return!r&&i<=e},void 0,function(){return Promise.resolve(a.delay(1e3*t)).then(function(){return Promise.resolve(a.bundler.getUserOperationReceipt(a.userOperationHash)).then(function(e){if(null!=e)return r=1,e;i++})})});return Promise.resolve(o&&o.then?o.then(n):n(o))}catch(e){return Promise.reject(e)}},e}(),N=/*#__PURE__*/function(t){function n(e,r,a){var i;return void 0===r&&(r=n.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===a&&(a=n.DEFAULT_ENTRYPOINT_ADDRESS),(i=t.call(this,e)||this).entrypointAddress=void 0,i.safe4337ModuleAddress=void 0,i.initCode=void 0,i.entrypointAddress=a,i.safe4337ModuleAddress=r,i.initCode=null,i}return u(n,t),n.createProxyAddress=function(e,t,n,a){if(t<0n)throw RangeError("c2Nonce can't be negative");var i=r.AbiCoder.defaultAbiCoder(),o=r.keccak256(r.solidityPacked(["bytes32","uint256"],[r.keccak256(e),t])),s=i.encode(["uint256"],[a]),f=r.keccak256(r.solidityPacked(["bytes","bytes"],[this.proxyByteCode,s]));return"0x"+r.solidityPackedKeccak256(["bytes1","address","bytes32","bytes32"],["0xff",n,o,f]).slice(-40)},n.createAccountCallDataSingleTransaction=function(t){var r,a,i,o=null!=(r=t.value)?r:0,s=null!=(a=t.data)?a:"0x",f=null!=(i=t.operation)?i: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 a=P("0x8d80ff0a",["bytes"],[F(t)]);return n.createAccountCallData(r,0n,a,e.Operation.Delegate)},n.createAccountCallData=function(e,t,r,a,i){return void 0===i&&(i=n.DEFAULT_EXECUTOR_FUCNTION_SELECTOR),P(i,n.executorFunctionInputAbi,[e,t,r,a])},n.decodeAccountCallData=function(t){if(t.startsWith(e.SafeModuleExecutorFunctionSelector.executeUserOpWithErrorString)||t.startsWith(e.SafeModuleExecutorFunctionSelector.executeUserOp)){var n=r.AbiCoder.defaultAbiCoder(),a="0x"+t.slice(10),i=n.decode(["address","uint256","bytes","uint8"],a);return[i[0],BigInt(i[1]),i[2],Number(i[3])]}throw new A("BAD_DATA","Invalid calldata, should start with "+e.SafeModuleExecutorFunctionSelector.executeUserOpWithErrorString+" or "+e.SafeModuleExecutorFunctionSelector.executeUserOp,{context:{callData:t}})},n.prependTokenPaymasterApproveToCallDataStatic=function(t,a,i,o,s){void 0===s&&(s=n.DEFAULT_MULTISEND_CONTRACT_ADDRESS);var f=n.decodeAccountCallData(t),c=f[0],u=f[1],d=f[2],l=f[3],h="";h="string"!=typeof d?(new TextDecoder).decode(d):d;var v=F([{to:a,value:0n,data:P(G("approve(address,uint256)"),["address","uint256"],[i,o]),operation:e.Operation.Call}]),p="",m="0x8d80ff0a";if(h.startsWith(m)){var A=function(e){return r.AbiCoder.defaultAbiCoder().decode(["bytes"],"0x"+e.slice(10))[0]}(h);p=A+v.slice(2)}else p=F([{to:c,value:u,data:d,operation:l}])+v.slice(2);var y=P(m,["bytes"],[p]);return n.createAccountCallData(s,0n,y,e.Operation.Delegate)},n.formatEip712SignaturesToUseroperationSignature=function(e,t,r,a){if(void 0===r&&(r=0n),void 0===a&&(a=0n),e.length!=t.length)throw RangeError("signersAddresses and signatures arrays should be the same length");var i=new Map;e.forEach(function(e,r){i.set(e.toLocaleLowerCase(),t[r])});var o=new Map(Array.from(i).sort()),s="0x"+Array.from(o.values()).reduce(function(e,t){return e+t.slice(2)},"");return n.formatEip712SingleSignatureToUseroperationSignature(s,r,a)},n.getUserOperationEip712Hash=function(e,t,a,i,o){return void 0===a&&(a=0n),void 0===i&&(i=0n),r.TypedDataEncoder.hash({chainId:t,verifyingContract:n.DEFAULT_SAFE_4337_MODULE_ADDRESS},n.EIP712_SAFE_OPERATION_TYPE,{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:a,validUntil:i,entryPoint:o})},n.formatEip712SingleSignatureToUseroperationSignature=function(e,t,n){if(void 0===t&&(t=0n),void 0===n&&(n=0n),t<0n)throw RangeError("validAfter can't be negative");if(n<0n)throw RangeError("validUntil can't be negative");return r.solidityPacked(["uint48","uint48","bytes"],[t,n,e])},n.prototype.sendUserOperation=function(e,t){try{var r=this,n=new O(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);N.DEFAULT_ENTRYPOINT_ADDRESS="0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",N.DEFAULT_SAFE_4337_MODULE_ADDRESS="0xa581c4A4DB7175302464fF3C06380BC3270b4037",N.DEFAULT_SINGLETON_ADDRESS="0x29fcB43b46531BcA003ddC8FCB67FFE91900C762",N.DEFAULT_ADD_MODULE_LIB_ADDRESS="0x8EcD4ec46D4D2a6B64fE960B3D64e8B94B2234eb",N.DEFAULT_MULTISEND_CONTRACT_ADDRESS="0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526",N.proxyByteCode="0x608060405234801561001057600080fd5b506040516101e63803806101e68339818101604052602081101561003357600080fd5b8101908080519060200190929190505050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156100ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806101c46022913960400191505060405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505060ab806101196000396000f3fe608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea264697066735822122003d1488ee65e08fa41e58e888a9865554c535f2c77126a82cb4c0f917f31441364736f6c63430007060033496e76616c69642073696e676c65746f6e20616464726573732070726f7669646564",N.initializerFunctionSelector="0xb63e800d",N.initializerFunctionInputAbi=["address[]","uint256","address","bytes","address","address","uint256","address"],N.DEFAULT_EXECUTOR_FUCNTION_SELECTOR=e.SafeModuleExecutorFunctionSelector.executeUserOpWithErrorString,N.executorFunctionInputAbi=["address","uint256","bytes","uint8"],N.EIP712_SAFE_OPERATION_TYPE={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"}]};var B="0x0000000000000000000000000000000000000000",M={sender:B,nonce:0n,initCode:"0x",callData:"0x",callGasLimit:0n,verificationGasLimit:0n,preVerificationGas:0n,maxFeePerGas:0n,maxPriorityFeePerGas:0n,paymasterAndData:"0x",signature:"0x"},k=/*#__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}(),V=/*#__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}(k),j=/*#__PURE__*/function(e){function t(r,n,a){return void 0===n&&(n=t.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===a&&(a=t.DEFAULT_ENTRYPOINT_ADDRESS),e.call(this,r,n,a)||this}u(t,e),t.initializeNewAccount=function(e,r){void 0===r&&(r={});var n=t.createAccountAddressAndInitCode(e,r),a=n[1],i=new t(n[0]);return i.initCode=a,i},t.createAccountAddress=function(e,r){return void 0===r&&(r={}),t.createAccountAddressAndInitCode(e,r)[0]},t.createAccountAddressAndInitCode=function(e,r){var n,a,i,o,s;if(void 0===r&&(r={}),e.length<1)throw RangeError("There should be at least one owner");var f=null!=(n=r.threshold)?n:1,c=null!=(a=r.c2Nonce)?a:0n,u=null!=(i=r.singletonAddress)?i:N.DEFAULT_SINGLETON_ADDRESS,d=null!=(o=r.safe4337ModuleAddress)?o:N.DEFAULT_SAFE_4337_MODULE_ADDRESS,l=null!=(s=r.addModuleLibAddress)?s:N.DEFAULT_ADD_MODULE_LIB_ADDRESS,h=new V;null!=r.safeAccountFactoryAddress&&(h=new V(r.safeAccountFactoryAddress));var v=t.createInitializerCallData(e,f,d,l);return[this.createProxyAddress(v,c,h.address,u),h.getFactoryGeneratorFunctionCallData([u,v,c])]},t.createInitializerCallData=function(e,t,r,n){if(void 0===r&&(r=N.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===n&&(n=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=P("0x8d0dc49f",["address[]"],[[r]]);return P(N.initializerFunctionSelector,N.initializerFunctionInputAbi,[e,t,n,a,r,B,0,B])},t.createInitCode=function(e,r,n,a,i,o,s){if(void 0===r&&(r=1),void 0===n&&(n=0n),void 0===a&&(a=N.DEFAULT_SINGLETON_ADDRESS),void 0===i&&(i=new V),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(r<1)throw RangeError("threshold should be at least one");if(r>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=t.createInitializerCallData(e,r,o,s);return i.getFactoryGeneratorFunctionCallData([a,f,n])};var n=t.prototype;return n.prependTokenPaymasterApproveToCallData=function(e,r,n,a,i){return void 0===i&&(i=t.DEFAULT_MULTISEND_CONTRACT_ADDRESS),t.prependTokenPaymasterApproveToCallDataStatic(e,r,n,a,i)},n.estimateUserOperationGas=function(e,t,r,n){void 0===n&&(n=1);try{if(n<1n)throw RangeError("numberOfSigners can't be less than 1");for(var a="",i=0;i<n;i++)a+="ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff";e.signature="0xffffffffffffffffffffffff"+a;var o=new O(t),s=e.maxFeePerGas,f=e.maxPriorityFeePerGas;return e.maxFeePerGas=0n,e.maxPriorityFeePerGas=0n,Promise.resolve(o.estimateUserOperationGas(e,this.entrypointAddress,r)).then(function(t){return e.maxFeePerGas=s,e.maxPriorityFeePerGas=f,[BigInt(t.preVerificationGas),BigInt(t.verificationGasLimit)+20000n*BigInt(n),BigInt(t.callGasLimit)]})}catch(e){return Promise.reject(e)}},n.createUserOperation=function(e,r,n,a){void 0===a&&(a={});try{var i=function(i){var f;function u(e){var t,r,i,f;function u(e){var t,r,n,i,o,s;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 p.preVerificationGas=null!=(t=a.preVerificationGas)?t:m*BigInt(Math.floor(((null!=(r=a.preVerificationGasPercentageMultiplier)?r:0)+100)/100)),p.verificationGasLimit=null!=(n=a.verificationGasLimit)?n:y*BigInt(Math.floor(((null!=(i=a.verificationGasLimitPercentageMultiplier)?i:0)+100)/100)),p.callGasLimit=null!=(o=a.callGasLimit)?o:g*BigInt(Math.floor(((null!=(s=a.callGasLimitPercentageMultiplier)?s:0)+100)/100)),p}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");h=null!=(t=a.maxFeePerGas)?t:h*BigInt(Math.floor(((null!=(r=a.maxFeePerGasPercentageMultiplier)?r:0)+100)/100)),v=null!=(i=a.maxPriorityFeePerGas)?i:v*BigInt(Math.floor(((null!=(f=a.maxPriorityFeePerGasPercentageMultiplier)?f:0)+100)/100));var p=c({},M,{sender:o.accountAddress,nonce:s,initCode:d,callData:l,maxFeePerGas:h,maxPriorityFeePerGas:v}),m=M.preVerificationGas,y=M.verificationGasLimit,g=M.callGasLimit,E=function(){if(null==a.preVerificationGas||null==a.verificationGasLimit||null==a.callGasLimit)return function(){if(null!=n){p.callGasLimit=0n,p.verificationGasLimit=0n,p.preVerificationGas=0n;var e=p.maxFeePerGas,t=p.maxPriorityFeePerGas;return p.maxFeePerGas=0n,p.maxPriorityFeePerGas=0n,Promise.resolve(o.estimateUserOperationGas(p,n,a.state_override_set,a.numberOfSigners)).then(function(r){m=r[0],y=r[1],g=r[2],p.maxFeePerGas=e,p.maxPriorityFeePerGas=t})}throw new A("BAD_DATA","bundlerRpc cant't be null if preVerificationGas,verificationGasLimit and callGasLimit are not overriden")}()}();return E&&E.then?E.then(u):u()}var d=null!=(f=a.initCode)?f:o.initCode;if((null==d||s>0n)&&(d="0x"),s<0n)throw RangeError("nonce can't be negative");var l="0x";l=null==a.callData?1==e.length?t.createAccountCallDataSingleTransaction(e[0]):t.createAccountCallDataBatchTransactions(e):a.callData;var h=M.maxFeePerGas,v=M.maxPriorityFeePerGas,p=function(){if(null==a.maxFeePerGas||null==a.maxPriorityFeePerGas)return function(){if(null!=r)return Promise.resolve(g(r)).then(function(e){h=e[0],v=e[1]});throw new A("BAD_DATA","providerRpc cant't be null if maxFeePerGas and maxPriorityFeePerGas are not overriden")}()}();return p&&p.then?p.then(u):u()},o=this;if(e.length<1)throw RangeError("There should be at least one transaction");var s=0n,f=function(){if(null==a.nonce)return function(){if(null!=r)return Promise.resolve(E(r,o.entrypointAddress,o.accountAddress)).then(function(e){s=e});throw new A("BAD_DATA","providerRpc cant't be null if nonce is not overriden")}();s=a.nonce}();return Promise.resolve(f&&f.then?f.then(i):i())}catch(e){return Promise.reject(e)}},n.signUserOperation=function(e,n,a,i,o){if(void 0===i&&(i=0n),void 0===o&&(o=0n),n.length<1)throw RangeError("There should be at least one privateKey");if(a<0n)throw RangeError("chainId can't be negative");if(i<0n)throw RangeError("validAfter can't be negative");if(o<0n)throw RangeError("validUntil can't be negative");for(var s,f=N.getUserOperationEip712Hash(e,a,i,o,this.entrypointAddress),c=[],u=[],d=p(n);!(s=d()).done;){var l=new r.Wallet(s.value),h=l.signingKey.sign(f).serialized;c.push(l.address),u.push(h)}return t.formatEip712SignaturesToUseroperationSignature(c,u,i,o)},t}(N),W=/*#__PURE__*/function(t){function n(e,r,a){var i;return void 0===r&&(r=n.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===a&&(a=n.DEFAULT_ENTRYPOINT_ADDRESS),(i=t.call(this,e,r,a)||this).isInitWebAuthn=void 0,i.x=0n,i.y=0n,i.isInitWebAuthn=!1,i}u(n,t),n.initializeNewAccount=function(e,t){void 0===t&&(t={});for(var r,a=!1,i=0n,o=0n,s=p(e);!(r=s()).done;){var f=r.value;"string"!=typeof f&&(a=!0,i=f.x,o=f.y)}var c=n.createAccountAddressAndInitCode(e,t),u=c[1],d=new n(c[0]);return d.initCode=u,d.isInitWebAuthn=a,d.x=i,d.y=o,d},n.createAccountAddress=function(e,t){return void 0===t&&(t={}),n.createAccountAddressAndInitCode(e,t)[0]},n.createAccountAddressAndInitCode=function(e,t){var r,a,i,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!=(a=t.c2Nonce)?a:0n,u=null!=(i=t.singletonAddress)?i:N.DEFAULT_SINGLETON_ADDRESS,d=null!=(o=t.safe4337ModuleAddress)?o:N.DEFAULT_SAFE_4337_MODULE_ADDRESS,l=null!=(s=t.addModuleLibAddress)?s:N.DEFAULT_ADD_MODULE_LIB_ADDRESS,h=new V;null!=t.safeAccountFactoryAddress&&(h=new V(t.safeAccountFactoryAddress));var v=n.createInitializerCallData(e,f,d,l);return[this.createProxyAddress(v,c,h.address,u),h.getFactoryGeneratorFunctionCallData([u,v,c])]},n.createInitializerCallData=function(t,r,a,i){if(void 0===a&&(a=N.DEFAULT_SAFE_4337_MODULE_ADDRESS),void 0===i&&(i=N.DEFAULT_ADD_MODULE_LIB_ADDRESS),t.length<1)throw RangeError("There should be at least one owner");if(r<1)throw RangeError("threshold should be at least one");if(r>t.length)throw RangeError("threshold can't be larger than number of owners");var o=P("0x8d0dc49f",["address[]"],[[a]]),s=[];s.push({to:i,value:0n,data:o,operation:e.Operation.Delegate});for(var f,c=[],u=0,d=p(t);!(f=d()).done;){var l=f.value;if("string"!=typeof l){if(u>0)throw RangeError("Only one WebAuthn owner can be set during initialization");var h=P("0xf9c6055b",["uint256","uint256"],[l.x,l.y]);s.push({to:n.DEFAULT_WEB_AUTHN_SIGNATURE_VALIDATOR_SINGLETON,value:0n,data:h,operation:e.Operation.Delegate}),c.push(n.DEFAULT_WEB_AUTHN_SIGNATURE_VALIDATOR_SINGLETON),u++}else c.push(l)}var v=P("0x8d80ff0a",["bytes"],[F(s)]);return P(N.initializerFunctionSelector,N.initializerFunctionInputAbi,[c,r,n.DEFAULT_MULTISEND_CONTRACT_ADDRESS,v,a,B,0,B])},n.createInitCode=function(e,t,r,a,i,o,s){if(void 0===t&&(t=1),void 0===r&&(r=0n),void 0===a&&(a=N.DEFAULT_SINGLETON_ADDRESS),void 0===i&&(i=new V),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 i.getFactoryGeneratorFunctionCallData([a,f,r])};var a=n.prototype;return a.prependTokenPaymasterApproveToCallData=function(e,t,r,a,i){return void 0===i&&(i=n.DEFAULT_MULTISEND_CONTRACT_ADDRESS),n.prependTokenPaymasterApproveToCallDataStatic(e,t,r,a,i)},a.estimateUserOperationGas=function(e,t,r,n,a){void 0===n&&(n=1),void 0===a&&(a=null);try{if(n<1n)throw RangeError("numberOfSigners can't be less than 1");if(null!=a&&n!=a.length)throw RangeError("dummySignatures list should has the length of numberOfSigners");for(var i="",o=0;o<n;o++)i+=a;e.signature="0xffffffffffffffffffffffffffffffffffffffffffffffff"+i;var s=new O(t);return Promise.resolve(s.estimateUserOperationGas(e,this.entrypointAddress,r)).then(function(e){return[BigInt(e.preVerificationGas),BigInt(e.verificationGasLimit)+20000n*BigInt(n),BigInt(e.callGasLimit)]})}catch(e){return Promise.reject(e)}},a.createUserOperation=function(t,r,a,i){void 0===i&&(i={});try{var o=function(o){var u;function d(e){var t,r,n,o;function u(e){var t,r,n,a,o,s;if("bigint"==typeof i.preVerificationGas&&i.preVerificationGas<0n)throw RangeError("preVerificationGas overrid can't be negative");if("bigint"==typeof i.verificationGasLimit&&i.verificationGasLimit<0n)throw RangeError("verificationGasLimit overrid can't be negative");if("bigint"==typeof i.callGasLimit&&i.callGasLimit<0n)throw RangeError("callGasLimit overrid can't be negative");return d.preVerificationGas=null!=(t=i.preVerificationGas)?t:h*BigInt((null!=(r=i.preVerificationGasPercentageMultiplier)?r:0)+100)/100n,d.verificationGasLimit=null!=(n=i.verificationGasLimit)?n:v*BigInt((null!=(a=i.verificationGasLimitPercentageMultiplier)?a:0)+100)/100n,d.callGasLimit=null!=(o=i.callGasLimit)?o:p*BigInt((null!=(s=i.callGasLimitPercentageMultiplier)?s:0)+100)/100n,d}if("bigint"==typeof i.maxFeePerGas&&i.maxFeePerGas<0n)throw RangeError("maxFeePerGas overrid can't be negative");if("bigint"==typeof i.maxPriorityFeePerGas&&i.maxPriorityFeePerGas<0n)throw RangeError("maxPriorityFeePerGas overrid can't be negative");b=null!=(t=i.maxFeePerGas)?t:b*BigInt((null!=(r=i.maxFeePerGasPercentageMultiplier)?r:0)+100)/100n,D=null!=(n=i.maxPriorityFeePerGas)?n:D*BigInt((null!=(o=i.maxPriorityFeePerGasPercentageMultiplier)?o:0)+100)/100n;var d=c({},M,{sender:s.accountAddress,nonce:f,initCode:l,callData:E,maxFeePerGas:b,maxPriorityFeePerGas:D}),h=M.preVerificationGas,v=M.verificationGasLimit,p=M.callGasLimit,m=function(){if(null==i.preVerificationGas||null==i.verificationGasLimit||null==i.callGasLimit)return function(){if(null!=a)return Promise.resolve(s.estimateUserOperationGas(d,a,i.state_override_set,i.numberOfSigners,i.dummySignatures)).then(function(e){h=e[0],v=e[1],p=e[2]});throw new A("BAD_DATA","bundlerRpc cant't be null if preVerificationGas,verificationGasLimit and callGasLimit are not overriden")}()}();return m&&m.then?m.then(u):u()}var l=null!=(u=i.initCode)?u:s.initCode;if(null==l||f>0n)l="0x";else if(s.isInitWebAuthn){var h=P("0x080fbebf",["uint256","uint256","address"],[s.x,s.y,n.DEFAULT_WEB_AUTHN_VERIFIER]),v=P("0x1688f0b9",["address","bytes","uint256"],[n.DEFAULT_SIGNATURE_VALIDATOR,h,0]),p={to:n.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,value:0n,data:v},m=n.createWebAuthnSignerVerifierAddress(s.x,s.y),y=P("0xe318b52b",["address","address","address"],["0x0000000000000000000000000000000000000001",n.DEFAULT_WEB_AUTHN_SIGNATURE_VALIDATOR_SINGLETON,m]);t=[p,{to:s.accountAddress,value:0n,data:y},{to:n.DEFAULT_WEB_AUTHN_SIGNATURE_VALIDATOR_SINGLETON,value:0n,data:"0x578c7a83",operation:e.Operation.Delegate}].concat(t)}if(f<0n)throw RangeError("nonce can't be negative");var E="0x";E=null==i.callData?1==t.length?n.createAccountCallDataSingleTransaction(t[0]):n.createAccountCallDataBatchTransactions(t):i.callData;var b=M.maxFeePerGas,D=M.maxPriorityFeePerGas,G=function(){if(null==i.maxFeePerGas||null==i.maxPriorityFeePerGas)return function(){if(null!=r)return Promise.resolve(g(r)).then(function(e){b=e[0],D=e[1]});throw new A("BAD_DATA","providerRpc cant't be null if maxFeePerGas and maxPriorityFeePerGas are not overriden")}()}();return G&&G.then?G.then(d):d()},s=this;if(t.length<1)throw RangeError("There should be at least one transaction");var f=0n,u=function(){if(null==i.nonce)return function(){if(null!=r)return Promise.resolve(E(r,s.entrypointAddress,s.accountAddress)).then(function(e){f=e});throw new A("BAD_DATA","providerRpc cant't be null if nonce is not overriden")}();f=i.nonce}();return Promise.resolve(u&&u.then?u.then(o):o())}catch(e){return Promise.reject(e)}},a.signUserOperation=function(e,t,a,i,o){if(void 0===i&&(i=0n),void 0===o&&(o=0n),t.length<1)throw RangeError("There should be at least one privateKey");if(a<0n)throw RangeError("chainId can't be negative");if(i<0n)throw RangeError("validAfter can't be negative");if(o<0n)throw RangeError("validUntil can't be negative");for(var s,f={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:o,entryPoint:this.entrypointAddress},c={chainId:a,verifyingContract:this.safe4337ModuleAddress},u=[],d=[],l=p(t);!(s=l()).done;){var h=new r.Wallet(s.value),v=h.signingKey.sign(r.TypedDataEncoder.hash(c,n.EIP712_SAFE_OPERATION_TYPE,f)).serialized;u.push(h.address),d.push(v)}return n.formatEip712SignaturesToUseroperationSignature(u,d,i,o)},n.createWebAuthnSignerVerifierAddress=function(e,t){var a=P("0x080fbebf",["uint256","uint256","address"],[e,t,n.DEFAULT_WEB_AUTHN_VERIFIER]),i=r.AbiCoder.defaultAbiCoder(),o=r.keccak256(r.solidityPacked(["bytes32","uint256"],[r.keccak256(a),0])),s=i.encode(["uint256"],[n.DEFAULT_SIGNATURE_VALIDATOR]),f=r.keccak256(r.solidityPacked(["bytes","bytes"],[n.DEFAULT_WEB_AUTHN_SIGNER_CREATION_CODE,s]));return"0x"+r.solidityPackedKeccak256(["bytes1","address","bytes32","bytes32"],["0xff",n.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,o,f]).slice(-40)},n.formatSignaturesToUseroperationSignature=function(e,t,a,i){void 0===t&&(t=null),void 0===a&&(a=0n),void 0===i&&(i=0n);var o=n.buildSignatures(e,t);return r.solidityPacked(["uint48","uint48","bytes"],[a,i,o])},n.getLowerCaseAddress=function(e){return"string"==typeof e?e.toLowerCase():n.createWebAuthnSignerVerifierAddress(e.x,e.y)},n.sortSignatures=function(e){e.sort(function(e,t){return n.getLowerCaseAddress(e.signer).localeCompare(n.getLowerCaseAddress(t.signer))})},n.buildSignatures=function(e,t){void 0===t&&(t=null),n.sortSignatures(e);var a=65*e.length,i=e.reduce(function(e,i){var o=e.segments,s=e.offset,f=i.signer,c=i.signature,u=i.isContractSignature;if(u=u||"string"!=typeof f){if("string"==typeof f)return{segments:[].concat(o,[r.ethers.solidityPacked(["uint256","uint256","uint8"],[f,a+s,0])]),offset:s+32+r.ethers.dataLength(c)};if(null==t)throw RangeError("Must define isInit parameter when using WebAuthn");return f=t?n.DEFAULT_WEB_AUTHN_SIGNATURE_VALIDATOR_SINGLETON:n.createWebAuthnSignerVerifierAddress(f.x,f.y),{segments:[].concat(o,[r.ethers.solidityPacked(["uint256","uint256","uint8"],[f,a+s,0])]),offset:s+32+r.ethers.dataLength(c)}}return{segments:[].concat(o,[r.ethers.solidityPacked(["bytes"],[c])]),offset:0}},{segments:[],offset:0});return r.ethers.concat([].concat(i.segments,e.map(function(e){var t=e.signature;return r.ethers.solidityPacked(["uint256","bytes"],[r.ethers.dataLength(t),t])})))},n.createWebAuthnSignature=function(e){return r.ethers.AbiCoder.defaultAbiCoder().encode(["bytes","bytes","uint256[2]"],[new Uint8Array(e.authenticatorData),e.clientDataFields,e.rs])},n}(N);function H(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}W.DEFAULT_WEB_AUTHN_SIGNATURE_VALIDATOR_SINGLETON="0xcA66C5A0eEAb0Fe74F343bb4A539042c68aE45F9",W.DEFAULT_WEB_AUTHN_SIGNER_FACTORY="0xEae2AD611c0e8E14604B8cc611a89d5e9d138B49",W.DEFAULT_WEB_AUTHN_VERIFIER="0xCAc51aDF726E4b269645a7fD6a43296A1Ff53e8d",W.DEFAULT_SIGNATURE_VALIDATOR="0x21E4747C7215fe6E343376034F08261bBD9ac497",W.DEFAULT_WEB_AUTHN_SIGNER_CREATION_CODE="0x608060405234801561001057600080fd5b5060405161017238038061017283398101604081905261002f916100b9565b6001600160a01b0381166100945760405162461bcd60e51b815260206004820152602260248201527f496e76616c69642073696e676c65746f6e20616464726573732070726f766964604482015261195960f21b606482015260840160405180910390fd5b600080546001600160a01b0319166001600160a01b03929092169190911790556100e9565b6000602082840312156100cb57600080fd5b81516001600160a01b03811681146100e257600080fd5b9392505050565b607b806100f76000396000f3fe608060405260008054632cf35bc960e11b8235016027576001600160f41b0381168252602082f35b3682833781823684845af490503d82833e806040573d82fd5b503d81f3fea264697066735822122062f4785a59897477a798d8218290ac5cf89f803649d66b453fa58689dd461e3164736f6c63430008140033";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}u(t,e);var r=t.prototype;return r.initialize=function(){try{var e=this;return Promise.resolve(H(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 A("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?H(function(){return Promise.resolve(b(e.rpcUrl,"pm_supportedERC20Tokens",[])).then(function(e){return{tokens:e.tokens.map(function(e){return{symbol:e.symbol,address:e.address,decimal:Number(e.decimal),fee:BigInt(e.fee),exchangeRate:BigInt(e.exchangeRate)}}),paymasterMetadata:e.paymasterMetadata}})},function(e){var t=y(e);throw new A("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?H(function(){return Promise.resolve(b(e.rpcUrl,"pm_supportedEntryPoint",[]))},function(e){var t=y(e);throw new A("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.toLowerCase()===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={}),void 0===n&&(n={});try{var a=function(){return H(function(){function a(t){var a,c,u,d,l,h;if("bigint"==typeof n.preVerificationGas&&n.preVerificationGas<0n)throw RangeError("preVerificationGas overrid can't be negative");if("bigint"==typeof n.verificationGasLimit&&n.verificationGasLimit<0n)throw RangeError("verificationGasLimit overrid can't be negative");if("bigint"==typeof n.callGasLimit&&n.callGasLimit<0n)throw RangeError("callGasLimit overrid can't be negative");return e.preVerificationGas=null!=(a=n.preVerificationGas)?a:o*BigInt((null!=(c=n.preVerificationGasPercentageMultiplier)?c:0)+100)/100n,e.verificationGasLimit=null!=(u=n.verificationGasLimit)?u:s*BigInt((null!=(d=n.verificationGasLimitPercentageMultiplier)?d:0)+100)/100n,e.callGasLimit=null!=(l=n.callGasLimit)?l:f*BigInt((null!=(h=n.callGasLimitPercentageMultiplier)?h:0)+100)/100n,e.preVerificationGas=e.preVerificationGas+100n,e.verificationGasLimit=e.verificationGasLimit+10000n,Promise.resolve(b(i.rpcUrl,"pm_sponsorUserOperation",[e,i.entrypointAddress,r])).then(function(t){var r,n,a,i,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!=(a=f.verificationGasLimit)?a:e.verificationGasLimit,e.maxFeePerGas=null!=(i=f.maxFeePerGas)?i:e.maxFeePerGas,e.maxPriorityFeePerGas=null!=(o=f.maxPriorityFeePerGas)?o:e.maxPriorityFeePerGas,e})}e.paymasterAndData=i.paymasterMetadata.dummyPaymasterAndData;var o=e.preVerificationGas,s=e.verificationGasLimit,f=e.callGasLimit,c=function(){if(null==n.preVerificationGas||null==n.verificationGasLimit||null==n.callGasLimit)return function(){if(null!=t){var r=new O(t);e.callGasLimit=0n,e.verificationGasLimit=0n,e.preVerificationGas=0n;var a=e.maxFeePerGas,c=e.maxPriorityFeePerGas;return e.maxFeePerGas=0n,e.maxPriorityFeePerGas=0n,Promise.resolve(r.estimateUserOperationGas(e,i.entrypointAddress,n.state_override_set)).then(function(t){o<t.preVerificationGas&&(o=t.preVerificationGas),s<t.verificationGasLimit&&(s=t.verificationGasLimit),f<t.callGasLimit&&(f=t.callGasLimit),e.maxFeePerGas=a,e.maxPriorityFeePerGas=c})}throw new A("BAD_DATA","bundlerRpc cant't be null if preVerificationGas,verificationGasLimit and callGasLimit are not overriden")}()}();return c&&c.then?c.then(a):a()},function(e){var t=y(e);throw new A("PAYMASTER_ERROR","pm_sponsorUserOperation failed",{cause:t})})},i=this,o=function(){if(null==i.entrypointAddress||null==i.supportedTokens||null==i.paymasterMetadata)return Promise.resolve(i.initialize()).then(function(){})}();return Promise.resolve(o&&o.then?o.then(a):a())}catch(e){return Promise.reject(e)}},r.createSponsorPaymasterUserOperation=function(e,t,r){void 0===r&&(r={});try{return Promise.resolve(this.createPaymasterUserOperation(e,t,{},r))}catch(e){return Promise.reject(e)}},r.createTokenPaymasterUserOperation=function(e,t,r,n,a){void 0===a&&(a={});try{var i=this;return Promise.resolve(H(function(){return Promise.resolve(i.calculateUserOperationErc20TokenMaxGasCost(t,r)).then(function(o){var s=2n*o;return Promise.resolve(i.getPaymasterMetaData()).then(function(o){var f=e.prependTokenPaymasterApproveToCallData(t.callData,r,o.address,s);return t.callData=f,Promise.resolve(i.createPaymasterUserOperation(t,n,{token:r},a))})})},function(e){var t=y(e);throw new A("PAYMASTER_ERROR","createTokenPaymasterUserOperation failed",{cause:t})}))}catch(e){return Promise.reject(e)}},r.calculateUserOperationErc20TokenMaxGasCost=function(e,t){try{var r=this;return Promise.resolve(H(function(){return Promise.resolve(r.getSupportedERC20TokenData(t)).then(function(n){if(null==n)return Promise.resolve(r.getSupportedERC20TokensAndPaymasterMetadata()).then(function(e){throw new A("PAYMASTER_ERROR",t+" token is not supported by the paymaster.",{context:{supportedERC20TokensAndPaymasterMetadata:JSON.stringify(e,function(e,t){return"bigint"==typeof t?"0x"+t.toString(16):t})}})});var a=_(e);return n.exchangeRate*a/BigInt(Math.pow(10,18))})},function(e){var t=y(e);throw new A("PAYMASTER_ERROR","calculateUserOperationErc20TokenMaxGasCost failed",{cause:t})}))}catch(e){return Promise.reject(e)}},t}(function(){}),Y={__proto__:null,SmartAccount:s,SocialRecoveryModule:L,SafeAccountV0_2_0:j,SafeAccountWebAuth:W,SendUseroperationResponse:C,SmartAccountFactory:k,SafeAccountFactory:V,Bundler:O,CandidePaymaster:z,createUserOperationHash:D,createCallData:P,getFunctionSelector:G,fetchAccountNonce:E,calculateUserOperationMaxGasCost:_,get SafeModuleExecutorFunctionSelector(){return e.SafeModuleExecutorFunctionSelector},get DummySignature(){return e.DummySignature},get Operation(){return e.Operation},ZeroAddress:B,UserOperationDummyValues:M};e.Bundler=O,e.CandidePaymaster=z,e.SafeAccountFactory=V,e.SafeAccountV0_2_0=j,e.SafeAccountWebAuth=W,e.SendUseroperationResponse=C,e.SmartAccount=s,e.SmartAccountFactory=k,e.SocialRecoveryModule=L,e.UserOperationDummyValues=M,e.ZeroAddress=B,e.abstractionkit=Y,e.calculateUserOperationMaxGasCost=_,e.createCallData=P,e.createUserOperationHash=D,e.fetchAccountNonce=E,e.getFunctionSelector=G}); |
@@ -16,7 +16,7 @@ import { Paymaster } from "./Paymaster"; | ||
getSupportedERC20TokenData(erc20TokenAddress: string): Promise<ERC20Token | null>; | ||
createPaymasterUserOperation(userOperation: UserOperation, bundlerRpc: string, context?: CandidePaymasterContext, createPaymasterUserOperationOverrides?: CreatePaymasterUserOperationOverrides): Promise<UserOperation>; | ||
createSponsorPaymasterUserOperation(userOperation: UserOperation, bundlerRpc: string, createPaymasterUserOperationOverrides?: CreatePaymasterUserOperationOverrides): Promise<UserOperation>; | ||
createTokenPaymasterUserOperation(smartAccount: PrependTokenPaymasterApproveAccount, userOperation: UserOperation, tokenAddress: string, bundlerRpc: string, createPaymasterUserOperationOverrides?: CreatePaymasterUserOperationOverrides): Promise<UserOperation>; | ||
createPaymasterUserOperation(userOperation: UserOperation, bundlerRpc: string, context?: CandidePaymasterContext, overrides?: CreatePaymasterUserOperationOverrides): Promise<UserOperation>; | ||
createSponsorPaymasterUserOperation(userOperation: UserOperation, bundlerRpc: string, overrides?: CreatePaymasterUserOperationOverrides): Promise<UserOperation>; | ||
createTokenPaymasterUserOperation(smartAccount: PrependTokenPaymasterApproveAccount, userOperation: UserOperation, tokenAddress: string, bundlerRpc: string, overrides?: CreatePaymasterUserOperationOverrides): Promise<UserOperation>; | ||
calculateUserOperationErc20TokenMaxGasCost(userOperation: UserOperation, erc20TokenAddress: string): Promise<bigint>; | ||
} | ||
//# sourceMappingURL=CandidePaymaster.d.ts.map |
@@ -7,3 +7,3 @@ { | ||
}, | ||
"version": "0.1.10", | ||
"version": "0.1.11", | ||
"description": "Account Abstraction 4337 SDK by Candidelabs", | ||
@@ -10,0 +10,0 @@ "main": "dist/index.js", |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
255839
49
1221
4
1