abstractionkit 0.2.38 → 0.2.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Bundler.d.ts +3 -3
- package/dist/Bundler.d.ts.map +1 -1
- package/dist/abstractionkit.d.ts +7 -5
- package/dist/abstractionkit.d.ts.map +1 -1
- package/dist/account/Calibur/Calibur7702Account.d.ts +44 -0
- package/dist/account/Calibur/Calibur7702Account.d.ts.map +1 -0
- package/dist/account/Calibur/types.d.ts +62 -0
- package/dist/account/Calibur/types.d.ts.map +1 -0
- package/dist/account/Safe/SafeMultiChainSigAccount.d.ts +1 -5
- package/dist/account/Safe/SafeMultiChainSigAccount.d.ts.map +1 -1
- package/dist/account/Safe/modules/AllowanceModule.d.ts +1 -0
- package/dist/account/Safe/modules/AllowanceModule.d.ts.map +1 -1
- package/dist/account/simple/Simple7702Account.d.ts +9 -0
- package/dist/account/simple/Simple7702Account.d.ts.map +1 -1
- package/dist/constants.d.ts +2 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.m.js +1 -1
- package/dist/index.modern.mjs +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/paymaster/CandidePaymaster.d.ts +26 -21
- package/dist/paymaster/CandidePaymaster.d.ts.map +1 -1
- package/dist/paymaster/types.d.ts +4 -1
- package/dist/paymaster/types.d.ts.map +1 -1
- package/dist/types.d.ts +16 -27
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +1 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils7702.d.ts +3 -1
- package/dist/utils7702.d.ts.map +1 -1
- package/package.json +5 -4
package/dist/index.modern.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"isomorphic-unfetch";import{AbiCoder as t,keccak256 as a,id as n,JsonRpcProvider as r,solidityPacked as i,encodeRlp as s,Wallet as o,getBytes as l,toBeArray as c,hashMessage as d,solidityPackedKeccak256 as u,getAddress as f,TypedDataEncoder as A,ethers as h}from"ethers";class p{constructor(e){this.accountAddress=void 0,this.accountAddress=e}}function m(){return m=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)({}).hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},m.apply(null,arguments)}p.proxyByteCode=void 0,p.initializerFunctionSelector=void 0,p.initializerFunctionInputAbi=void 0,p.executorFunctionSelector=void 0,p.executorFunctionInputAbi=void 0;const E="0x0000000000000000000000000000000000000000",g="0x433709009B8330FDa32311DF1C2AFA402eD8D009",y="0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108",S="0x0000000071727De22E5E9d8BAf0edAc6f37da032",D="0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",_={singletonAddress:"0xEdd160fEBBD92E350D4D398fb636302fccd67C7e",singletonInitHash:"0x1b94aebb5a7df6dff11d93589204a6bbc99b4b8c9014bf1d386d006c2c17a881"},b={singletonAddress:"0x29fcB43b46531BcA003ddC8FCB67FFE91900C762",singletonInitHash:"0xe298282cefe913ab5d282047161268a8222e4bd4ed106300c547894bbefd31ee"},w={sender:E,nonce:0n,callData:"0x",callGasLimit:0n,verificationGasLimit:0n,preVerificationGas:0n,maxFeePerGas:0n,maxPriorityFeePerGas:0n,signature:"0x"},T="SafeOp",F={SafeOp:[{type:"address",name:"safe"},{type:"uint256",name:"nonce"},{type:"bytes",name:"initCode"},{type:"bytes",name:"callData"},{type:"uint256",name:"callGasLimit"},{type:"uint256",name:"verificationGasLimit"},{type:"uint256",name:"preVerificationGas"},{type:"uint256",name:"maxFeePerGas"},{type:"uint256",name:"maxPriorityFeePerGas"},{type:"bytes",name:"paymasterAndData"},{type:"uint48",name:"validAfter"},{type:"uint48",name:"validUntil"},{type:"address",name:"entryPoint"}]},P={SafeOp:[{type:"address",name:"safe"},{type:"uint256",name:"nonce"},{type:"bytes",name:"initCode"},{type:"bytes",name:"callData"},{type:"uint128",name:"verificationGasLimit"},{type:"uint128",name:"callGasLimit"},{type:"uint256",name:"preVerificationGas"},{type:"uint128",name:"maxPriorityFeePerGas"},{type:"uint128",name:"maxFeePerGas"},{type:"bytes",name:"paymasterAndData"},{type:"uint48",name:"validAfter"},{type:"uint48",name:"validUntil"},{type:"address",name:"entryPoint"}]},U="MerkleTreeRoot",R={MerkleTreeRoot:[{type:"bytes32",name:"merkleTreeRoot"}]},C="0x0000000000000000000000000000000000000100";var L,v,x;!function(e){e[e.Call=0]="Call",e[e.Delegate=1]="Delegate"}(L||(L={})),function(e){e[e.Slow=1]="Slow",e[e.Medium=1.2]="Medium",e[e.Fast=1.5]="Fast"}(v||(v={})),function(e){e.Mainnet="v2",e.ZkMainnet="zkevm",e.Amoy="amoy",e.Cardona="cardona"}(x||(x={}));const I={"-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"};class O extends Error{constructor(e,t,a={}){const{cause:n,errno:r,context:i}=a;super(t,{cause:n}),this.code=void 0,this.context=void 0,this.errno=void 0,this.name=this.constructor.name,this.code=e,this.errno=r,this.context=i}stringify(){return JSON.stringify(this,["name","code","message","cause","errno","context"])}}function G(e){if(e instanceof Error)return e;let 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}`)}function M(e,n){const r=t.defaultAbiCoder().encode(["(bytes32,bytes32,bytes32,uint256,address)"],[["0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f","0x364da28a5c92bcc87fe97c8813a6c6b8a3a049b0ea0a328fcb0b4f0e00337586","0xc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6",e,n]]);return a(r)}function V(e,n,r){let i;const s=t.defaultAbiCoder();let o;if(n.toLowerCase()==D.toLowerCase()){i=a(function(e){const n=[e.sender,e.nonce,a(e.initCode),a(e.callData),e.callGasLimit,e.verificationGasLimit,e.preVerificationGas,e.maxFeePerGas,e.maxPriorityFeePerGas,a(e.paymasterAndData)];return t.defaultAbiCoder().encode(["address","uint256","bytes32","bytes32","uint256","uint256","uint256","uint256","uint256","bytes32"],n)}(e));const l=s.encode(["bytes32","address","uint256"],[i,n,r]);o=a(l)}else if(n.toLowerCase()==S.toLowerCase()){i=a(function(e){const n=t.defaultAbiCoder();let r="0x";null!=e.factory&&(r=e.factory,null!=e.factoryData&&(r+=e.factoryData.slice(2)));const i="0x"+n.encode(["uint128"],[e.verificationGasLimit]).slice(34)+n.encode(["uint128"],[e.callGasLimit]).slice(34),s="0x"+n.encode(["uint128"],[e.maxPriorityFeePerGas]).slice(34)+n.encode(["uint128"],[e.maxFeePerGas]).slice(34);let o="0x";null!=e.paymaster&&(o=e.paymaster,null!=e.paymasterVerificationGasLimit&&(o+=n.encode(["uint128"],[e.paymasterVerificationGasLimit]).slice(34)),null!=e.paymasterPostOpGasLimit&&(o+=n.encode(["uint128"],[e.paymasterPostOpGasLimit]).slice(34)),null!=e.paymasterData&&(o+=e.paymasterData.slice(2)));const l=[e.sender,e.nonce,a(r),a(e.callData),i,e.preVerificationGas,s,a(o)];return n.encode(["address","uint256","bytes32","bytes32","bytes32","uint256","bytes32","bytes32"],l)}(e));const l=s.encode(["bytes32","address","uint256"],[i,n,r]);o=a(l)}else if(n.toLowerCase()==y.toLowerCase()){i=a(function(e){return B(e,!1)}(e));const t=M(r,n);o=a("0x1901"+t.slice(2)+i.slice(2))}else{if(n.toLowerCase()!=g.toLowerCase())throw new RangeError("unsupported entrypoint address: "+n);{i=a(function(e){return B(e,!0)}(e));const t=M(r,n);o=a("0x1901"+t.slice(2)+i.slice(2))}}return o}function W(e){const t="22e325a297439656",n=e.split(t);return a(n.length>1?i(["bytes","bytes"],[n[0],"0x"+t]):e)}function B(e,n){const r=t.defaultAbiCoder();let i="0x";if(null!=e.factory){const t=e.eip7702Auth;i=null!=t&&null!=t.address?t.address:e.factory,null!=e.factoryData&&(i+=e.factoryData.slice(2))}const s="0x"+r.encode(["uint128"],[e.verificationGasLimit]).slice(34)+r.encode(["uint128"],[e.callGasLimit]).slice(34),o="0x"+r.encode(["uint128"],[e.maxPriorityFeePerGas]).slice(34)+r.encode(["uint128"],[e.maxFeePerGas]).slice(34);let l="0x";null!=e.paymaster&&(l=e.paymaster,null!=e.paymasterVerificationGasLimit&&(l+=r.encode(["uint128"],[e.paymasterVerificationGasLimit]).slice(34)),null!=e.paymasterPostOpGasLimit&&(l+=r.encode(["uint128"],[e.paymasterPostOpGasLimit]).slice(34)),null!=e.paymasterData&&(l+=e.paymasterData.slice(2)));const c=["0x29a0bca4af4be3421398da00295e58e6d7de38cb492214754cb6a47507dd6f8e",e.sender,e.nonce,a(i),a(e.callData),s,e.preVerificationGas,o,n?W(l):a(l)];return r.encode(["bytes32","address","uint256","bytes32","bytes32","bytes32","uint256","bytes32","bytes32"],c)}function N(e,a,n){return e+t.defaultAbiCoder().encode(a,n).slice(2)}async function H(t,a,n,r={"Content-Type":"application/json"},i="params"){const s=e.default||e,o={method:"POST",headers:r,body:JSON.stringify({method:a,[i]:n,id:(new Date).getTime(),jsonrpc:"2.0"},(e,t)=>"bigint"==typeof t?"0x"+t.toString(16):t),redirect:"follow"},l=await s(t,o),c=await l.json();if("result"in c)return c.result;if("simulation_results"in c)return c.simulation_results;{const e=c.error,a=String(e.code);throw new O(a in I?I[a]:"UNKNOWN_ERROR",e.message,{errno:e.code,context:{url:t,requestOptions:JSON.stringify(o)}})}}function k(e){return n(e).slice(0,10)}async function z(e,t,a,n=0){const r=[{from:"0x0000000000000000000000000000000000000000",to:t,data:N(k("getNonce(address,uint192)"),["address","uint192"],[a,n])},"latest"];try{const t=await H(e,"eth_call",r);if("string"!=typeof t)throw new O("BAD_DATA","getNonce returned ill formed data",{context:JSON.stringify(t)});try{return BigInt(t)}catch(e){const t=G(e);throw new O("BAD_DATA","getNonce returned ill formed data",{cause:t})}}catch(e){const t=G(e);throw new O("BAD_DATA","getNonce failed",{cause:t})}}async function Y(e,t=v.Medium){try{const a=new r(e),n=await a.getFeeData();let i,s;return null!=n.maxFeePerGas&&null!=n.maxPriorityFeePerGas?(i=BigInt(Math.ceil(Number(n.maxFeePerGas)*t)),s=BigInt(Math.ceil(Number(n.maxPriorityFeePerGas)*t))):null!=n.gasPrice?(i=BigInt(Math.ceil(Number(n.gasPrice)*t)),s=i):(i=BigInt(Math.ceil(1e9*t)),s=i),0n==i&&(i=1n),0n==s&&(s=1n),[i,s]}catch(e){const t=G(e);throw new O("BAD_DATA","fetching gas prices from node failed.",{cause:t})}}function X(e){return"initCode"in e?(e.callGasLimit+e.verificationGasLimit*("0x"!=e.paymasterAndData&&null!=e.paymasterAndData?3n:0n)+e.preVerificationGas)*e.maxFeePerGas:(e.verificationGasLimit+e.callGasLimit+(null!=(t=e.paymasterVerificationGasLimit)?t:0n)+(null!=(a=e.paymasterPostOpGasLimit)?a:0n)+e.preVerificationGas)*e.maxFeePerGas;var t,a}async function j(e,t,a){return(await J(e,t,a)).deposit}async function J(e,a,n){const r={from:"0x0000000000000000000000000000000000000000",to:n,data:N("0x5287ce12",["address"],[a])};try{const a=await K(e,r,"latest"),n=t.defaultAbiCoder().decode(["uint256","bool","uint112","uint32","uint48"],a);if(5!==n.length)throw new O("BAD_DATA","getDepositInfo returned ill formed data",{context:JSON.stringify(n)});try{return{deposit:BigInt(n[0]),staked:Boolean(n[1]),stake:BigInt(n[2]),unstakeDelaySec:BigInt(n[3]),withdrawTime:BigInt(n[4])}}catch(e){const t=G(e);throw new O("BAD_DATA","getDepositInfo returned ill formed data",{cause:t})}}catch(e){const t=G(e);throw new O("BAD_DATA","getDepositInfo failed",{cause:t})}}async function K(e,t,a,n){let r=[];r=null==n?[t,a]:[t,a,n];try{const t=await H(e,"eth_call",r);if("string"!=typeof t)throw new O("BAD_DATA","eth_call returned ill formed data",{context:JSON.stringify(t)});try{return t}catch(e){const t=G(e);throw new O("BAD_DATA","eth_call returned ill formed data",{cause:t})}}catch(e){const t=G(e);throw new O("BAD_DATA","eth_call failed",{cause:t})}}async function q(e,t,a){const n=[t,a];try{const t=await H(e,"eth_getCode",n);if("string"!=typeof t)throw new O("BAD_DATA","eth_getCode returned ill formed data",{context:JSON.stringify(t)});try{return t}catch(e){const t=G(e);throw new O("BAD_DATA","eth_getCode returned ill formed data",{cause:t})}}catch(e){const t=G(e);throw new O("BAD_DATA","eth_getCode failed",{cause:t})}}async function $(e,t,a=v.Medium){let n,r;if(null!=t)[n,r]=await async function(e,t=v.Medium){const a="https://gasstation.polygon.technology/"+e;try{const e=await fetch(a),n=await e.json();let r;r=t==v.Slow?n.safeLow:t==v.Medium?n.standard:n.fast;let i=BigInt(Math.ceil(1e9*Number(r.maxFee))),s=BigInt(Math.ceil(1e9*Number(r.maxPriorityFee)));return 0n==i&&(i=1n),0n==s&&(s=1n),[i,s]}catch(e){const t=G(e);throw new O("BAD_DATA","fetching gas prices from "+a+" failed.",{cause:t})}}(t,a);else{if(null==e)throw new O("BAD_DATA","providerRpc cant't be null if maxFeePerGas and maxPriorityFeePerGas are not overriden");[n,r]=await Y(e,a)}return[n,r]}const Z="0x04";function Q(e,t,n,r,i,c,d,u){if(e>=2**64)throw new RangeError("Invalid chainId.");if(t>=2**64)throw new RangeError("Invalid nonce.");if(42!=i.length)throw new RangeError("Invalid destination.");let f=[se(t),se(n),se(r),i,se(c),d,se(e),se(0n),se(0n)];const A=a(s(f)),h=new o(u).signingKey.sign(A);return f=[se(t),se(n),se(r),i,se(c),d,se(BigInt(h.yParity+2*Number(e)+35)),l(h.r),l(h.s)],s(f)}function ee(e,t,a,n){const r=ae(te(e,t,a),n);return{chainId:oe(e),address:t,nonce:oe(a),yParity:oe(BigInt(r.yParity)),r:oe(r.r),s:oe(r.s)}}function te(e,t,n){const r=[se(e),t,se(n)],i=s(r);return a("0x05"+i.slice(2))}function ae(e,t){const a=new o(t).signingKey.sign(e);return{yParity:a.yParity,r:BigInt(a.r),s:BigInt(a.s)}}function ne(e,t,a,n,r,i,o,l,c,d,u){const f=re(e,t,a,n,r,i,o,l,c,d),A=ie(e,t,a,n,r,i,o,l,c,d),h=ae(f,u),p=A.concat([se(BigInt(h.yParity)),se(h.r),se(h.s)]),m=s(p);return Z+m.slice(2)}function re(e,t,n,r,i,o,l,c,d,u){const f=ie(e,t,n,r,i,o,l,c,d,u);return a(Z+s(f).slice(2))}function ie(e,t,a,n,r,i,s,o,c,d){if(e>=2**64)throw new RangeError("Invalid chainId.");if(t>=2**64)throw new RangeError("Invalid nonce.");if(42!=i.length)throw new RangeError("Invalid destination.");const u=function(e){let t=[];for(const a of e){if(42!=a.address.length)throw new RangeError("Invalid authorization list address: "+a);const e=[se(a.chainId),a.address,se(a.nonce),se(BigInt(a.yParity)),se(a.r),se(a.s)];t.push(e)}return t}(d),f=function(e){let t=[];for(const[a,n]of e){if(42!=a.length)throw new RangeError("Invalid access list address: "+a);let e=[];for(const t of n){if(66!=t.length)throw new RangeError("Invalid access list storage: "+t);e.push(l(t))}t.push([l(a),e])}return t}(c);return[se(e),se(t),se(a),se(n),se(r),i,se(s),o,f,u]}function se(e){return l(c(e))}function oe(e){let t=e.toString(16);return t.length%2?"0x0"+t:"0x"+t}class le{constructor(e){this.rpcUrl=void 0,this.rpcUrl=e}async chainId(){try{const e=await H(this.rpcUrl,"eth_chainId",[]);if("string"==typeof e)return e;throw new O("BAD_DATA","bundler eth_chainId rpc call failed")}catch(e){const t=G(e);throw new O("BUNDLER_ERROR","bundler eth_chainId rpc call failed",{cause:t})}}async supportedEntryPoints(){try{return await H(this.rpcUrl,"eth_supportedEntryPoints",[])}catch(e){const t=G(e);throw new O("BUNDLER_ERROR","bundler eth_supportedEntryPoints rpc call failed",{cause:t})}}async estimateUserOperationGas(e,t,a){try{let n={};n=void 0===a?await H(this.rpcUrl,"eth_estimateUserOperationGas",[e,t]):await H(this.rpcUrl,"eth_estimateUserOperationGas",[e,t,a]);const r=n;return{callGasLimit:BigInt(r.callGasLimit),preVerificationGas:BigInt(r.preVerificationGas),verificationGasLimit:BigInt(r.verificationGasLimit)}}catch(e){const t=G(e);throw new O("BUNDLER_ERROR","bundler eth_estimateUserOperationGas rpc call failed",{cause:t})}}async sendUserOperation(e,t){try{return await H(this.rpcUrl,"eth_sendUserOperation",[e,t])}catch(e){const t=G(e);throw new O("BUNDLER_ERROR","bundler eth_sendUserOperation rpc call failed",{cause:t})}}async getUserOperationReceipt(e){try{const t=await H(this.rpcUrl,"eth_getUserOperationReceipt",[e]);if(null!=t){const e=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:e})}return null}catch(t){const a=G(t);throw new O("BUNDLER_ERROR","bundler eth_getUserOperationReceipt rpc call failed",{cause:a,context:{useroperationhash:e}})}}async getUserOperationByHash(e){try{const t=await H(this.rpcUrl,"eth_getUserOperationByHash",[e]);return null!=t?m({},t,{blockNumber:null==t.blockNumber?null:BigInt(t.blockNumber)}):null}catch(t){const a=G(t);throw new O("BUNDLER_ERROR","bundler eth_getUserOperationByHash rpc call failed",{cause:a,context:{useroperationhash:e}})}}}class ce{constructor(e,t,a){this.userOperationHash=void 0,this.bundler=void 0,this.entrypointAddress=void 0,this.bundler=t,this.userOperationHash=e,this.entrypointAddress=a}delay(e){return new Promise(t=>setTimeout(t,e))}async included(e=180,t=2){if(e<=0||t<=0)throw new RangeError("timeoutInSeconds and requestIntervalInSeconds should be bigger than zero");if(e<t)throw new RangeError("timeoutInSeconds can't be less than requestIntervalInSeconds");let a=0;for(;a<=e;){await this.delay(1e3*t);const e=await this.bundler.getUserOperationReceipt(this.userOperationHash);if(null!=e)return e;a+=t}throw new O("TIMEOUT","can't find useroperation",{context:this.userOperationHash})}}class de extends p{constructor(e,t,a){super(e),this.entrypointAddress=void 0,this.delegateeAddress=void 0,this.entrypointAddress=t,this.delegateeAddress=a}static createAccountCallData(e,t,a){return N(de.executorFunctionSelector,de.executorFunctionInputAbi,[e,t,a])}static createAccountCallDataSingleTransaction(e){var t,a;const n=null!=(t=e.value)?t:0,r=null!=(a=e.data)?a:"0x";return de.createAccountCallData(e.to,n,r)}static createAccountCallDataBatchTransactions(e){const t=[e.map(e=>[e.to,e.value,e.data])];return N(de.batchExecutorFunctionSelector,de.batchExecutorFunctionInputAbi,t)}async baseCreateUserOperation(e,t,a,n={}){var r,i,s,o,l,c,d,u,f,A;if(e.length<1)throw new RangeError("There should be at least one transaction");let h=null,p=null;if(null==n.nonce){if(null==t)throw new O("BAD_DATA","providerRpc cant't be null if nonce is not overriden");p=z(t,this.entrypointAddress,this.accountAddress)}else h=n.nonce;if("bigint"==typeof n.maxFeePerGas&&n.maxFeePerGas<0n)throw new RangeError("maxFeePerGas override can't be negative");if("bigint"==typeof n.maxPriorityFeePerGas&&n.maxPriorityFeePerGas<0n)throw new RangeError("maxPriorityFeePerGas override can't be negative");let E=w.maxFeePerGas,y=w.maxPriorityFeePerGas,S=null;null!=n.maxFeePerGas&&null!=n.maxPriorityFeePerGas||(S=$(t,n.polygonGasStation,n.gasLevel));let D=null,_=null,b=null;var T,F;if(null!=n.eip7702Auth&&(D=n.eip7702Auth.chainId,_=null!=(T=n.eip7702Auth.address)?T:this.delegateeAddress,b=null!=(F=n.eip7702Auth.nonce)?F:null),null!=n.eip7702Auth&&null==b){let e;if(null==t)throw new O("BAD_DATA","providerRpc cant't be null if eoaDelegatorNonce is not overriden");e=H(t,"eth_getTransactionCount",[this.accountAddress,"latest"]),null!=S&&null!=p?await Promise.all([e,p,S]).then(e=>{b=BigInt(e[0]),h=e[1],[E,y]=e[2]}):null!=S?await Promise.all([e,S]).then(e=>{b=BigInt(e[0]),[E,y]=e[1]}):null!=p?await Promise.all([e,p]).then(e=>{b=BigInt(e[0]),h=e[1]}):b=BigInt(await e)}else null!=S&&null!=p?await Promise.all([p,S]).then(e=>{h=e[0],[E,y]=e[1]}):null!=S?[E,y]=await S:null!=p&&(h=await p);if(E=null!=(r=n.maxFeePerGas)?r:BigInt(Math.floor(Number(E)*(((null!=(i=n.maxFeePerGasPercentageMultiplier)?i:0)+100)/100))),y=null!=(s=n.maxPriorityFeePerGas)?s:BigInt(Math.floor(Number(y)*(((null!=(o=n.maxPriorityFeePerGasPercentageMultiplier)?o:0)+100)/100))),null==h)throw new RangeError("failed to determine nonce");if(h<0n)throw new RangeError("nonce can't be negative");let P,U="0x";if(U=null==n.callData?1==e.length?de.createAccountCallDataSingleTransaction(e[0]):de.createAccountCallDataBatchTransactions(e):n.callData,null!=n.eip7702Auth){var R,C,L;const e=null!=(R=n.eip7702Auth.yParity)?R:"0x0";if("0x0"!=e&&"0x00"!=e&&"0x1"!=e&&"0x01"!=e)throw new O("BAD_DATA","invalide yParity value for eoaDelegatorSignature. must be '0x0' or '0x1'");const t={chainId:oe(D),address:_,nonce:oe(b),yParity:e,r:null!=(C=n.eip7702Auth.r)?C:"0x4277ba564d2c138823415df0ec8e8f97f30825056d54ec5128a8b29ec2dd81b2",s:null!=(L=n.eip7702Auth.s)?L:"0x1075a1bec7f59848cca899ece93075199cd2aabceb0654b9ae00b881a30044cd"};P=m({},w,{sender:this.accountAddress,nonce:h,callData:U,maxFeePerGas:E,maxPriorityFeePerGas:y,factory:"0x7702",factoryData:null,paymaster:null,paymasterVerificationGasLimit:null,paymasterPostOpGasLimit:null,paymasterData:null,eip7702Auth:t})}else P=m({},w,{sender:this.accountAddress,nonce:h,callData:U,maxFeePerGas:E,maxPriorityFeePerGas:y,factory:null,factoryData:null,paymaster:null,paymasterVerificationGasLimit:null,paymasterPostOpGasLimit:null,paymasterData:null,eip7702Auth:null});let v=w.preVerificationGas,x=w.verificationGasLimit,I=w.callGasLimit;if(null==n.preVerificationGas||null==n.verificationGasLimit||null==n.callGasLimit){const e=n.parallelPaymasterInitValues;if(null!=e){if(this.entrypointAddress!=g)throw new RangeError("parallelPaymasterInitValues only works with ep v0.9");P.paymaster=e.paymaster,P.paymasterVerificationGasLimit=e.paymasterVerificationGasLimit,P.paymasterPostOpGasLimit=e.paymasterPostOpGasLimit,P.paymasterData=e.paymasterData}if(null==a)throw new O("BAD_DATA","bundlerRpc cant't be null if preVerificationGas,verificationGasLimit and callGasLimit are not overriden");{var G;P.callGasLimit=0n,P.verificationGasLimit=0n,P.preVerificationGas=0n;const e=P.maxFeePerGas,t=P.maxPriorityFeePerGas;let r;P.maxFeePerGas=0n,P.maxPriorityFeePerGas=0n,r=m({},P),P.signature=null!=(G=n.dummySignature)?G:de.dummySignature,[v,x,I]=await this.baseEstimateUserOperationGas(r,a,{stateOverrideSet:n.state_override_set}),x+=55000n,P.maxFeePerGas=e,P.maxPriorityFeePerGas=t}}if("bigint"==typeof n.preVerificationGas&&n.preVerificationGas<0n)throw new RangeError("preVerificationGas override can't be negative");if("bigint"==typeof n.verificationGasLimit&&n.verificationGasLimit<0n)throw new RangeError("verificationGasLimit override can't be negative");if("bigint"==typeof n.callGasLimit&&n.callGasLimit<0n)throw new RangeError("callGasLimit override can't be negative");return P.preVerificationGas=null!=(l=n.preVerificationGas)?l:BigInt(Math.floor(Number(v)*(((null!=(c=n.preVerificationGasPercentageMultiplier)?c:0)+100)/100))),P.verificationGasLimit=null!=(d=n.verificationGasLimit)?d:BigInt(Math.floor(Number(x)*(((null!=(u=n.verificationGasLimitPercentageMultiplier)?u:0)+100)/100))),P.callGasLimit=null!=(f=n.callGasLimit)?f:BigInt(Math.floor(Number(I)*(((null!=(A=n.callGasLimitPercentageMultiplier)?A:0)+100)/100))),P}async baseEstimateUserOperationGas(e,t,a={}){var n;e.signature=null!=(n=a.dummySignature)?n:de.dummySignature;const r=new le(t),i=e.maxFeePerGas,s=e.maxPriorityFeePerGas;e.maxFeePerGas=0n,e.maxPriorityFeePerGas=0n;const o=await r.estimateUserOperationGas(e,this.entrypointAddress,a.stateOverrideSet);return e.maxFeePerGas=i,e.maxPriorityFeePerGas=s,[BigInt(o.preVerificationGas),BigInt(o.verificationGasLimit),BigInt(o.callGasLimit)]}baseSignUserOperation(e,t,a){const n=V(e,this.entrypointAddress,a);return new o(t).signingKey.sign(n).serialized}async baseSendUserOperation(e,t){const a=new le(t),n=await a.sendUserOperation(e,this.entrypointAddress);return new ce(n,a,this.entrypointAddress)}prependTokenPaymasterApproveToCallData(e,t,a,n){return de.prependTokenPaymasterApproveToCallDataStatic(e,t,a,n)}static prependTokenPaymasterApproveToCallDataStatic(e,a,n,r){const i={to:a,value:0n,data:N(k("approve(address,uint256)"),["address","uint256"],[n,r])},s=t.defaultAbiCoder();let o;if(e.startsWith(de.batchExecutorFunctionSelector))o=s.decode(de.batchExecutorFunctionInputAbi,"0x"+e.slice(10))[0].map(e=>({to:e[0],value:BigInt(e[1]),data:"string"!=typeof e[2]?(new TextDecoder).decode(e[2]):e[2]}));else{if(!e.startsWith(de.executorFunctionSelector))throw new O("BAD_DATA","Invalid calldata, should start with "+de.batchExecutorFunctionSelector+" or "+de.executorFunctionSelector,{context:{callData:e}});{const t=s.decode(de.executorFunctionInputAbi,"0x"+e.slice(10));o=[{to:t[0],value:BigInt(t[1]),data:"string"!=typeof t[2]?(new TextDecoder).decode(t[2]):t[2]}]}}return o.unshift(i),de.createAccountCallDataBatchTransactions(o)}}de.executorFunctionSelector="0xb61d27f6",de.executorFunctionInputAbi=["address","uint256","bytes"],de.batchExecutorFunctionSelector="0x34fcd5be",de.batchExecutorFunctionInputAbi=["(address,uint256,bytes)[]"],de.dummySignature="0xd2614025fc173b86704caf37b2fb447f7618101a0d31f5f304c777024cef38a060a29ee43fcf0c46f9107d4f670b8a85c2c017a1fe9e4af891f24f0be6ba5d671c";class ue extends de{constructor(e,t={}){var a,n;super(e,null!=(a=t.entrypointAddress)?a:y,null!=(n=t.delegateeAddress)?n:ue.DEFAULT_DELEGATEE_ADDRESS)}async createUserOperation(e,t,a,n={}){return this.baseCreateUserOperation(e,t,a,n)}async estimateUserOperationGas(e,t,a={}){return this.baseEstimateUserOperationGas(e,t,a)}signUserOperation(e,t,a){return this.baseSignUserOperation(e,t,a)}async sendUserOperation(e,t){return this.baseSendUserOperation(e,t)}}ue.DEFAULT_DELEGATEE_ADDRESS="0xe6Cae83BdE06E4c305530e199D7217f42808555B";class fe extends de{constructor(e,t={}){var a,n;super(e,null!=(a=t.entrypointAddress)?a:g,null!=(n=t.delegateeAddress)?n:fe.DEFAULT_DELEGATEE_ADDRESS)}async createUserOperation(e,t,a,n={}){return this.baseCreateUserOperation(e,t,a,n)}async estimateUserOperationGas(e,t,a={}){return this.baseEstimateUserOperationGas(e,t,a)}signUserOperation(e,t,a){return this.baseSignUserOperation(e,t,a)}async sendUserOperation(e,t){return this.baseSendUserOperation(e,t)}}async function Ae(t,a,n,r){const i="https://api.tenderly.co/api/v1/account/"+t+"/project/"+a+"/simulations/"+r+"/share",s=e.default||e,o={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json","X-Access-Key":n},redirect:"follow"},l=(await s(i,o)).status;if(204!=l)throw new O("BAD_DATA","tenderly share simulation failed.",{context:{tenderlyAccountSlug:t,tenderlyProjectSlug:a,tenderlyAccessKey:n,tenderlySimulationId:r,status:l}})}async function he(e,t,a,n,r,i,s=null,o){const l=await pe(e,t,a,n,r,i,s,o);return await Ae(e,t,a,l.simulation.id),{simulation:l,simulationShareLink:"https://dashboard.tenderly.co/shared/simulation/"+l.simulation.id}}async function pe(e,a,n,r,i,s,o=null,l){const c=i.toLowerCase();let d=null;const u=t.defaultAbiCoder(),f="initCode"in s;if(f!==("0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789"==c))throw new RangeError("UserOperation version does not match entrypoint.");if(f)d="0x1fad948c"+u.encode(["(address,uint256,bytes,bytes,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[]","address"],[[[s.sender,s.nonce,s.initCode,s.callData,s.callGasLimit,s.verificationGasLimit,s.preVerificationGas,s.maxFeePerGas,s.maxPriorityFeePerGas,s.paymasterAndData,s.signature]],"0x1000000000000000000000000000000000000000"]).slice(2);else{let e="0x";null!=s.factory&&(e=s.factory,null!=s.factoryData&&(e+=s.factoryData.slice(2)));const t="0x"+u.encode(["uint128"],[s.verificationGasLimit]).slice(34)+u.encode(["uint128"],[s.callGasLimit]).slice(34),a="0x"+u.encode(["uint128"],[s.maxPriorityFeePerGas]).slice(34)+u.encode(["uint128"],[s.maxFeePerGas]).slice(34);let n="0x";null!=s.paymaster&&(n=s.paymaster,null!=s.paymasterVerificationGasLimit&&(n+=u.encode(["uint128"],[s.paymasterVerificationGasLimit]).slice(34)),null!=s.paymasterPostOpGasLimit&&(n+=u.encode(["uint128"],[s.paymasterPostOpGasLimit]).slice(34)),null!=s.paymasterData&&(n+=s.paymasterData.slice(2)));const r=u.encode(["(address,uint256,bytes,bytes,bytes32,uint256,bytes32,bytes,bytes)[]","address"],[[[s.sender,s.nonce,e,s.callData,t,s.preVerificationGas,a,n,s.signature]],"0x1000000000000000000000000000000000000000"]);if("0x0000000071727de22e5e9d8baf0edac6f37da032"!=c&&"0x4337084d9e255ff0702461cf8895ce9e3b5ff108"!=c&&"0x433709009b8330fda32311df1c2afa402ed8d009"!=c)throw new RangeError("Invalid entrypoint.");d="0x765e827f"+r.slice(2)}if(!f&&"0x7702"===s.factory){const e=s.eip7702Auth;if(null!=e&&null!=e.address){const t="0xef0100"+e.address.toLowerCase().replace("0x",""),a=s.sender.toLowerCase();(l=l?m({},l):{})[a]=m({},l[a]||{},{code:t})}}return(await Se(e,a,n,[{chainId:r,blockNumber:o,from:"0x1000000000000000000000000000000000000000",to:i,data:d,stateOverrides:l}]))[0]}async function me(e,t,a,n,r,i,s=null,o){const l=await Ee(e,t,a,n,r,i,s,o),c=l.map(e=>e.simulation.id);await Promise.all(c.map(n=>Ae(e,t,a,n)));const d=c.map(e=>"https://dashboard.tenderly.co/shared/simulation/"+e);if(1==d.length)return{simulation:l,callDataSimulationShareLink:d[0]};if(2==d.length)return{simulation:l,accountDeploymentSimulationShareLink:d[0],callDataSimulationShareLink:d[1]};throw new O("BAD_DATA","invalid number of simulations retuned",{context:JSON.stringify(l,(e,t)=>"bigint"==typeof t?"0x"+t.toString(16):t)})}async function Ee(e,a,n,r,i,s,o=null,l){let c=null,d=null;if("initCode"in s!=("0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789"==i.toLowerCase()))throw new RangeError("UserOperation version does not match entrypoint.");let u=s.callData;if("initCode"in s)null!=s.initCode&&s.initCode.length>2&&(c=s.initCode.slice(0,22),d=s.initCode.slice(22));else{c=s.factory,d=s.factoryData,"0x7702"===c&&(c=null,d=null);const e="0x8dd7712f";if(u.toLowerCase().startsWith(e)){const a=t.defaultAbiCoder();let n="0x";null!=s.factory&&(n=s.factory,null!=s.factoryData&&(n+=s.factoryData.slice(2)));const o="0x"+a.encode(["uint128"],[s.verificationGasLimit]).slice(34)+a.encode(["uint128"],[s.callGasLimit]).slice(34),l="0x"+a.encode(["uint128"],[s.maxPriorityFeePerGas]).slice(34)+a.encode(["uint128"],[s.maxFeePerGas]).slice(34);let c="0x";null!=s.paymaster&&(c=s.paymaster,null!=s.paymasterVerificationGasLimit&&(c+=a.encode(["uint128"],[s.paymasterVerificationGasLimit]).slice(34)),null!=s.paymasterPostOpGasLimit&&(c+=a.encode(["uint128"],[s.paymasterPostOpGasLimit]).slice(34)),null!=s.paymasterData&&(c+=s.paymasterData.slice(2)));const d=V(s,i,r);u=e+a.encode(["(address,uint256,bytes,bytes,bytes32,uint256,bytes32,bytes,bytes)","bytes32"],[[s.sender,s.nonce,n,s.callData,o,s.preVerificationGas,l,c,s.signature],d]).slice(2)}}return await ye(e,a,n,r,i,s.sender,u,c,d,o,l)}async function ge(e,t,a,n,r,i,s,o=null,l=null,c=null,d){const u=await ye(e,t,a,n,r,i,s,o,l,c,d),f=u.map(e=>e.simulation.id);await Promise.all(f.map(n=>Ae(e,t,a,n)));const A=f.map(e=>"https://dashboard.tenderly.co/shared/simulation/"+e);if(1==A.length)return{simulation:u,callDataSimulationShareLink:A[0]};if(2==A.length)return{simulation:u,accountDeploymentSimulationShareLink:A[0],callDataSimulationShareLink:A[1]};throw new O("BAD_DATA","invalid number of simulations retuned",{context:JSON.stringify(u,(e,t)=>"bigint"==typeof t?"0x"+t.toString(16):t)})}async function ye(e,t,a,n,r,i,s,o=null,l=null,c=null,d){const u=[],f=r.toLowerCase();let A;if("0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789"==f)A="0x7fc98430eaedbb6070b35b39d798725049088348";else if("0x0000000071727de22e5e9d8baf0edac6f37da032"==f)A="0xefc2c1444ebcc4db75e7613d20c6a62ff67a167c";else if("0x4337084d9e255ff0702461cf8895ce9e3b5ff108"==f)A="0x449ed7c3e6fee6a97311d4b55475df59c44add33";else{if("0x433709009b8330fda32311df1c2afa402ed8d009"!=f)throw new RangeError(`Invalid entrypoint: ${r}`);A="0x0A630a99Df908A81115A3022927Be82f9299987e"}if(null==o&&null!=l||null!=o&&null==l)throw new RangeError("Invalid factory and factoryData");null!=o&&null!=l&&u.push({chainId:n,blockNumber:c,from:A,to:o,data:l,stateOverrides:d}),u.push({chainId:n,blockNumber:c,from:r,to:i,data:s,stateOverrides:d});const h=await Se(e,t,a,u);for(const e of h)if(""==e.simulation.id)throw new O("TENDERLY_SIMULATION_ERROR","tenderly simulation failed",{context:JSON.stringify(h,(e,t)=>"bigint"==typeof t?"0x"+t.toString(16):t)});return h}async function Se(e,t,a,n){const r="https://api.tenderly.co/api/v1/account/"+e+"/project/"+t+"/simulate-bundle",i=n.map(e=>{var t,a,n;const r={network_id:e.chainId.toString(),save:null==(t=e.save)||t,save_if_fails:null==(a=e.saveIfFails)||a,from:e.from,to:e.to,input:e.data,simulation_type:null!=(n=e.simulationType)?n:"full"};if(null!=e.blockNumber&&(r.block_number=e.blockNumber),null!=e.gas&&(r.gas=e.gas),null!=e.gasPrice&&(r.gas_price=e.gasPrice),null!=e.value&&(r.value=e.value),null!=e.stateOverrides){const t=e.stateOverrides;for(const e in t)for(const a in t[e]){if("balance"!=a&&"code"!=a&&"storage"!=a&&"stateDiff"!=a)throw new RangeError(`Invalide stateOverrides key: ${a}.`);if("storage"in t[e]&&"stateDiff"in t[e])throw new RangeError("can't set both storage and stateDiff for stateOverrides");"stateDiff"in t[e]&&(t[e].storage=t[e].stateDiff,delete t[e].stateDiff)}r.state_objects=t}return null!=e.transactionIndex&&(r.transaction_index=e.transactionIndex),null!=e.estimateGas&&(r.estimate_gas=e.estimateGas),null!=e.generateAccessList&&(r.generate_access_list=e.generateAccessList),null!=e.accessList&&(r.access_list=e.accessList),r}),s={Accept:"application/json","Content-Type":"application/json","X-Access-Key":a};return await H(r,"tenderly_simulateBundle",i,s,"simulations")}var De;fe.DEFAULT_DELEGATEE_ADDRESS="0xa46cc63eBF4Bd77888AA327837d20b23A63a56B5",function(e){e.executeUserOpWithErrorString="0x541d63c8",e.executeUserOp="0x7bb37428"}(De||(De={}));const _e={signer:"0xfD90FAd33ee8b58f32c00aceEad1358e4AFC23f9",signature:"0x47003599ffa7e9198f321afa774e34a12a959844efd6363b88896e9c24ed33cf4e1be876ef123a3c4467e7d451511434039539699f2baa2f44955fa3d1c1c6d81c",isContractSignature:!1},be={signer:"0xfD90FAd33ee8b58f32c00aceEad1358e4AFC23f9",signature:"0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e06c92f0ac5c4ef9e74721c23d80a9fc12f259ca84afb160f0890483539b9e6080d824c0e6c795157ad5d1ee5eff1ceeb3031009a595f9360919b83dd411c5a78d0000000000000000000000000000000000000000000000000000000000000025a24f744b28d73f066bf3203d145765a7bc735e6328168c8b03e476da3ad0d8fe0400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001e226f726967696e223a2268747470733a2f2f736166652e676c6f62616c220000",isContractSignature:!0};function we(e){return"0x"+e.map(e=>function(e){var t;const a=null!=(t=e.operation)?t:L.Call,n=l(e.data);return i(["uint8","address","uint256","uint256","bytes"],[a,e.to,e.value,n.length,n]).slice(2)}(e)).join("")}class Te{constructor(e,t,a){this.address=void 0,this.generatorFunctionSelector=void 0,this.generatorFunctionInputAbi=void 0,this.address=e,this.generatorFunctionSelector=t,this.generatorFunctionInputAbi=a}getFactoryGeneratorFunctionCallData(e){return N(this.generatorFunctionSelector,this.generatorFunctionInputAbi,e)}}class Fe extends Te{constructor(e=Fe.DEFAULT_FACTORY_ADDRESS){super(e,"0x1688f0b9",["address","bytes","uint256"])}}Fe.DEFAULT_FACTORY_ADDRESS="0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67";const Pe="SafeMessage",Ue={SafeMessage:[{type:"bytes",name:"message"}]};function Re(e,t,a){const n={message:d(a)};return{domain:{chainId:Number(t),verifyingContract:e},types:Ue,messageValue:n}}class Ce extends p{constructor(e,t,n,r={}){var i;if(super(e),this.isInitWebAuthn=void 0,this.x=null,this.y=null,this.safeAccountSingleton=void 0,this.entrypointAddress=void 0,this.safe4337ModuleAddress=void 0,this.factoryAddress=void 0,this.factoryData=void 0,this.onChainIdentifier=void 0,this.entrypointAddress=n,this.safe4337ModuleAddress=t,this.factoryAddress=null,this.factoryData=null,this.isInitWebAuthn=!1,null!=r.onChainIdentifierParams&&null!=r.onChainIdentifier)throw new RangeError("can't override both onChainIdentifier and onChainIdentifierParams");if(null!=r.onChainIdentifierParams)this.onChainIdentifier=function(e,t="Web",n="abstractionkit",r="0.2.38"){const i=a("0x"+Buffer.from(e,"utf8").toString("hex")).slice(-20),s=a("0x"+Buffer.from(t,"utf8").toString("hex")).slice(-3),o=a("0x"+Buffer.from(n,"utf8").toString("hex")).slice(-3),l=a("0x"+Buffer.from(r,"utf8").toString("hex")).slice(-3);return`5afe00${Buffer.from(i,"utf8").toString("hex")}${Buffer.from(s,"utf8").toString("hex")}${Buffer.from(o,"utf8").toString("hex")}${Buffer.from(l,"utf8").toString("hex")}`}(r.onChainIdentifierParams.project,r.onChainIdentifierParams.platform,r.onChainIdentifierParams.tool,r.onChainIdentifierParams.toolVersion);else if(null!=r.onChainIdentifier){let e=r.onChainIdentifier;if(e.startsWith("0x")&&(e=e.slice(2)),64!=e.length)throw new RangeError("onChainIdentifier length must be 64.");this.onChainIdentifier=e}else this.onChainIdentifier=null;this.safeAccountSingleton=null!=(i=r.safeAccountSingleton)?i:b}static createProxyAddress(e,t={}){var n,r,s;const o=null!=(n=t.c2Nonce)?n:0n;if(o<0n)throw new RangeError("c2Nonce can't be negative");const l=null!=(r=t.safeFactoryAddress)?r:Fe.DEFAULT_FACTORY_ADDRESS,c=null!=(s=t.singletonInitHash)?s:b.singletonInitHash,d=a(i(["bytes32","uint256"],[a(e),o])),A=u(["bytes1","address","bytes32","bytes32"],["0xff",l,d,c]).slice(-40);return f("0x"+A)}static createAccountCallDataSingleTransaction(e,t={}){var a,n,r,i;const s=null!=(a=e.value)?a:0,o=null!=(n=e.data)?n:"0x",l=null!=(r=e.operation)?r:L.Call,c=null!=(i=t.safeModuleExecutorFunctionSelector)?i:Ce.DEFAULT_EXECUTOR_FUCNTION_SELECTOR;return Ce.createAccountCallData(e.to,s,o,l,{safeModuleExecutorFunctionSelector:c})}static createAccountCallDataBatchTransactions(e,t={}){var a,n;if(e.length<1)throw new RangeError("There should be at least one metaTransaction");const r=null!=(a=t.safeModuleExecutorFunctionSelector)?a:Ce.DEFAULT_EXECUTOR_FUCNTION_SELECTOR,i=null!=(n=t.multisendContractAddress)?n:Ce.DEFAULT_MULTISEND_CONTRACT_ADDRESS,s=N("0x8d80ff0a",["bytes"],[we(e)]);return Ce.createAccountCallData(i,0n,s,L.Delegate,{safeModuleExecutorFunctionSelector:r})}static createAccountCallData(e,t,a,n,r={}){var i;return N(null!=(i=r.safeModuleExecutorFunctionSelector)?i:Ce.DEFAULT_EXECUTOR_FUCNTION_SELECTOR,Ce.executorFunctionInputAbi,[e,t,a,n])}static decodeAccountCallData(e){let a=null;if(e.startsWith(De.executeUserOpWithErrorString)?a=De.executeUserOpWithErrorString:e.startsWith(De.executeUserOp)&&(a=De.executeUserOp),null!=a){const n=t.defaultAbiCoder(),r="0x"+e.slice(10),i=n.decode(["address","uint256","bytes","uint8"],r);let s;return s="string"!=typeof i[2]?(new TextDecoder).decode(i[2]):i[2],[{to:i[0],value:BigInt(i[1]),data:s,operation:Number(i[3])},a]}throw new O("BAD_DATA","Invalid calldata, should start with "+De.executeUserOpWithErrorString+" or "+De.executeUserOp,{context:{callData:e}})}static prependTokenPaymasterApproveToCallDataStatic(e,a,n,r,i={}){var s;const o=null!=(s=i.multisendContractAddress)?s:Ce.DEFAULT_MULTISEND_CONTRACT_ADDRESS,[l,c]=Ce.decodeAccountCallData(e),d=we([{to:a,value:0n,data:N(k("approve(address,uint256)"),["address","uint256"],[n,r]),operation:L.Call}]);let u="";const f="0x8d80ff0a";if(l.data.startsWith(f)){const e=function(e){return t.defaultAbiCoder().decode(["bytes"],"0x"+e.slice(10))[0]}(l.data);u=e+d.slice(2)}else u=we([l])+d.slice(2);const A=N(f,["bytes"],[u]);return Ce.createAccountCallData(o,0n,A,L.Delegate,{safeModuleExecutorFunctionSelector:c})}static formatEip712SignaturesToUseroperationSignature(e,t,a={}){if(e.length!=t.length)throw new RangeError("signersAddresses and signatures arrays should be the same length");const n=[];return e.forEach((e,a)=>{n.push({signer:e.toLowerCase(),signature:t[a]})}),Ce.formatSignaturesToUseroperationSignature(n,{validAfter:a.validAfter,validUntil:a.validUntil,isMultiChainSignature:a.isMultiChainSignature,multiChainMerkleProof:a.merkleProof})}static getUserOperationEip712Hash(e,t,a={}){return"initCode"in e?Ce.getUserOperationEip712Hash_V6(e,t,a):a.entrypointAddress&&a.entrypointAddress.toLowerCase()===g.toLowerCase()?Ce.getUserOperationEip712Hash_V9(e,t,a):Ce.getUserOperationEip712Hash_V7(e,t,a)}static getUserOperationEip712Data(e,t,a){if("initCode"in e){const n=Ce.getUserOperationEip712Data_V6(e,t,a);return{domain:n.domain,types:n.types,messageValue:n.messageValue}}{let n;return n=null!=a&&a.entrypointAddress&&a.entrypointAddress.toLowerCase()===g.toLowerCase()?Ce.getUserOperationEip712Data_V9(e,t,a):Ce.getUserOperationEip712Data_V7(e,t,a),{domain:n.domain,types:n.types,messageValue:n.messageValue}}}static getUserOperationEip712Data_V6(e,t,a={}){var n,r,i,s;const o=null!=(n=a.validAfter)?n:0n,l=null!=(r=a.validUntil)?r:0n,c=null!=(i=a.entrypointAddress)?i:D,d=null!=(s=a.safe4337ModuleAddress)?s:"0xa581c4A4DB7175302464fF3C06380BC3270b4037",u={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:o,validUntil:l,entryPoint:c};return{domain:{chainId:Number(t),verifyingContract:d},types:F,messageValue:u}}static getUserOperationEip712Hash_V6(e,t,a={}){const n=Ce.getUserOperationEip712Data_V6(e,t,a);return A.hash(n.domain,n.types,n.messageValue)}static baseGetUserOperationEip712DataV7V8V9(e,a,n,r={}){var i,s,o;const l=null!=(i=r.validAfter)?i:0n,c=null!=(s=r.validUntil)?s:0n,d=null!=(o=r.safe4337ModuleAddress)?o:"0x75cf11467937ce3F2f357CE24ffc3DBF8fD5c226",u=t.defaultAbiCoder();let f="0x";null!=e.factory&&(f=e.factory,null!=e.factoryData&&(f+=e.factoryData.slice(2)));let A="0x";if(null!=e.paymaster&&(A=e.paymaster,null!=e.paymasterVerificationGasLimit&&(A+=u.encode(["uint128"],[e.paymasterVerificationGasLimit]).slice(34)),null!=e.paymasterPostOpGasLimit&&(A+=u.encode(["uint128"],[e.paymasterPostOpGasLimit]).slice(34)),null!=e.paymasterData)){const t="22e325a297439656";r.is_v9&&e.paymasterData.endsWith(t)?A+=t:A+=e.paymasterData.slice(2)}const h={safe:e.sender,nonce:e.nonce,initCode:f,callData:e.callData,verificationGasLimit:e.verificationGasLimit,callGasLimit:e.callGasLimit,preVerificationGas:e.preVerificationGas,maxPriorityFeePerGas:e.maxPriorityFeePerGas,maxFeePerGas:e.maxFeePerGas,paymasterAndData:A,validAfter:l,validUntil:c,entryPoint:n};return{domain:{chainId:Number(a),verifyingContract:d},types:P,messageValue:h}}static getUserOperationEip712Data_V7(e,t,a={}){var n;return Ce.baseGetUserOperationEip712DataV7V8V9(e,t,null!=(n=a.entrypointAddress)?n:S,a)}static getUserOperationEip712Hash_V7(e,t,a={}){const n=Ce.getUserOperationEip712Data_V7(e,t,a);return A.hash(n.domain,n.types,n.messageValue)}static getUserOperationEip712Data_V9(e,t,a={}){var n,r;const i=null!=(n=a.safe4337ModuleAddress)?n:"0xee8005d7e79f9a6829ea61A81Fc2A85055fB2a42";return Ce.baseGetUserOperationEip712DataV7V8V9(e,t,null!=(r=a.entrypointAddress)?r:g,m({},a,{safe4337ModuleAddress:i,is_v9:!0}))}static getUserOperationEip712Hash_V9(e,t,a={}){const n=Ce.getUserOperationEip712Data_V9(e,t,a);return A.hash(n.domain,n.types,n.messageValue)}static formatEip712SingleSignatureToUseroperationSignature(e,t={}){return Ce.formatSignaturesToUseroperationSignature([{signer:"0x0000000000000000000000000000000000000000",signature:e}],t)}async sendUserOperation(e,t){const a=new le(t),n=await a.sendUserOperation(e,this.entrypointAddress);return new ce(n,a,this.entrypointAddress)}static createAccountAddressAndFactoryAddressAndData(e,t,a,n){var r,i,s,o,l,c,d,u;if(e.length<1)throw new RangeError("There should be at least one owner");const f=Ce.createBaseInitializerCallData(e,null!=(r=t.threshold)?r:1,a,n,null!=(i=t.multisendContractAddress)?i:Ce.DEFAULT_MULTISEND_CONTRACT_ADDRESS,null!=(s=t.webAuthnSharedSigner)?s:Ce.DEFAULT_WEB_AUTHN_SHARED_SIGNER,null!=(o=t.eip7212WebAuthnPrecompileVerifierForSharedSigner)?o:Ce.DEFAULT_WEB_AUTHN_PRECOMPILE,null!=(l=t.eip7212WebAuthnContractVerifierForSharedSigner)?l:Ce.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER);let A;A=null!=t.safeAccountFactoryAddress?new Fe(t.safeAccountFactoryAddress):new Fe;const h=null!=(c=t.safeAccountSingleton)?c:b,p=this.createProxyAddress(f,{c2Nonce:null!=(d=t.c2Nonce)?d:0n,safeFactoryAddress:A.address,singletonInitHash:h.singletonInitHash}),m=[h.singletonAddress,f,null!=(u=t.c2Nonce)?u:0n],E=A.getFactoryGeneratorFunctionCallData(m);return[p,A.address,E]}static createBaseInitializerCallData(e,t,a,n,r=Ce.DEFAULT_MULTISEND_CONTRACT_ADDRESS,i=Ce.DEFAULT_WEB_AUTHN_SHARED_SIGNER,s=Ce.DEFAULT_WEB_AUTHN_PRECOMPILE,o=Ce.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER){if(e.length<1)throw new RangeError("There should be at least one owner");if(t<1)throw new RangeError("threshold should be at least one");if(t>e.length)throw new RangeError("threshold can't be larger than number of owners");const l=N("0x8d0dc49f",["address[]"],[[a]]);let c,d=!1;const u=[];for(const t of e)"string"!=typeof t?d=!0:u.push(t);if(d){const d=[];d.push({to:n,value:0n,data:l,operation:L.Delegate});const u=[];let f=0;for(const t of e)if("string"!=typeof t){if(f>0)throw new RangeError("Only one WebAuthn owner can be set during initialization");const e=N("0x0dd9692f",["uint256","uint256","uint176"],[t.x,t.y,"0x"+s.slice(-4)+o.slice(2)]);d.push({to:i,value:0n,data:e,operation:L.Delegate}),u.push(i),f++}else u.push(t);c=[u,t,r,N("0x8d80ff0a",["bytes"],[we(d)]),a,E,0,E]}else c=[u,t,n,l,a,E,0,E];return N(Ce.initializerFunctionSelector,Ce.initializerFunctionInputAbi,c)}static createFactoryAddressAndData(e,t={},a,n){var r,i,s,o,l,c,d,u;if(e.length<1)throw new RangeError("There should be at least one owner");const f=null!=(r=t.threshold)?r:1,A=null!=(i=t.c2Nonce)?i:0;if(f<1)throw new RangeError("threshold should be at least one");if(f>e.length)throw new RangeError("threshold can't be larger than number of owners");if(A<0n)throw new RangeError("c2Nonce can't be negative");const h=Ce.createBaseInitializerCallData(e,null!=(s=t.threshold)?s:1,a,n,null!=(o=t.multisendContractAddress)?o:Ce.DEFAULT_MULTISEND_CONTRACT_ADDRESS,null!=(l=t.webAuthnSharedSigner)?l:Ce.DEFAULT_WEB_AUTHN_SHARED_SIGNER,null!=(c=t.eip7212WebAuthnPrecompileVerifierForSharedSigner)?c:Ce.DEFAULT_WEB_AUTHN_PRECOMPILE,null!=(d=t.eip7212WebAuthnContractVerifierForSharedSigner)?d:Ce.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER);let p;p=null!=t.safeAccountFactoryAddress?new Fe(t.safeAccountFactoryAddress):new Fe;const m=null!=(u=t.safeAccountSingleton)?u:b,E=p.getFactoryGeneratorFunctionCallData([m.singletonAddress,h,A]);return[p.address,E]}prependTokenPaymasterApproveToCallData(e,t,a,n,r={}){var i;const s=null!=(i=r.multisendContractAddress)?i:Ce.DEFAULT_MULTISEND_CONTRACT_ADDRESS;return Ce.prependTokenPaymasterApproveToCallDataStatic(e,t,a,n,{multisendContractAddress:s})}async baseEstimateUserOperationGas(e,t,a={}){const n=0xffffffffffffn,r=0xffffffffffffn;if(null!=a.dummySignerSignaturePairs){if(null!=a.expectedSigners)throw new RangeError("Can't use both dummySignerSignaturePairs and expectedSigners overrides.");if(a.dummySignerSignaturePairs.length<1)throw new RangeError("Number of dummy signers signature pairs can't be less than 1");e.signature=Ce.formatSignaturesToUseroperationSignature(a.dummySignerSignaturePairs,{validAfter:n,validUntil:r,isMultiChainSignature:a.isMultiChainSignature})}else if(null!=a.expectedSigners){let t;t="initCode"in e?e.initCode:e.factory;const i=Ce.createDummySignerSignaturePairForExpectedSigners(a.expectedSigners,{isInit:null!=t&&"0x"!=t,webAuthnSharedSigner:a.webAuthnSharedSigner,eip7212WebAuthnPrecompileVerifier:a.eip7212WebAuthnPrecompileVerifier,eip7212WebAuthnContractVerifier:a.eip7212WebAuthnContractVerifier,webAuthnSignerFactory:a.webAuthnSignerFactory,webAuthnSignerSingleton:a.webAuthnSignerSingleton,webAuthnSignerProxyCreationCode:a.webAuthnSignerProxyCreationCode,validAfter:n,validUntil:r});e.signature=Ce.formatSignaturesToUseroperationSignature(i,{validAfter:n,validUntil:r,isMultiChainSignature:a.isMultiChainSignature})}else e.signature.length<3&&(e.signature=Ce.formatSignaturesToUseroperationSignature([_e],{validAfter:n,validUntil:r,isMultiChainSignature:a.isMultiChainSignature}));const i=new le(t),s=e.maxFeePerGas,o=e.maxPriorityFeePerGas;e.maxFeePerGas=0n,e.maxPriorityFeePerGas=0n;const l=await i.estimateUserOperationGas(e,this.entrypointAddress,a.stateOverrideSet);e.maxFeePerGas=s,e.maxPriorityFeePerGas=o;const c=BigInt(l.preVerificationGas);let d;return d=null!=a.dummySignerSignaturePairs?BigInt(l.verificationGasLimit)+55000n*BigInt(a.dummySignerSignaturePairs.length):BigInt(l.verificationGasLimit),[c,d,BigInt(l.callGasLimit)]}async createBaseUserOperationAndFactoryAddressAndFactoryData(e,t,a,n,r={}){var i,s,o,l,c,d,u,f,A,h,p,E,y,S,D,_,b,T;if(e.length<1)throw new RangeError("There should be at least one transaction");const F=null!=(i=r.webAuthnSharedSigner)?i:Ce.DEFAULT_WEB_AUTHN_SHARED_SIGNER,P=null!=(s=r.safeModuleExecutorFunctionSelector)?s:Ce.DEFAULT_EXECUTOR_FUCNTION_SELECTOR,U=null!=(o=r.multisendContractAddress)?o:Ce.DEFAULT_MULTISEND_CONTRACT_ADDRESS;let R=null,C=null;if(null==r.nonce){if(null==a)throw new O("BAD_DATA","providerRpc cant't be null if nonce is not overriden");C=z(a,this.entrypointAddress,this.accountAddress)}else R=r.nonce;if("bigint"==typeof r.maxFeePerGas&&r.maxFeePerGas<0n)throw new RangeError("maxFeePerGas overrid can't be negative");if("bigint"==typeof r.maxPriorityFeePerGas&&r.maxPriorityFeePerGas<0n)throw new RangeError("maxPriorityFeePerGas overrid can't be negative");let L=w.maxFeePerGas,v=w.maxPriorityFeePerGas,x=null;null!=r.maxFeePerGas&&null!=r.maxPriorityFeePerGas||(x=$(a,r.polygonGasStation,r.gasLevel)),null!=x&&null!=C?await Promise.all([C,x]).then(e=>{R=e[0],[L,v]=e[1]}):null!=x?[L,v]=await x:null!=C&&(R=await C),L=null!=(l=r.maxFeePerGas)?l:L*BigInt((null!=(c=r.maxFeePerGasPercentageMultiplier)?c:0)+100)/100n,v=null!=(d=r.maxPriorityFeePerGas)?d:v*BigInt((null!=(u=r.maxPriorityFeePerGasPercentageMultiplier)?u:0)+100)/100n;const I=null!=(f=r.eip7212WebAuthnPrecompileVerifier)?f:Ce.DEFAULT_WEB_AUTHN_PRECOMPILE,G=null!=(A=r.eip7212WebAuthnContractVerifier)?A:Ce.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER,M=null!=(h=r.webAuthnSignerFactory)?h:Ce.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,V=null!=(p=r.webAuthnSignerSingleton)?p:Ce.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON,W=null!=(E=r.webAuthnSignerProxyCreationCode)?E:Ce.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE;let B=this.factoryAddress,H=this.factoryData;if(null==R)throw new RangeError("failed to determine nonce");if(R<0n)throw new RangeError("nonce can't be negative");if(R>0n)B=null,H=null;else if(this.isInitWebAuthn){if(null==this.x||null==this.y)throw new RangeError("Invalide account initialization with Webauthnn signer.Webauthnn signer publickey can be null!!");const t=Ce.createDeployWebAuthnVerifierMetaTransaction(this.x,this.y,{eip7212WebAuthnPrecompileVerifier:I,eip7212WebAuthnContractVerifier:G,webAuthnSignerFactory:M}),a=N("0xe318b52b",["address","address","address"],["0x0000000000000000000000000000000000000001",F,Ce.createWebAuthnSignerVerifierAddress(this.x,this.y,{eip7212WebAuthnPrecompileVerifier:I,eip7212WebAuthnContractVerifier:G,webAuthnSignerFactory:M,webAuthnSignerSingleton:V,webAuthnSignerProxyCreationCode:W})]);e=[t,{to:this.accountAddress,value:0n,data:a}].concat(e)}let k="0x";k=null==r.callData?1==e.length?Ce.createAccountCallDataSingleTransaction(e[0],{safeModuleExecutorFunctionSelector:P}):Ce.createAccountCallDataBatchTransactions(e,{safeModuleExecutorFunctionSelector:P,multisendContractAddress:U}):r.callData,null!=this.onChainIdentifier&&(k+=this.onChainIdentifier);const Y=m({},w,{sender:this.accountAddress,nonce:R,callData:k,maxFeePerGas:L,maxPriorityFeePerGas:v});let X=w.preVerificationGas,j=w.verificationGasLimit,J=w.callGasLimit;if(null==r.preVerificationGas||null==r.verificationGasLimit||null==r.callGasLimit){if(null==n)throw new O("BAD_DATA","bundlerRpc cant't be null if preVerificationGas,verificationGasLimit and callGasLimit are not overriden");{Y.callGasLimit=0n,Y.verificationGasLimit=0n,Y.preVerificationGas=0n;const e=Y.maxFeePerGas,a=Y.maxPriorityFeePerGas;let i;if(Y.maxFeePerGas=0n,Y.maxPriorityFeePerGas=0n,t){let e="0x";null!=B&&(e=B,null!=H&&(e+=H.slice(2))),i=m({},Y,{initCode:e,paymasterAndData:"0x"})}else{i=m({},Y,{factory:B,factoryData:H,paymaster:null,paymasterVerificationGasLimit:null,paymasterPostOpGasLimit:null,paymasterData:null});const e=r.parallelPaymasterInitValues;if(null!=e){if("0x22e325a297439656"!=e.paymasterData)throw new RangeError("Invalid paymasterData override, the only valid value is 0x22e325a297439656.");if(this.entrypointAddress!=g)throw new RangeError("parallelPaymasterInitValues only works with ep v0.9");i.paymaster=e.paymaster,i.paymasterVerificationGasLimit=e.paymasterVerificationGasLimit,i.paymasterPostOpGasLimit=e.paymasterPostOpGasLimit,i.paymasterData=e.paymasterData}}const s=0xffffffffffffn,o=0xffffffffffffn;let l;if(null!=r.dummySignerSignaturePairs){if(null!=r.expectedSigners)throw new RangeError("Can't use both dummySignerSignaturePairs and expectedSigners overrides.");if(r.dummySignerSignaturePairs.length<1)throw new RangeError("Number of dummySignerSignaturePairs can't be less than 1");l=r.dummySignerSignaturePairs}else l=null==r.expectedSigners?[_e]:Ce.createDummySignerSignaturePairForExpectedSigners(r.expectedSigners,{isInit:null!=B&&"0x"!=B,webAuthnSharedSigner:F,eip7212WebAuthnPrecompileVerifier:I,eip7212WebAuthnContractVerifier:G,webAuthnSignerFactory:M,webAuthnSignerSingleton:V,webAuthnSignerProxyCreationCode:W,validAfter:s,validUntil:o});Y.signature=Ce.formatSignaturesToUseroperationSignature(l,{validAfter:s,validUntil:o,webAuthnSharedSigner:F,isMultiChainSignature:r.isMultiChainSignature}),[X,j,J]=await this.baseEstimateUserOperationGas(i,n,{stateOverrideSet:r.state_override_set,isMultiChainSignature:r.isMultiChainSignature}),j+=55000n*BigInt(l.length),Y.maxFeePerGas=e,Y.maxPriorityFeePerGas=a}}if("bigint"==typeof r.preVerificationGas&&r.preVerificationGas<0n)throw new RangeError("preVerificationGas overrid can't be negative");if("bigint"==typeof r.verificationGasLimit&&r.verificationGasLimit<0n)throw new RangeError("verificationGasLimit overrid can't be negative");if("bigint"==typeof r.callGasLimit&&r.callGasLimit<0n)throw new RangeError("callGasLimit overrid can't be negative");return Y.preVerificationGas=null!=(y=r.preVerificationGas)?y:X*BigInt((null!=(S=r.preVerificationGasPercentageMultiplier)?S:0)+100)/100n,Y.verificationGasLimit=null!=(D=r.verificationGasLimit)?D:j*BigInt((null!=(_=r.verificationGasLimitPercentageMultiplier)?_:0)+100)/100n,Y.callGasLimit=null!=(b=r.callGasLimit)?b:J*BigInt((null!=(T=r.callGasLimitPercentageMultiplier)?T:0)+100)/100n,[Y,B,H]}static baseSignSingleUserOperation(e,t,a,n,r,i={}){var s,l;const c=null!=(s=i.validAfter)?s:0n,d=null!=(l=i.validUntil)?l:0n;if(t.length<1)throw new RangeError("There should be at least one privateKey");if(a<0n)throw new RangeError("chainId can't be negative");if(c<0n)throw new RangeError("validAfter can't be negative");if(d<0n)throw new RangeError("validUntil can't be negative");const u=Ce.getUserOperationEip712Hash(e,a,{validAfter:c,validUntil:d,entrypointAddress:n,safe4337ModuleAddress:r}),f=[];for(const e of t){const t=new o(e),a=t.signingKey.sign(u).serialized;f.push({signer:t.address,signature:a})}return Ce.formatSignaturesToUseroperationSignature(f,{validAfter:c,validUntil:d,isMultiChainSignature:i.isMultiChainSignature})}static createWebAuthnSignerVerifierAddress(e,t,n={}){var r,s,o,l,c;const d=null!=(r=n.eip7212WebAuthnPrecompileVerifier)?r:Ce.DEFAULT_WEB_AUTHN_PRECOMPILE,f=null!=(s=n.eip7212WebAuthnContractVerifier)?s:Ce.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER,A=null!=(o=n.webAuthnSignerFactory)?o:Ce.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,h=null!=(l=n.webAuthnSignerSingleton)?l:Ce.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON;if(42!=d.length||d.slice(0,38)!=E.slice(0,38))throw new RangeError("Invalide precompile address. It should have the format 0x000000000000000000000000000000000000____");const p=a(i(["bytes","uint256","uint256","uint256","uint256"],[null!=(c=n.webAuthnSignerProxyCreationCode)?c:Ce.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE,h,e,t,"0x"+d.slice(-4)+f.slice(2)]));return"0x"+u(["bytes1","address","bytes32","bytes32"],["0xff",A,"0x0000000000000000000000000000000000000000000000000000000000000000",p]).slice(-40)}static formatSignaturesToUseroperationSignature(e,t={}){var a,n;const r=null!=(a=t.validAfter)?a:0n,s=null!=(n=t.validUntil)?n:0n,o=this.buildSignaturesFromSingerSignaturePairs(e,t);if(t.isMultiChainSignature){if(null!=t.multiChainMerkleProof){const e=t.multiChainMerkleProof.slice(2).length;if(e<128||e%64!=0)throw new RangeError("invalid multiChainMerkleProof length.");let a=(e/64-1).toString(16);return a=a.length%2==0?"0x"+a:"0x0"+a,i(["bytes1","uint48","uint48","bytes"],[a,r,s,t.multiChainMerkleProof+o.slice(2)])}return i(["bytes1","uint48","uint48","bytes"],["0x00",r,s,o])}return i(["uint48","uint48","bytes"],[r,s,o])}static getSignerLowerCaseAddress(e,t={}){if("string"==typeof e)return e.toLowerCase();{var a,n,r,i,s;const o=null!=(a=t.eip7212WebAuthnPrecompileVerifier)?a:Ce.DEFAULT_WEB_AUTHN_PRECOMPILE,l=null!=(n=t.eip7212WebAuthnContractVerifier)?n:Ce.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER,c=null!=(r=t.webAuthnSignerFactory)?r:Ce.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,d=null!=(i=t.webAuthnSignerSingleton)?i:Ce.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON,u=null!=(s=t.webAuthnSignerProxyCreationCode)?s:Ce.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE;return Ce.createWebAuthnSignerVerifierAddress(e.x,e.y,{eip7212WebAuthnPrecompileVerifier:o,eip7212WebAuthnContractVerifier:l,webAuthnSignerFactory:c,webAuthnSignerSingleton:d,webAuthnSignerProxyCreationCode:u}).toLowerCase()}}static sortSignatures(e,t={}){e.sort((e,a)=>Ce.getSignerLowerCaseAddress(e.signer,t).localeCompare(Ce.getSignerLowerCaseAddress(a.signer,t)))}static buildSignaturesFromSingerSignaturePairs(e,t={}){Ce.sortSignatures(e,t);const a=65*e.length,{segments:n}=e.reduce(({segments:e,offset:n},{signer:r,signature:i,isContractSignature:s})=>{if(s=s||"string"!=typeof r){if("string"!=typeof r){if(null==t.isInit)throw new RangeError("Must define isInit parameter when using WebAuthn");if(t.isInit){var o;r=null!=(o=t.webAuthnSharedSigner)?o:Ce.DEFAULT_WEB_AUTHN_SHARED_SIGNER}else{var l,c,d,u,f;const e=null!=(l=t.eip7212WebAuthnPrecompileVerifier)?l:Ce.DEFAULT_WEB_AUTHN_PRECOMPILE,a=null!=(c=t.eip7212WebAuthnContractVerifier)?c:Ce.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER,n=null!=(d=t.webAuthnSignerFactory)?d:Ce.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,i=null!=(u=t.webAuthnSignerSingleton)?u:Ce.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON,s=null!=(f=t.webAuthnSignerProxyCreationCode)?f:Ce.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE;r=Ce.createWebAuthnSignerVerifierAddress(r.x,r.y,{eip7212WebAuthnPrecompileVerifier:e,eip7212WebAuthnContractVerifier:a,webAuthnSignerFactory:n,webAuthnSignerSingleton:i,webAuthnSignerProxyCreationCode:s})}}return{segments:[...e,h.solidityPacked(["uint256","uint256","uint8"],[r,a+n,0])],offset:n+32+h.dataLength(i)}}return{segments:[...e,h.solidityPacked(["bytes"],[i])],offset:n}},{segments:[],offset:0});return h.concat([...n,...e.map(({signer:e,signature:t,isContractSignature:a})=>(a=a||"string"!=typeof e)?h.solidityPacked(["uint256","bytes"],[h.dataLength(t),t]):"0x")])}static createWebAuthnSignature(e){return h.AbiCoder.defaultAbiCoder().encode(["bytes","bytes","uint256[2]"],[new Uint8Array(e.authenticatorData),e.clientDataFields,e.rs])}async createSwapOwnerMetaTransactions(e,t,a,n={}){var r;let i,s,o=null;const l=null!=(r=n.webAuthnSignerProxyCreationCode)?r:Ce.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE;"string"!=typeof t?(i=Ce.createWebAuthnSignerVerifierAddress(t.x,t.y,{eip7212WebAuthnPrecompileVerifier:n.eip7212WebAuthnPrecompileVerifier,eip7212WebAuthnContractVerifier:n.eip7212WebAuthnContractVerifier,webAuthnSignerFactory:n.webAuthnSignerFactory,webAuthnSignerSingleton:n.webAuthnSignerSingleton,webAuthnSignerProxyCreationCode:l}),(await q(e,i,"latest")).length<3&&(o=Ce.createDeployWebAuthnVerifierMetaTransaction(t.x,t.y,{eip7212WebAuthnPrecompileVerifier:n.eip7212WebAuthnPrecompileVerifier,eip7212WebAuthnContractVerifier:n.eip7212WebAuthnContractVerifier,webAuthnSignerFactory:n.webAuthnSignerFactory}))):i=t,s="string"!=typeof a?Ce.createWebAuthnSignerVerifierAddress(a.x,a.y,{eip7212WebAuthnPrecompileVerifier:n.eip7212WebAuthnPrecompileVerifier,eip7212WebAuthnContractVerifier:n.eip7212WebAuthnContractVerifier,webAuthnSignerFactory:n.webAuthnSignerFactory,webAuthnSignerSingleton:n.webAuthnSignerSingleton,webAuthnSignerProxyCreationCode:l}):a;let c=n.prevOwner;if(null==c){const t=await this.getOwners(e),a=t.indexOf(s);if(-1==a)throw new RangeError("oldOwner is not a current owner.");c=0==a?"0x0000000000000000000000000000000000000001":t[a-1]}const d=this.createStandardSwapOwnerMetaTransaction(i,s,c);return null==o?[d]:[o,d]}async createRemoveOwnerMetaTransaction(e,t,a,n={}){let r;if("string"!=typeof t){var i;const e=null!=(i=n.webAuthnSignerProxyCreationCode)?i:Ce.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE;r=Ce.createWebAuthnSignerVerifierAddress(t.x,t.y,{eip7212WebAuthnPrecompileVerifier:n.eip7212WebAuthnPrecompileVerifier,eip7212WebAuthnContractVerifier:n.eip7212WebAuthnContractVerifier,webAuthnSignerFactory:n.webAuthnSignerFactory,webAuthnSignerSingleton:n.webAuthnSignerSingleton,webAuthnSignerProxyCreationCode:e})}else r=t;let s=n.prevOwner;if(null==s){const t=await this.getOwners(e),a=t.indexOf(r);if(-1==a)throw new RangeError("ownerToDelete is not a current owner.");s=0==a?"0x0000000000000000000000000000000000000001":t[a-1]}return this.createStandardRemoveOwnerMetaTransaction(r,a,s)}async createAddOwnerWithThresholdMetaTransactions(e,t,a={}){let n,r=null;if("string"!=typeof e){var i;const t=null!=(i=a.webAuthnSignerProxyCreationCode)?i:Ce.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE;if(n=Ce.createWebAuthnSignerVerifierAddress(e.x,e.y,{eip7212WebAuthnPrecompileVerifier:a.eip7212WebAuthnPrecompileVerifier,eip7212WebAuthnContractVerifier:a.eip7212WebAuthnContractVerifier,webAuthnSignerFactory:a.webAuthnSignerFactory,webAuthnSignerSingleton:a.webAuthnSignerSingleton,webAuthnSignerProxyCreationCode:t}),null==a.nodeRpcUrl)throw new RangeError("overrides.nodeRpcUrl can't be null if adding a webauthn owner");(await q(a.nodeRpcUrl,n,"latest")).length<3&&(r=Ce.createDeployWebAuthnVerifierMetaTransaction(e.x,e.y,{eip7212WebAuthnPrecompileVerifier:a.eip7212WebAuthnPrecompileVerifier,eip7212WebAuthnContractVerifier:a.eip7212WebAuthnContractVerifier,webAuthnSignerFactory:a.webAuthnSignerFactory}))}else n=e;const s=this.createStandardAddOwnerWithThresholdMetaTransaction(n,t);return null==r?[s]:[r,s]}createStandardAddOwnerWithThresholdMetaTransaction(e,t){const a=N("0x0d582f13",["address","uint256"],[e,t]);return{to:this.accountAddress,data:a,value:0n}}createStandardSwapOwnerMetaTransaction(e,t,a){const n=N("0xe318b52b",["address","address","address"],[a,t,e]);return{to:this.accountAddress,data:n,value:0n}}createStandardRemoveOwnerMetaTransaction(e,t,a){const n=N("0xf8dc5dd9",["address","address","uint256"],[a,e,t]);return{to:this.accountAddress,data:n,value:0n}}createChangeThresholdMetaTransaction(e){if(e<1)throw new RangeError("threshold can't be less than 1.");const t=N("0x694e80c3",["uint256"],[e]);return{to:this.accountAddress,data:t,value:0n}}createApproveHashMetaTransaction(e){const t=N("0xd4d9bdcd",["bytes32"],[e]);return{to:this.accountAddress,data:t,value:0n}}static createDeployWebAuthnVerifierMetaTransaction(e,t,a={}){var n,r,i;const s=null!=(n=a.eip7212WebAuthnPrecompileVerifier)?n:Ce.DEFAULT_WEB_AUTHN_PRECOMPILE,o=null!=(r=a.eip7212WebAuthnContractVerifier)?r:Ce.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER;return{to:null!=(i=a.webAuthnSignerFactory)?i:Ce.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,value:0n,data:N("0x0d2f0489",["uint256","uint256","uint176"],[e,t,"0x"+s.slice(-4)+o.slice(2)])}}async getOwners(e){const a=N(k("getOwners()"),[],[]),n={to:this.accountAddress,data:a},r=await K(e,n,"latest");return t.defaultAbiCoder().decode(["address[]"],r)[0]}async getThreshold(e){const a=N("0xe75235b8",[],[]),n={to:this.accountAddress,data:a},r=await K(e,n,"latest"),i=t.defaultAbiCoder().decode(["uint256"],r);return Number(i[0])}async getModules(e,a={}){try{let n=a.start;null==n&&(n="0x0000000000000000000000000000000000000001");let r=a.pageSize;null==r&&(r=10n);const i=N("0xcc2f8452",["address","uint256"],[n,r]),s={to:this.accountAddress,data:i},o=await K(e,s,"latest");if("0x"==o)throw new O("BAD_DATA","getModules retuned an empty result, the target account is probably not deployed yet.");const l=t.defaultAbiCoder().decode(["address[]","address"],o);return[l[0],l[1]]}catch(e){const t=G(e);throw new O("BAD_DATA","getModules failed",{cause:t})}}async isModuleEnabled(e,a){const n=N(k("isModuleEnabled(address)"),["address"],[a]),r={to:this.accountAddress,data:n},i=await K(e,r,"latest");return t.defaultAbiCoder().decode(["bool"],i)[0]}static createDummySignerSignaturePairForExpectedSigners(e,t={}){const a=[...e],n=[];for(let e of a){let a;if("string"==typeof e)a=_e;else{if(null==t.isInit)throw new RangeError("Must define isInit parameter when using WebAuthn");if(a=m({},be),t.isInit){var r;const e=null!=(r=t.webAuthnSharedSigner)?r:Ce.DEFAULT_WEB_AUTHN_SHARED_SIGNER;a.signer=e}else{var i,s,o,l,c;const n=null!=(i=t.eip7212WebAuthnPrecompileVerifier)?i:Ce.DEFAULT_WEB_AUTHN_PRECOMPILE,r=null!=(s=t.eip7212WebAuthnContractVerifier)?s:Ce.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER,d=null!=(o=t.webAuthnSignerFactory)?o:Ce.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,u=null!=(l=t.webAuthnSignerSingleton)?l:Ce.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON,f=null!=(c=t.webAuthnSignerProxyCreationCode)?c:Ce.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE;a.signer=Ce.createWebAuthnSignerVerifierAddress(e.x,e.y,{eip7212WebAuthnPrecompileVerifier:n,eip7212WebAuthnContractVerifier:r,webAuthnSignerFactory:d,webAuthnSignerSingleton:u,webAuthnSignerProxyCreationCode:f})}}n.push(a)}return n}static async verifyWebAuthnSignatureForMessageHash(e,a,n,r,i={}){var s,o,l;if(66!=n.length||"0x"!=n.slice(0,2))throw new RangeError("Invalide messageHash ,must be a 0x prefixed keccak256 hash.");const c=null!=(s=i.eip7212WebAuthnPrecompileVerifier)?s:Ce.DEFAULT_WEB_AUTHN_PRECOMPILE,d=null!=(o=i.eip7212WebAuthnContractVerifier)?o:Ce.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER,u=null!=(l=i.webAuthnSignerSingleton)?l:Ce.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON;if(42!=c.length||c.slice(0,38)!=E.slice(0,38))throw new RangeError("Invalide precompile address. It should have the format 0x000000000000000000000000000000000000____");const f="0x1111111111111111111111111111111111111111",A={to:f,data:N("0x1626ba7e",["bytes32","bytes"],[n,r])},h=Ce.createSafeWebAuthnSignerProxyDeployedByteCode(a,c,d,u),p=await K(e,A,"latest",{[f]:{code:h}});return t.defaultAbiCoder().decode(["bool"],p)[0]}static createSafeWebAuthnSignerProxyDeployedByteCode(e,a,n,r){const i=t.defaultAbiCoder(),s=i.encode(["uint256"],[e.x]),o=i.encode(["uint256"],[e.y]);return"0x608060408190527f"+i.encode(["uint176"],["0x"+a.slice(-4)+n.slice(2)]).slice(2)+"3660b681018290527f"+o.slice(2)+"60a082018190527f"+s.slice(2)+"8285018190527f000000000000000000000000"+r.slice(2)+"9490939192600082376000806056360183885af490503d6000803e8060c3573d6000fd5b503d6000f3fea2646970667358221220ddd9bb059ba7a6497d560ca97aadf4dbf0476f578378554a50d41c6bb654beae64736f6c63430008180033"}static createEnableModuleMetaTransaction(e,t){return{to:t,data:N("0x610b5925",["address"],[e]),value:0n}}async createDisableModuleMetaTransaction(e,t,a,n={}){try{let r=n.prevModuleAddress;if(null==r){const[a,i]=await this.getModules(e,{start:n.modulesStart,pageSize:n.modulesPageSize}),s=a.indexOf(t);if(-1==s)throw new RangeError("moduleToDisable "+t+" is not an enabled module.");if(0==s)r="0x0000000000000000000000000000000000000001";else{if(!(s>0))throw new RangeError("Invalid module index for "+t);r=a[s-1]}}return Ce.createStandardDisableModuleMetaTransaction(t,r,a)}catch(e){const t=G(e);throw new O("BAD_DATA","createDisableModuleMetaTransaction failed",{cause:t})}}static createStandardDisableModuleMetaTransaction(e,t,a){return{to:a,data:N("0xe009cfde",["address","address"],[t,e]),value:0n}}async simulateCallDataWithTenderlyAndCreateShareLink(e,t,a,n=null,r,i,s=null,o={}){var l;let c=!1;if(null==n&&null==o.isInit)throw new RangeError("nodeRpcUrl and overrides.isInit can't both be null");c=null==o.isInit?0n==await z(n,this.entrypointAddress,this.accountAddress):o.isInit;let d="0x";return d=null==o.callData?1==i.length?Ce.createAccountCallDataSingleTransaction(i[0],{safeModuleExecutorFunctionSelector:o.safeModuleExecutorFunctionSelector}):Ce.createAccountCallDataBatchTransactions(i,{safeModuleExecutorFunctionSelector:o.safeModuleExecutorFunctionSelector,multisendContractAddress:o.multisendContractAddress}):o.callData,null==(l=o.createShareLink)||l?await ge(e,t,a,r,this.entrypointAddress,this.accountAddress,d,c?this.factoryAddress:null,c?this.factoryData:null,s):{simulation:await ye(e,t,a,r,this.entrypointAddress,this.accountAddress,d,c?this.factoryAddress:null,c?this.factoryData:null,s)}}getSafeMessageEip712Data(e,t){return Re(this.accountAddress,e,t)}}function Le(e){if(0===e.length)throw new Error("Cannot create Merkle tree with empty hash list");const t=[...e];let n=[...e];const r=[n];for(;n.length>1;){const e=[];for(let t=0;t<n.length;t+=2)e.push(a((i=n[t])<(s=t+1<n.length?n[t+1]:n[t])?i+s.slice(2):s+i.slice(2)));r.push(e),n=e}var i,s;const o=r[r.length-1][0],l=t.map((e,t)=>{const a=[];let n=t;for(let e=0;e<r.length-1;e++){const t=r[e];a.push(n%2==1?t[n-1]:n+1<t.length?t[n+1]:t[n]),n=Math.floor(n/2)}let i=o;return a.reverse().forEach(e=>{i+=e.slice(2)}),i});return[o,l]}Ce.DEFAULT_WEB_AUTHN_SHARED_SIGNER="0xfD90FAd33ee8b58f32c00aceEad1358e4AFC23f9",Ce.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON="0x270D7E4a57E6322f336261f3EaE2BADe72E68d72",Ce.DEFAULT_WEB_AUTHN_SIGNER_FACTORY="0xF7488fFbe67327ac9f37D5F722d83Fc900852Fbf",Ce.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER="0x445a0683e494ea0c5AF3E83c5159fBE47Cf9e765",Ce.DEFAULT_WEB_AUTHN_PRECOMPILE="0x0000000000000000000000000000000000000000",Ce.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE="0x61010060405234801561001157600080fd5b506040516101ee3803806101ee83398101604081905261003091610058565b6001600160a01b0390931660805260a09190915260c0526001600160b01b031660e0526100bc565b6000806000806080858703121561006e57600080fd5b84516001600160a01b038116811461008557600080fd5b60208601516040870151606088015192965090945092506001600160b01b03811681146100b157600080fd5b939692955090935050565b60805160a05160c05160e05160ff6100ef60003960006008015260006031015260006059015260006080015260ff6000f3fe608060408190527f00000000000000000000000000000000000000000000000000000000000000003660b681018290527f000000000000000000000000000000000000000000000000000000000000000060a082018190527f00000000000000000000000000000000000000000000000000000000000000008285018190527f00000000000000000000000000000000000000000000000000000000000000009490939192600082376000806056360183885af490503d6000803e8060c3573d6000fd5b503d6000f3fea2646970667358221220ddd9bb059ba7a6497d560ca97aadf4dbf0476f578378554a50d41c6bb654beae64736f6c63430008180033",Ce.DEFAULT_MULTISEND_CONTRACT_ADDRESS="0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526",Ce.initializerFunctionSelector="0xb63e800d",Ce.initializerFunctionInputAbi=["address[]","uint256","address","bytes","address","address","uint256","address"],Ce.DEFAULT_EXECUTOR_FUCNTION_SELECTOR=De.executeUserOpWithErrorString,Ce.executorFunctionInputAbi=["address","uint256","bytes","uint8"];class ve extends Ce{constructor(e,t={}){var a,n,r;super(e,null!=(a=t.safe4337ModuleAddress)?a:ve.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(n=t.entrypointAddress)?n:ve.DEFAULT_ENTRYPOINT_ADDRESS,{onChainIdentifierParams:t.onChainIdentifierParams,onChainIdentifier:t.onChainIdentifier,safeAccountSingleton:null!=(r=t.safeAccountSingleton)?r:_})}static createProxyAddress(e,t={}){var a;const n=m({},t,{singletonInitHash:null!=(a=t.singletonInitHash)?a:_.singletonInitHash});return Ce.createProxyAddress(e,n)}static createAccountAddress(e,t={}){var a,n,r,i,s;const o=m({},t,{safeAccountSingleton:null!=(a=t.safeAccountSingleton)?a:_,eip7212WebAuthnPrecompileVerifierForSharedSigner:null!=(n=t.eip7212WebAuthnPrecompileVerifierForSharedSigner)?n:ve.DEFAULT_WEB_AUTHN_PRECOMPILE,eip7212WebAuthnContractVerifierForSharedSigner:null!=(r=t.eip7212WebAuthnContractVerifierForSharedSigner)?r:ve.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER}),[l,,]=Ce.createAccountAddressAndFactoryAddressAndData(e,o,null!=(i=t.safe4337ModuleAddress)?i:ve.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(s=t.safeModuleSetupAddress)?s:ve.DEFAULT_SAFE_MODULE_SETUP_ADDRESS);return l}static initializeNewAccount(e,t={}){var a,n,r,i,s;let o=!1,l=0n,c=0n;for(const t of e)if("string"!=typeof t){if(o)throw new RangeError("Only one Webauthn signer is allowed during initialization");if(0!=e.indexOf(t))throw new RangeError("Webauthn owner has to be the first owner for an init transaction.");o=!0,l=t.x,c=t.y}const d=m({},t,{safeAccountSingleton:null!=(a=t.safeAccountSingleton)?a:_,eip7212WebAuthnPrecompileVerifierForSharedSigner:null!=(n=t.eip7212WebAuthnPrecompileVerifierForSharedSigner)?n:ve.DEFAULT_WEB_AUTHN_PRECOMPILE,eip7212WebAuthnContractVerifierForSharedSigner:null!=(r=t.eip7212WebAuthnContractVerifierForSharedSigner)?r:ve.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER}),[u,f,A]=Ce.createAccountAddressAndFactoryAddressAndData(e,d,null!=(i=t.safe4337ModuleAddress)?i:ve.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(s=t.safeModuleSetupAddress)?s:ve.DEFAULT_SAFE_MODULE_SETUP_ADDRESS),h=new ve(u,{safe4337ModuleAddress:t.safe4337ModuleAddress,entrypointAddress:t.entrypointAddress,onChainIdentifierParams:t.onChainIdentifierParams,onChainIdentifier:t.onChainIdentifier,safeAccountSingleton:t.safeAccountSingleton});return h.factoryAddress=f,h.factoryData=A,o&&(h.isInitWebAuthn=!0,h.x=l,h.y=c),h}static getUserOperationEip712Hash(e,t,a={}){var n,r,i,s;const o=null!=(n=a.validAfter)?n:0n,l=null!=(r=a.validUntil)?r:0n,c=null!=(i=a.entrypointAddress)?i:ve.DEFAULT_ENTRYPOINT_ADDRESS,d=null!=(s=a.safe4337ModuleAddress)?s:ve.DEFAULT_SAFE_4337_MODULE_ADDRESS;return Ce.getUserOperationEip712Hash(e,t,{validAfter:o,validUntil:l,entrypointAddress:c,safe4337ModuleAddress:d})}static getUserOperationEip712Data(e,t,a={}){var n,r,i,s;const o=null!=(n=a.validAfter)?n:0n,l=null!=(r=a.validUntil)?r:0n,c=null!=(i=a.entrypointAddress)?i:ve.DEFAULT_ENTRYPOINT_ADDRESS,d=null!=(s=a.safe4337ModuleAddress)?s:ve.DEFAULT_SAFE_4337_MODULE_ADDRESS;return Ce.getUserOperationEip712Data(e,t,{validAfter:o,validUntil:l,entrypointAddress:c,safe4337ModuleAddress:d})}static createInitializerCallData(e,t,a={}){var n,r,i,s;const o=null!=(n=a.safe4337ModuleAddress)?n:ve.DEFAULT_SAFE_4337_MODULE_ADDRESS,l=null!=(r=a.safeModuleSetupAddress)?r:ve.DEFAULT_SAFE_MODULE_SETUP_ADDRESS;return Ce.createBaseInitializerCallData(e,t,o,l,a.multisendContractAddress,a.webAuthnSharedSigner,null!=(i=a.eip7212WebAuthnPrecompileVerifierForSharedSigner)?i:ve.DEFAULT_WEB_AUTHN_PRECOMPILE,null!=(s=a.eip7212WebAuthnContractVerifierForSharedSigner)?s:ve.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER)}static createFactoryAddressAndData(e,t={}){var a,n,r,i,s;const o=m({},t,{safeAccountSingleton:null!=(a=t.safeAccountSingleton)?a:_,eip7212WebAuthnPrecompileVerifierForSharedSigner:null!=(n=t.eip7212WebAuthnPrecompileVerifierForSharedSigner)?n:ve.DEFAULT_WEB_AUTHN_PRECOMPILE,eip7212WebAuthnContractVerifierForSharedSigner:null!=(r=t.eip7212WebAuthnContractVerifierForSharedSigner)?r:ve.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER});return Ce.createFactoryAddressAndData(e,o,null!=(i=t.safe4337ModuleAddress)?i:ve.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(s=t.safeModuleSetupAddress)?s:ve.DEFAULT_SAFE_MODULE_SETUP_ADDRESS)}async createUserOperation(e,t,a,n={}){var r,i;const s=n.parallelPaymasterInitValues;if(null!=s&&"0x22e325a297439656"!=s.paymasterData)throw new RangeError("Invalid paymasterData override, the only valid value is 0x22e325a297439656.");const[o,l,c]=await this.createBaseUserOperationAndFactoryAddressAndFactoryData(e,!1,t,a,m({},n,{isMultiChainSignature:!0,eip7212WebAuthnPrecompileVerifier:null!=(r=n.eip7212WebAuthnPrecompileVerifier)?r:ve.DEFAULT_WEB_AUTHN_PRECOMPILE,eip7212WebAuthnContractVerifier:null!=(i=n.eip7212WebAuthnContractVerifier)?i:ve.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER}));return null!=s?m({},o,{factory:l,factoryData:c},s,{eip7702Auth:null}):m({},o,{factory:l,factoryData:c,paymaster:null,paymasterVerificationGasLimit:null,paymasterPostOpGasLimit:null,paymasterData:null,eip7702Auth:null})}signUserOperation(e,t,a,n={}){return Ce.baseSignSingleUserOperation(e,t,a,this.entrypointAddress,this.safe4337ModuleAddress,m({},n,{isMultiChainSignature:!0}))}signUserOperations(e,t){if(e.length<1)throw new RangeError("There should be at least one userOperationsToSign");if(t.length<1)throw new RangeError("There should be at least one privateKey");if(e.length>1){const a=[];e.forEach((e,t)=>{const n=Ce.getUserOperationEip712Hash_V9(e.userOperation,e.chainId,{validAfter:e.validAfter,validUntil:e.validUntil,safe4337ModuleAddress:this.safe4337ModuleAddress,entrypointAddress:this.entrypointAddress});a.push(n)});const[n,r]=Le(a),i=A.hash({verifyingContract:this.safe4337ModuleAddress},R,{merkleTreeRoot:n}),s=[];for(const e of t){const t=new o(e),a=t.signingKey.sign(i).serialized;s.push({signer:t.address,signature:a})}const l=[];return e.forEach((e,t)=>{l.push(Ce.formatSignaturesToUseroperationSignature(s,{validAfter:e.validAfter,validUntil:e.validUntil,isMultiChainSignature:!0,multiChainMerkleProof:r[t]}))}),l}return[this.signUserOperation(e[0].userOperation,t,e[0].chainId,{validUntil:e[0].validUntil,validAfter:e[0].validAfter})]}static getMultiChainSingleSignatureUserOperationsEip712Hash(e,t={}){const a=ve.getMultiChainSingleSignatureUserOperationsEip712Data(e,t);return A.hash(a.domain,a.types,a.messageValue)}static getMultiChainSingleSignatureUserOperationsEip712Data(e,t={}){var a;if(e.length<1)throw new RangeError("There should be at least one userOperationsToSign");const n=null!=(a=t.safe4337ModuleAddress)?a:ve.DEFAULT_SAFE_4337_MODULE_ADDRESS,r=[];e.forEach((e,t)=>{const a=Ce.getUserOperationEip712Hash_V9(e.userOperation,e.chainId,{validAfter:e.validAfter,validUntil:e.validUntil,safe4337ModuleAddress:n});r.push(a)});const[i,s]=Le(r);return{domain:{verifyingContract:n},types:R,messageValue:{merkleTreeRoot:i}}}static formatSignaturesToUseroperationsSignatures(e,t,a={}){if(e.length<1)throw new RangeError("There should be at least one userOperationsToSign");const n=[];e.forEach((e,t)=>{const r=Ce.getUserOperationEip712Hash_V9(e.userOperation,e.chainId,{validAfter:e.validAfter,validUntil:e.validUntil,safe4337ModuleAddress:a.safe4337ModuleAddress});n.push(r)});const[r,i]=Le(n),s=[];return e.forEach((e,n)=>{s.push(Ce.formatSignaturesToUseroperationSignature(t,m({},a,{isMultiChainSignature:!0,multiChainMerkleProof:i[n]})))}),s}static createWebAuthnSignerVerifierAddress(e,t,a={}){var n,r;return Ce.createWebAuthnSignerVerifierAddress(e,t,m({},a,{eip7212WebAuthnPrecompileVerifier:null!=(n=a.eip7212WebAuthnPrecompileVerifier)?n:ve.DEFAULT_WEB_AUTHN_PRECOMPILE,eip7212WebAuthnContractVerifier:null!=(r=a.eip7212WebAuthnContractVerifier)?r:ve.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER}))}static createDeployWebAuthnVerifierMetaTransaction(e,t,a={}){var n,r;return Ce.createDeployWebAuthnVerifierMetaTransaction(e,t,m({},a,{eip7212WebAuthnPrecompileVerifier:null!=(n=a.eip7212WebAuthnPrecompileVerifier)?n:ve.DEFAULT_WEB_AUTHN_PRECOMPILE,eip7212WebAuthnContractVerifier:null!=(r=a.eip7212WebAuthnContractVerifier)?r:ve.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER}))}static createDummySignerSignaturePairForExpectedSigners(e,t={}){var a,n;return Ce.createDummySignerSignaturePairForExpectedSigners(e,m({},t,{eip7212WebAuthnPrecompileVerifier:null!=(a=t.eip7212WebAuthnPrecompileVerifier)?a:ve.DEFAULT_WEB_AUTHN_PRECOMPILE,eip7212WebAuthnContractVerifier:null!=(n=t.eip7212WebAuthnContractVerifier)?n:ve.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER}))}static async verifyWebAuthnSignatureForMessageHash(e,t,a,n,r={}){var i,s;return Ce.verifyWebAuthnSignatureForMessageHash(e,t,a,n,m({},r,{eip7212WebAuthnPrecompileVerifier:null!=(i=r.eip7212WebAuthnPrecompileVerifier)?i:ve.DEFAULT_WEB_AUTHN_PRECOMPILE,eip7212WebAuthnContractVerifier:null!=(s=r.eip7212WebAuthnContractVerifier)?s:ve.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER}))}}ve.DEFAULT_ENTRYPOINT_ADDRESS=g,ve.DEFAULT_SAFE_4337_MODULE_ADDRESS="0x22939E839e3c0F479B713eAF95e0df128554AEAd",ve.DEFAULT_SAFE_MODULE_SETUP_ADDRESS="0x2dd68b007B46fBe91B9A7c3EDa5A7a1063cB5b47",ve.DEFAULT_WEB_AUTHN_PRECOMPILE="0x0000000000000000000000000000000000000100",ve.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER="0xc2b78104907F722DABAc4C69f826a522B2754De4";class xe{constructor(e){this.moduleAddress=void 0,this.abiCoder=void 0,this.moduleAddress=e,this.abiCoder=t.defaultAbiCoder()}createEnableModuleMetaTransaction(e){return Ce.createEnableModuleMetaTransaction(this.moduleAddress,e)}checkForEmptyResultAndRevert(e,t){if("0x"==e)throw new O("BAD_DATA",t+" returned 0x, module contract "+this.moduleAddress+" is probably not deployed")}}var Ie;!function(e){e.After3Minutes="0x949d01d424bE050D09C16025dd007CB59b3A8c66",e.After3Days="0x38275826E1933303E508433dD5f289315Da2541c",e.After7Days="0x088f6cfD8BB1dDb1BB069CCb3fc1A98927D233f2",e.After14Days="0x9BacD92F4687Db306D7ded5d4513a51EA05df25b"}(Ie||(Ie={}));class Oe extends xe{constructor(e=Oe.DEFAULT_SOCIAL_RECOVERY_ADDRESS){super(e)}createConfirmRecoveryMetaTransaction(e,t,a,n){const r=N("0x064e2d0e",["address","address[]","uint256","bool"],[e,t,a,n]);return{to:this.moduleAddress,data:r,value:0n}}createMultiConfirmRecoveryMetaTransaction(e,t,a,n,r){const i=N("0x0728e1e7",["address","address[]","uint256","(address,bytes)","bool"],[e,t,a,n.map(e=>[e.signer,e.signature]),r]);return{to:this.moduleAddress,data:i,value:0n}}createExecuteRecoveryMetaTransaction(e,t,a){const n=N("0xb1f85f69",["address","address[]","uint256"],[e,t,a]);return{to:this.moduleAddress,data:n,value:0n}}createFinalizeRecoveryMetaTransaction(e){const t=N("0x315a7af3",["address"],[e]);return{to:this.moduleAddress,data:t,value:0n}}createCancelRecoveryMetaTransaction(){return{to:this.moduleAddress,data:"0x0ba234d6",value:0n}}createAddGuardianWithThresholdMetaTransaction(e,t){const a=N("0xbe0e54d7",["address","uint256"],[e,t]);return{to:this.moduleAddress,data:a,value:0n}}async createRevokeGuardianWithThresholdMetaTransaction(e,t,a,n,r={}){let i=r.prevGuardianAddress;if(null==i){const n=await this.getGuardians(e,t),r=n.indexOf(a);if(-1==r)throw new RangeError(a+" is not a current guardian for account : "+t);if(0==r)i="0x0000000000000000000000000000000000000001";else{if(!(r>0))throw new RangeError("Invalid guardian index");i=n[r-1]}}return this.createStandardRevokeGuardianWithThresholdMetaTransaction(i,a,n)}createStandardRevokeGuardianWithThresholdMetaTransaction(e,t,a){const n=N("0x936f7d86",["address","address","uint256"],[e,t,a]);return{to:this.moduleAddress,data:n,value:0n}}createChangeThresholdMetaTransaction(e){const t=N("0x694e80c3",["uint256"],[e]);return{to:this.moduleAddress,data:t,value:0n}}async getRecoveryHash(e,t,a,n,r){const i=N("0x5f19df08",["address","address[]","uint256","uint256"],[t,a,n,r]),s={to:this.moduleAddress,data:i},o=await K(e,s,"latest");return this.checkForEmptyResultAndRevert(o,"getRecoveryHash"),this.abiCoder.decode(["bytes32"],o)[0]}async getRecoveryRequest(e,t){const a=N("0x4f9a28b9",["address"],[t]),n={to:this.moduleAddress,data:a},r=await K(e,n,"latest");this.checkForEmptyResultAndRevert(r,"getRecoveryRequest");const i=this.abiCoder.decode(["(uint256,uint256,uint64,address[])"],r);return{guardiansApprovalCount:BigInt(i[0][0]),newThreshold:BigInt(i[0][1]),executeAfter:BigInt(i[0][2]),newOwners:i[0][3]}}async getRecoveryApprovals(e,t,a,n){const r=N("0x6c6595ca",["address","address[]","uint256"],[t,a,n]),i={to:this.moduleAddress,data:r},s=await K(e,i,"latest");this.checkForEmptyResultAndRevert(s,"getRecoveryApprovals");const o=this.abiCoder.decode(["uint256"],s);return BigInt(o[0])}async hasGuardianApproved(e,t,a,n,r){const i=N("0x37d82c36",["address","address","address[]","uint256"],[t,a,n,r]),s={to:this.moduleAddress,data:i},o=await K(e,s,"latest");this.checkForEmptyResultAndRevert(o,"hasGuardianApproved");const l=this.abiCoder.decode(["bool"],o);return Boolean(l[0])}async isGuardian(e,t,a){const n=N("0xd4ee9734",["address","address"],[t,a]),r={to:this.moduleAddress,data:n},i=await K(e,r,"latest");this.checkForEmptyResultAndRevert(i,"isGuardian");const s=this.abiCoder.decode(["bool"],i);return Boolean(s[0])}async guardiansCount(e,t){const a=N("0xc026e7ee",["address"],[t]),n={to:this.moduleAddress,data:a},r=await K(e,n,"latest");this.checkForEmptyResultAndRevert(r,"guardiansCount");const i=this.abiCoder.decode(["uint256"],r);return BigInt(i[0])}async threshold(e,t){const a=N("0xc86ec2bf",["address"],[t]),n={to:this.moduleAddress,data:a},r=await K(e,n,"latest");this.checkForEmptyResultAndRevert(r,"threshold");const i=this.abiCoder.decode(["uint256"],r);return BigInt(i[0])}async getGuardians(e,t){const a=N("0xf18858ab",["address"],[t]),n={to:this.moduleAddress,data:a},r=await K(e,n,"latest");return this.checkForEmptyResultAndRevert(r,"threshold"),this.abiCoder.decode(["address[]"],r)[0]}async nonce(e,t){const a=N("0x70ae92d2",["address"],[t]),n={to:this.moduleAddress,data:a},r=await K(e,n,"latest");this.checkForEmptyResultAndRevert(r,"threshold");const i=this.abiCoder.decode(["uint256"],r);return BigInt(i[0])}async getRecoveryRequestEip712Data(e,t,a,n,r,i={}){let s;if(null==i.recoveryNonce){const t=new Oe(this.moduleAddress);s=await t.nonce(e,a)}else s=i.recoveryNonce;const o={wallet:a,newOwners:n,newThreshold:r,nonce:s};return{domain:{name:"Social Recovery Module",version:"0.0.1",chainId:Number(t),verifyingContract:this.moduleAddress},types:Me,messageValue:o}}}Oe.DEFAULT_SOCIAL_RECOVERY_ADDRESS=Ie.After3Days;const Ge="ExecuteRecovery",Me={ExecuteRecovery:[{type:"address",name:"wallet"},{type:"address[]",name:"newOwners"},{type:"uint256",name:"newThreshold"},{type:"uint256",name:"nonce"}]};class Ve extends xe{constructor(e=Ve.DEFAULT_ALLOWANCE_MODULE_ADDRESS){super(e)}createOneTimeAllowanceMetaTransaction(e,t,a,n){return this.createBaseSetAllowanceMetaTransaction(e,t,a,0n,n)}createRecurringAllowanceMetaTransaction(e,t,a,n,r){return this.createBaseSetAllowanceMetaTransaction(e,t,a,n,r)}createBaseSetAllowanceMetaTransaction(e,t,a,n,r){const i=N("0xbeaeb388",["address","address","uint96","uint16","uint32"],[e,t,a,n,r]);return{to:this.moduleAddress,data:i,value:0n}}createRenewAllowanceMetaTransaction(e,t){const a=N("0xc19bf50e",["address","address"],[e,t]);return{to:this.moduleAddress,data:a,value:0n}}createDeleteAllowanceMetaTransaction(e,t){const a=N("0x885133e3",["address","address"],[e,t]);return{to:this.moduleAddress,data:a,value:0n}}createAllowanceTransferMetaTransaction(e,t,a,n,r,i={}){var s;let o="0x0000000000000000000000000000000000000000",l=0n;if(null!=i.paymentToken){if(o=i.paymentToken,null==i.paymentAmount)throw new RangeError("must specify paymentAmount if paymentToken is set");l=i.paymentAmount}let c=null!=(s=i.delegateSignature)?s:"0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001";return this.createBaseExecuteAllowanceTransferMetaTransaction(e,t,a,n,o,l,r,c)}createBaseExecuteAllowanceTransferMetaTransaction(e,t,a,n,r,i,s,o){const l=N("0x4515641a",["address","address","address","uint96","address","uint96","address","bytes"],[e,t,a,n,r,i,s,o]);return{to:this.moduleAddress,data:l,value:0n}}createAddDelegateMetaTransaction(e){const t=N("0xe71bdf41",["address"],[e]);return{to:this.moduleAddress,data:t,value:0n}}createRemoveDelegateMetaTransaction(e,t){const a=N("0xdd43a79f",["address","bool"],[e,t]);return{to:this.moduleAddress,data:a,value:0n}}async getTokens(e,t,a){const n=N("0x8d0e8e1d",["address","address"],[t,a]),r={to:this.moduleAddress,data:n},i=await K(e,r,"latest");return this.checkForEmptyResultAndRevert(i,"getTokens"),this.abiCoder.decode(["address[]"],i)[0]}async getTokensAllowance(e,t,a,n){const r=N("0x94b31fbd",["address","address","address"],[t,a,n]),i={to:this.moduleAddress,data:r},s=await K(e,i,"latest");this.checkForEmptyResultAndRevert(s,"getTokenAllowance");const o=this.abiCoder.decode(["uint256[5]"],s)[0];return{amount:BigInt(o[0]),spent:BigInt(o[1]),resetTimeMin:BigInt(o[2]),lastResetMin:BigInt(o[3]),nonce:BigInt(o[4])}}async getDelegates(e,t,a={}){var n;let r=null!=(n=a.start)?n:0n;if(null!=a.maxNumberOfResults)return(await this.baseGetDelegates(e,t,r,a.maxNumberOfResults)).results;const i=[];for(;;){const a=await this.baseGetDelegates(e,t,r,20n);if(i.push.apply(i,a.results),0n==a.next)break;r=a.next}return i}async baseGetDelegates(e,t,a,n){const r=N("0xeb37abe0",["address","uint48","uint8"],[t,a,n]),i={to:this.moduleAddress,data:r},s=await K(e,i,"latest");this.checkForEmptyResultAndRevert(s,"getDelegates");const o=this.abiCoder.decode(["address[]","uint48"],s);return{results:o[0],next:BigInt(o[1])}}}Ve.DEFAULT_ALLOWANCE_MODULE_ADDRESS="0x691f59471Bfd2B7d639DCF74671a2d648ED1E331";class We extends Ce{constructor(e,t={}){var a,n;super(e,null!=(a=t.safe4337ModuleAddress)?a:We.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(n=t.entrypointAddress)?n:We.DEFAULT_ENTRYPOINT_ADDRESS,{onChainIdentifierParams:t.onChainIdentifierParams,onChainIdentifier:t.onChainIdentifier,safeAccountSingleton:t.safeAccountSingleton})}static createAccountAddress(e,t={}){var a,n;const[r,,]=Ce.createAccountAddressAndFactoryAddressAndData(e,t,null!=(a=t.safe4337ModuleAddress)?a:We.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(n=t.safeModuleSetupAddress)?n:We.DEFAULT_SAFE_MODULE_SETUP_ADDRESS);return r}static initializeNewAccount(e,t={}){var a,n;let r=!1,i=0n,s=0n;for(const t of e)if("string"!=typeof t){if(r)throw new RangeError("Only one Webauthn signer is allowed during initialization");if(0!=e.indexOf(t))throw new RangeError("Webauthn owner has to be the first owner for an init transaction.");r=!0,i=t.x,s=t.y}const[o,l,c]=Ce.createAccountAddressAndFactoryAddressAndData(e,t,null!=(a=t.safe4337ModuleAddress)?a:We.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(n=t.safeModuleSetupAddress)?n:We.DEFAULT_SAFE_MODULE_SETUP_ADDRESS),d=new We(o,{safe4337ModuleAddress:t.safe4337ModuleAddress,entrypointAddress:t.entrypointAddress,onChainIdentifierParams:t.onChainIdentifierParams,onChainIdentifier:t.onChainIdentifier,safeAccountSingleton:t.safeAccountSingleton});return d.factoryAddress=l,d.factoryData=c,r&&(d.isInitWebAuthn=!0,d.x=i,d.y=s),d}static getUserOperationEip712Hash(e,t,a={}){var n,r,i,s;const o=null!=(n=a.validAfter)?n:0n,l=null!=(r=a.validUntil)?r:0n,c=null!=(i=a.entrypointAddress)?i:We.DEFAULT_ENTRYPOINT_ADDRESS,d=null!=(s=a.safe4337ModuleAddress)?s:We.DEFAULT_SAFE_4337_MODULE_ADDRESS;return Ce.getUserOperationEip712Hash(e,t,{validAfter:o,validUntil:l,entrypointAddress:c,safe4337ModuleAddress:d})}static getUserOperationEip712Data(e,t,a={}){var n,r,i,s;const o=null!=(n=a.validAfter)?n:0n,l=null!=(r=a.validUntil)?r:0n,c=null!=(i=a.entrypointAddress)?i:We.DEFAULT_ENTRYPOINT_ADDRESS,d=null!=(s=a.safe4337ModuleAddress)?s:We.DEFAULT_SAFE_4337_MODULE_ADDRESS;return Ce.getUserOperationEip712Data(e,t,{validAfter:o,validUntil:l,entrypointAddress:c,safe4337ModuleAddress:d})}static createInitializerCallData(e,t,a={}){var n,r;const i=null!=(n=a.safe4337ModuleAddress)?n:We.DEFAULT_SAFE_4337_MODULE_ADDRESS,s=null!=(r=a.safeModuleSetupAddress)?r:We.DEFAULT_SAFE_MODULE_SETUP_ADDRESS;return Ce.createBaseInitializerCallData(e,t,i,s,a.multisendContractAddress,a.webAuthnSharedSigner,a.eip7212WebAuthnPrecompileVerifierForSharedSigner,a.eip7212WebAuthnContractVerifierForSharedSigner)}static createFactoryAddressAndData(e,t={}){var a,n;return Ce.createFactoryAddressAndData(e,t,null!=(a=t.safe4337ModuleAddress)?a:We.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(n=t.safeModuleSetupAddress)?n:We.DEFAULT_SAFE_MODULE_SETUP_ADDRESS)}async createUserOperation(e,t,a,n={}){const[r,i,s]=await this.createBaseUserOperationAndFactoryAddressAndFactoryData(e,!1,t,a,n);return m({},r,{factory:i,factoryData:s,paymaster:null,paymasterVerificationGasLimit:null,paymasterPostOpGasLimit:null,paymasterData:null})}async estimateUserOperationGas(e,t,a={}){return this.baseEstimateUserOperationGas(e,t,a)}signUserOperation(e,t,a,n={}){return Ce.baseSignSingleUserOperation(e,t,a,this.entrypointAddress,this.safe4337ModuleAddress,n)}}We.DEFAULT_ENTRYPOINT_ADDRESS=S,We.DEFAULT_SAFE_4337_MODULE_ADDRESS="0x75cf11467937ce3F2f357CE24ffc3DBF8fD5c226",We.DEFAULT_SAFE_MODULE_SETUP_ADDRESS="0x2dd68b007B46fBe91B9A7c3EDa5A7a1063cB5b47";class Be extends Ce{constructor(e,t={}){var a,n;super(e,null!=(a=t.safe4337ModuleAddress)?a:Be.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(n=t.entrypointAddress)?n:Be.DEFAULT_ENTRYPOINT_ADDRESS,{onChainIdentifierParams:t.onChainIdentifierParams,onChainIdentifier:t.onChainIdentifier})}static createAccountAddress(e,t={}){var a,n;const[r,,]=Ce.createAccountAddressAndFactoryAddressAndData(e,t,null!=(a=t.safe4337ModuleAddress)?a:Be.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(n=t.safeModuleSetupAddress)?n:Be.DEFAULT_SAFE_MODULE_SETUP_ADDRESS);return r}static initializeNewAccount(e,t={}){var a,n;let r=!1,i=0n,s=0n;for(const t of e)if("string"!=typeof t){if(r)throw new RangeError("Only one Webauthn signer is allowed during initialization");if(0!=e.indexOf(t))throw new RangeError("Webauthn owner has to be the first owner for an init transaction.");r=!0,i=t.x,s=t.y}const[o,l,c]=Be.createAccountAddressAndFactoryAddressAndData(e,t,null!=(a=t.safe4337ModuleAddress)?a:Be.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(n=t.safeModuleSetupAddress)?n:Be.DEFAULT_SAFE_MODULE_SETUP_ADDRESS),d=new Be(o,{safe4337ModuleAddress:t.safe4337ModuleAddress,entrypointAddress:t.entrypointAddress,onChainIdentifierParams:t.onChainIdentifierParams,onChainIdentifier:t.onChainIdentifier});return d.factoryAddress=l,d.factoryData=c,r&&(d.isInitWebAuthn=!0,d.x=i,d.y=s),d}static getUserOperationEip712Hash(e,t,a={}){var n,r,i,s;const o=null!=(n=a.validAfter)?n:0n,l=null!=(r=a.validUntil)?r:0n,c=null!=(i=a.entrypointAddress)?i:Be.DEFAULT_ENTRYPOINT_ADDRESS,d=null!=(s=a.safe4337ModuleAddress)?s:Be.DEFAULT_SAFE_4337_MODULE_ADDRESS;return Ce.getUserOperationEip712Hash(e,t,{validAfter:o,validUntil:l,entrypointAddress:c,safe4337ModuleAddress:d})}static getUserOperationEip712Data(e,t,a={}){var n,r,i,s;const o=null!=(n=a.validAfter)?n:0n,l=null!=(r=a.validUntil)?r:0n,c=null!=(i=a.entrypointAddress)?i:Be.DEFAULT_ENTRYPOINT_ADDRESS,d=null!=(s=a.safe4337ModuleAddress)?s:Be.DEFAULT_SAFE_4337_MODULE_ADDRESS;return Ce.getUserOperationEip712Data(e,t,{validAfter:o,validUntil:l,entrypointAddress:c,safe4337ModuleAddress:d})}static createAccountAddressAndInitCode(e,t={}){var a,n;const[r,i,s]=Ce.createAccountAddressAndFactoryAddressAndData(e,t,null!=(a=t.safe4337ModuleAddress)?a:Be.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(n=t.safeModuleSetupAddress)?n:Be.DEFAULT_SAFE_MODULE_SETUP_ADDRESS);return[r,i+s.slice(2)]}static createInitializerCallData(e,t,a={}){var n,r;const i=null!=(n=a.safe4337ModuleAddress)?n:Be.DEFAULT_SAFE_4337_MODULE_ADDRESS,s=null!=(r=a.safeModuleSetupAddress)?r:Be.DEFAULT_SAFE_MODULE_SETUP_ADDRESS;return Ce.createBaseInitializerCallData(e,t,i,s,a.multisendContractAddress,a.webAuthnSharedSigner,a.eip7212WebAuthnPrecompileVerifierForSharedSigner,a.eip7212WebAuthnContractVerifierForSharedSigner)}static createInitCode(e,t={}){var a,n;const[r,i]=Ce.createFactoryAddressAndData(e,t,null!=(a=t.safe4337ModuleAddress)?a:Be.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(n=t.safeModuleSetupAddress)?n:Be.DEFAULT_SAFE_MODULE_SETUP_ADDRESS);return r+i.slice(2)}async createUserOperation(e,t,a,n={}){const[r,i,s]=await this.createBaseUserOperationAndFactoryAddressAndFactoryData(e,!0,t,a,n);let o="0x";if(null==n.initCode){if(null!=i){let e="0x";null!=s&&(e=s),o=i+e.slice(2)}}else o=n.initCode;return m({},r,{initCode:o,paymasterAndData:"0x"})}async createMigrateToSafeAccountV0_3_0MetaTransactions(e,t={}){var a,n;const r=null!=(a=t.safeV06ModuleAddress)?a:Be.DEFAULT_SAFE_4337_MODULE_ADDRESS,i=null!=(n=t.safeV07ModuleAddress)?n:We.DEFAULT_SAFE_4337_MODULE_ADDRESS,s=await this.createDisableModuleMetaTransaction(e,r,this.accountAddress,{prevModuleAddress:t.safeV06ModuleAddress,modulesPageSize:t.pageSize,modulesStart:t.modulesStart}),o=Ce.createEnableModuleMetaTransaction(i,this.accountAddress),l=N("0xf08a0323",["address"],[i]);return[s,o,{to:this.accountAddress,value:0n,data:l}]}async estimateUserOperationGas(e,t,a={}){return this.baseEstimateUserOperationGas(e,t,a)}signUserOperation(e,t,a,n={}){return Ce.baseSignSingleUserOperation(e,t,a,this.entrypointAddress,this.safe4337ModuleAddress,n)}}Be.DEFAULT_ENTRYPOINT_ADDRESS=D,Be.DEFAULT_SAFE_4337_MODULE_ADDRESS="0xa581c4A4DB7175302464fF3C06380BC3270b4037",Be.DEFAULT_SAFE_MODULE_SETUP_ADDRESS="0x8EcD4ec46D4D2a6B64fE960B3D64e8B94B2234eb";class Ne extends We{constructor(e,t={}){var a;super(e,{safe4337ModuleAddress:t.safe4337ModuleAddress,entrypointAddress:t.entrypointAddress,onChainIdentifierParams:t.onChainIdentifierParams,onChainIdentifier:t.onChainIdentifier,safeAccountSingleton:null!=(a=t.safeAccountSingleton)?a:_})}static createProxyAddress(e,t={}){var a;const n=m({},t,{singletonInitHash:null!=(a=t.singletonInitHash)?a:_.singletonInitHash});return We.createProxyAddress(e,n)}static initializeNewAccount(e,t={}){var a,n,r;const i=m({},t,{safeAccountSingleton:null!=(a=t.safeAccountSingleton)?a:_,eip7212WebAuthnPrecompileVerifierForSharedSigner:null!=(n=t.eip7212WebAuthnPrecompileVerifierForSharedSigner)?n:Ne.DEFAULT_WEB_AUTHN_PRECOMPILE,eip7212WebAuthnContractVerifierForSharedSigner:null!=(r=t.eip7212WebAuthnContractVerifierForSharedSigner)?r:Ne.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER});return We.initializeNewAccount(e,i)}static createAccountAddress(e,t={}){var a,n,r;const i=m({},t,{safeAccountSingleton:null!=(a=t.safeAccountSingleton)?a:_,eip7212WebAuthnPrecompileVerifierForSharedSigner:null!=(n=t.eip7212WebAuthnPrecompileVerifierForSharedSigner)?n:Ne.DEFAULT_WEB_AUTHN_PRECOMPILE,eip7212WebAuthnContractVerifierForSharedSigner:null!=(r=t.eip7212WebAuthnContractVerifierForSharedSigner)?r:Ne.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER});return We.createAccountAddress(e,i)}static createFactoryAddressAndData(e,t={}){var a,n,r;const i=m({},t,{safeAccountSingleton:null!=(a=t.safeAccountSingleton)?a:_,eip7212WebAuthnPrecompileVerifierForSharedSigner:null!=(n=t.eip7212WebAuthnPrecompileVerifierForSharedSigner)?n:Ne.DEFAULT_WEB_AUTHN_PRECOMPILE,eip7212WebAuthnContractVerifierForSharedSigner:null!=(r=t.eip7212WebAuthnContractVerifierForSharedSigner)?r:Ne.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER});return We.createFactoryAddressAndData(e,i)}async createUserOperation(e,t,a,n={}){var r,i;return super.createUserOperation(e,t,a,m({},n,{eip7212WebAuthnPrecompileVerifier:null!=(r=n.eip7212WebAuthnPrecompileVerifier)?r:Ne.DEFAULT_WEB_AUTHN_PRECOMPILE,eip7212WebAuthnContractVerifier:null!=(i=n.eip7212WebAuthnContractVerifier)?i:Ne.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER}))}async estimateUserOperationGas(e,t,a={}){var n,r;return super.estimateUserOperationGas(e,t,m({},a,{eip7212WebAuthnPrecompileVerifier:null!=(n=a.eip7212WebAuthnPrecompileVerifier)?n:Ne.DEFAULT_WEB_AUTHN_PRECOMPILE,eip7212WebAuthnContractVerifier:null!=(r=a.eip7212WebAuthnContractVerifier)?r:Ne.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER}))}static createWebAuthnSignerVerifierAddress(e,t,a={}){var n,r;return Ce.createWebAuthnSignerVerifierAddress(e,t,m({},a,{eip7212WebAuthnPrecompileVerifier:null!=(n=a.eip7212WebAuthnPrecompileVerifier)?n:Ne.DEFAULT_WEB_AUTHN_PRECOMPILE,eip7212WebAuthnContractVerifier:null!=(r=a.eip7212WebAuthnContractVerifier)?r:Ne.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER}))}static createDeployWebAuthnVerifierMetaTransaction(e,t,a={}){var n,r;return Ce.createDeployWebAuthnVerifierMetaTransaction(e,t,m({},a,{eip7212WebAuthnPrecompileVerifier:null!=(n=a.eip7212WebAuthnPrecompileVerifier)?n:Ne.DEFAULT_WEB_AUTHN_PRECOMPILE,eip7212WebAuthnContractVerifier:null!=(r=a.eip7212WebAuthnContractVerifier)?r:Ne.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER}))}static createDummySignerSignaturePairForExpectedSigners(e,t={}){var a,n;return Ce.createDummySignerSignaturePairForExpectedSigners(e,m({},t,{eip7212WebAuthnPrecompileVerifier:null!=(a=t.eip7212WebAuthnPrecompileVerifier)?a:Ne.DEFAULT_WEB_AUTHN_PRECOMPILE,eip7212WebAuthnContractVerifier:null!=(n=t.eip7212WebAuthnContractVerifier)?n:Ne.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER}))}static async verifyWebAuthnSignatureForMessageHash(e,t,a,n,r={}){var i,s;return Ce.verifyWebAuthnSignatureForMessageHash(e,t,a,n,m({},r,{eip7212WebAuthnPrecompileVerifier:null!=(i=r.eip7212WebAuthnPrecompileVerifier)?i:Ne.DEFAULT_WEB_AUTHN_PRECOMPILE,eip7212WebAuthnContractVerifier:null!=(s=r.eip7212WebAuthnContractVerifier)?s:Ne.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER}))}}Ne.DEFAULT_WEB_AUTHN_PRECOMPILE="0x0000000000000000000000000000000000000100",Ne.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER="0xc2b78104907F722DABAc4C69f826a522B2754De4";class He{}class ke extends He{constructor(e){super(),this.rpcUrl=void 0,this.version=void 0,this.entrypointDataV8=void 0,this.entrypointDataV7=void 0,this.entrypointDataV6=void 0,this.initialized=!1,this.rpcUrl=e}async initialize(){try{const e=await H(this.rpcUrl,"pm_clientVersion",[]);if(e.startsWith("Candide/v3"))this.version="v3";else{if(!e.startsWith("Candide/v2"))throw new RangeError("Invalid paymaster version received from paymaster rpc");this.version="v2"}const t=await this.getSupportedEntrypointsLive();if(t.some(e=>e.toLowerCase()===y.toLowerCase())){const e=await this.getSupportedERC20TokensAndPaymasterMetadata(y);this.entrypointDataV8=null!=e?e:null}if(t.some(e=>e.toLowerCase()===S.toLowerCase())){const e=await this.getSupportedERC20TokensAndPaymasterMetadata(S);this.entrypointDataV7=null!=e?e:null}if(t.some(e=>e.toLowerCase()===D.toLowerCase())){const e=await this.getSupportedERC20TokensAndPaymasterMetadata(D);this.entrypointDataV6=null!=e?e:null}if(null==this.entrypointDataV8&&null==this.entrypointDataV7&&null==this.entrypointDataV6)throw new RangeError("Invalid data received during initialization.");return this.initialized=!0,null}catch(e){const t=G(e);throw new O("PAYMASTER_ERROR","failed initializing the paymaster",{cause:t})}}async getSupportedERC20TokensAndPaymasterMetadata(e){if(this.initialized){var t,a,n;if(e==y)return null!=(t=this.entrypointDataV8)?t:null;if(e==S)return null!=(a=this.entrypointDataV7)?a:null;if(e==D)return null!=(n=this.entrypointDataV6)?n:null}else try{let t;if(t="v3"==this.version?await H(this.rpcUrl,"pm_supportedERC20Tokens",[e]):await H(this.rpcUrl,"pm_supportedERC20Tokens",[]),e==y)return{tokens:t.tokens.map(e=>({name:e.name,symbol:e.symbol,address:e.address,decimals:Number(e.decimals)})),paymasterMetadata:t.paymasterMetadata};if(e==S)return{tokens:t.tokens.map(e=>({name:e.name,symbol:e.symbol,address:e.address,decimals:Number(e.decimals)})),paymasterMetadata:t.paymasterMetadata};if(e==D)return{tokens:t.tokens.map(e=>({name:e.name,symbol:e.symbol,address:e.address,decimals:Number(e.decimals)})),paymasterMetadata:t.paymasterMetadata};throw new RangeError("unsupported entrypoint.")}catch(e){const t=G(e);throw new O("PAYMASTER_ERROR","getSupportedERC20TokensAndPaymasterMetadata failed",{cause:t})}return null}async getSupportedEntrypointsLive(){try{return"v3"==this.version?await H(this.rpcUrl,"pm_supportedEntryPoints",[]):[await H(this.rpcUrl,"pm_supportedEntryPoint",[])]}catch(e){const t=G(e);throw new O("PAYMASTER_ERROR","getSupportedEntrypoint failed",{cause:t})}}async getSupportedEntrypoints(){this.initialized||await this.initialize();const e=[];return null!=this.entrypointDataV8&&e.push(y),null!=this.entrypointDataV7&&e.push(S),null!=this.entrypointDataV6&&e.push(D),e}async getPaymasterMetaData(e){if(this.initialized||await this.initialize(),e==y&&null!=this.entrypointDataV8)return this.entrypointDataV8.paymasterMetadata;if(e==S&&null!=this.entrypointDataV7)return this.entrypointDataV7.paymasterMetadata;if(e==D&&null!=this.entrypointDataV6)return this.entrypointDataV6.paymasterMetadata;throw new RangeError("unsupported entrypoint.")}async isSupportedERC20Token(e,t=S){return!!this.getSupportedERC20TokenData(e,t)}async getSupportedERC20TokenData(e,t=S){let a;if(this.initialized||await this.initialize(),t==y&&null!=this.entrypointDataV8)a=this.entrypointDataV8.tokens;else if(t==S&&null!=this.entrypointDataV7)a=this.entrypointDataV7.tokens;else{if(t!=D||null==this.entrypointDataV6)throw new RangeError("unsupported entrypoint.");a=this.entrypointDataV6.tokens}const n=a.find(t=>t.address.toLowerCase()===e.toLowerCase());return n?{name:n.name,symbol:n.symbol,address:n.address,decimals:Number(n.decimals)}:null}async createPaymasterUserOperation(e,t,a,n){null==a&&(a={});let r,i=n;null==i&&(i={}),e=m({},e),this.initialized||await this.initialize();try{var s,o,l,c,d;let n=i.entrypoint;if(null==n)if("initCode"in e){if(null==this.entrypointDataV6)throw new RangeError("UserOperation v0.06 is not supported");n=D,e.paymasterAndData=this.entrypointDataV6.paymasterMetadata.dummyPaymasterAndData}else if("eip7702Auth"in e){if(null==this.entrypointDataV8)throw new RangeError("UserOperation v0.08 is not supported");n=y;const t=this.entrypointDataV8.paymasterMetadata.dummyPaymasterAndData;e.paymaster=t.paymaster,e.paymasterVerificationGasLimit=t.paymasterVerificationGasLimit,e.paymasterPostOpGasLimit=t.paymasterPostOpGasLimit,e.paymasterData=t.paymasterData}else{if(null==this.entrypointDataV7)throw new RangeError("UserOperation v0.07 is not supported");n=S;const t=this.entrypointDataV7.paymasterMetadata.dummyPaymasterAndData;e.paymaster=t.paymaster,e.paymasterVerificationGasLimit=t.paymasterVerificationGasLimit,e.paymasterPostOpGasLimit=t.paymasterPostOpGasLimit,e.paymasterData=t.paymasterData}if("v2"==this.version||void 0!==a.token){var u,f,A,h,p,E;let a=e.preVerificationGas,r=e.verificationGasLimit,s=e.callGasLimit;if(null==i.preVerificationGas||null==i.verificationGasLimit||null==i.callGasLimit){if(null==t)throw new O("BAD_DATA","bundlerRpc can't be null if preVerificationGas,verificationGasLimit and callGasLimit are not overridden");{const o=new le(t);e.callGasLimit=0n,e.verificationGasLimit=0n,e.preVerificationGas=0n;const l=e.maxFeePerGas,c=e.maxPriorityFeePerGas;e.maxFeePerGas=0n,e.maxPriorityFeePerGas=0n;const d=await o.estimateUserOperationGas(e,n,i.state_override_set);a<d.preVerificationGas&&(a=d.preVerificationGas),r<d.verificationGasLimit&&(r=d.verificationGasLimit),s<d.callGasLimit&&(s=d.callGasLimit),e.maxFeePerGas=l,e.maxPriorityFeePerGas=c}}if("bigint"==typeof i.preVerificationGas&&i.preVerificationGas<0n)throw new RangeError("preVerificationGas override can't be negative");if("bigint"==typeof i.verificationGasLimit&&i.verificationGasLimit<0n)throw new RangeError("verificationGasLimit override can't be negative");if("bigint"==typeof i.callGasLimit&&i.callGasLimit<0n)throw new RangeError("callGasLimit override can't be negative");e.preVerificationGas=null!=(u=i.preVerificationGas)?u:BigInt(Math.floor(Number(a)*(((null!=(f=i.preVerificationGasPercentageMultiplier)?f:0)+100)/100))),e.verificationGasLimit=null!=(A=i.verificationGasLimit)?A:BigInt(Math.floor(Number(r)*(((null!=(h=i.verificationGasLimitPercentageMultiplier)?h:0)+100)/100))),e.callGasLimit=null!=(p=i.callGasLimit)?p:BigInt(Math.floor(Number(s)*(((null!=(E=i.callGasLimitPercentageMultiplier)?E:0)+100)/100))),e.preVerificationGas=e.preVerificationGas+100n,e.verificationGasLimit=e.verificationGasLimit+10000n}else if(null!=i.preVerificationGas||null!=i.verificationGasLimit||null!=i.callGasLimit||null!=i.preVerificationGasPercentageMultiplier||null!=i.verificationGasLimitPercentageMultiplier||null!=i.callGasLimitPercentageMultiplier)throw new RangeError("you can't use any gas overrides for paymaster v3, as it will estimate gas and override any provided values.");const m=await H(this.rpcUrl,"pm_sponsorUserOperation",[e,n,a]),g=m,_={callGasLimit:null==g.callGasLimit?void 0:BigInt(g.callGasLimit),preVerificationGas:null==g.preVerificationGas?void 0:BigInt(g.preVerificationGas),verificationGasLimit:null==g.verificationGasLimit?void 0:BigInt(g.verificationGasLimit),maxFeePerGas:null==g.maxFeePerGas?void 0:BigInt(g.maxFeePerGas),maxPriorityFeePerGas:null==g.maxPriorityFeePerGas?void 0:BigInt(g.maxPriorityFeePerGas),sponsorMetadata:null==g.sponsorMetadata?void 0:g.sponsorMetadata};if(e.callGasLimit=null!=(s=_.callGasLimit)?s:e.callGasLimit,e.preVerificationGas=null!=(o=_.preVerificationGas)?o:e.preVerificationGas,e.verificationGasLimit=null!=(l=_.verificationGasLimit)?l:e.verificationGasLimit,e.maxFeePerGas=null!=(c=_.maxFeePerGas)?c:e.maxFeePerGas,e.maxPriorityFeePerGas=null!=(d=_.maxPriorityFeePerGas)?d:e.maxPriorityFeePerGas,r=_.sponsorMetadata,"initCode"in e)e.paymasterAndData=m.paymasterAndData;else{const t=m;e.paymaster=t.paymaster,e.paymasterVerificationGasLimit=BigInt(t.paymasterVerificationGasLimit),e.paymasterPostOpGasLimit=BigInt(t.paymasterPostOpGasLimit),e.paymasterData=t.paymasterData}return[e,r]}catch(e){const t=G(e);throw new O("PAYMASTER_ERROR","pm_sponsorUserOperation failed",{cause:t})}}async createSponsorPaymasterUserOperation(e,t,a,n){const r={};return a&&a.trim().length>0&&(r.sponsorshipPolicyId=a),await this.createPaymasterUserOperation(e,t,r,n)}async createTokenPaymasterUserOperation(e,t,a,n,r){try{var i;this.initialized||await this.initialize();const s=m({},r||{},{callGasLimitPercentageMultiplier:null!=(i=null==r?void 0:r.callGasLimitPercentageMultiplier)?i:105});let o=null==r?void 0:r.entrypoint;null==o&&(o="initCode"in t?D:"eip7702Auth"in t?y:S);const l=2n*await this.calculateUserOperationErc20TokenMaxGasCost(t,a),c=await this.getPaymasterMetaData(o);if(null==c)throw new RangeError("unsupported entrypoint.");const d=e.prependTokenPaymasterApproveToCallData(t.callData,a,c.address,l);if(t.callData=d,"initCode"in t){const[e]=await this.createPaymasterUserOperation(t,n,{token:a},s);return e}if("eip7702Auth"in t){const[e]=await this.createPaymasterUserOperation(t,n,{token:a},s);return e}{const[e]=await this.createPaymasterUserOperation(t,n,{token:a},s);return e}}catch(e){const t=G(e);throw new O("PAYMASTER_ERROR","createTokenPaymasterUserOperation failed",{cause:t})}}async calculateUserOperationErc20TokenMaxGasCost(e,t,a={}){try{this.initialized||await this.initialize();let n=a.entrypoint;return null==n&&(n="initCode"in e?D:"eip7702Auth"in e?y:S),await this.fetchTokenPaymasterExchangeRate(t,n)*X(e)/BigInt(10**18)}catch(e){const t=G(e);throw new O("PAYMASTER_ERROR","calculateUserOperationErc20TokenMaxGasCost failed",{cause:t})}}async fetchTokenPaymasterExchangeRate(e,t=S){try{let a;this.initialized||await this.initialize(),a="v3"==this.version?await H(this.rpcUrl,"pm_supportedERC20Tokens",[t]):await H(this.rpcUrl,"pm_supportedERC20Tokens",[]);const n=a.tokens.map(e=>({address:e.address,exchangeRate:e.exchangeRate})),r=n.find(t=>t.address.toLowerCase()===e.toLowerCase());if(r)return BigInt(r.exchangeRate);throw new O("PAYMASTER_ERROR",e+" token is not supported by the paymaster.",{context:{supportedERC20TokensAndPaymasterMetadataV7:JSON.stringify(this.entrypointDataV7,(e,t)=>"bigint"==typeof t?"0x"+t.toString(16):t),supportedERC20TokensAndPaymasterMetadataV6:JSON.stringify(this.entrypointDataV6,(e,t)=>"bigint"==typeof t?"0x"+t.toString(16):t)}})}catch(e){const t=G(e);throw new O("PAYMASTER_ERROR","fetchTokenPaymasterExchangeRate failed",{cause:t})}}async fetchSupportedERC20TokensAndPaymasterMetadata(e=S){try{let t;if(this.initialized||await this.initialize(),t="v3"==this.version?await H(this.rpcUrl,"pm_supportedERC20Tokens",[e]):await H(this.rpcUrl,"pm_supportedERC20Tokens",[]),e==y||e==S)return{tokens:t.tokens.map(e=>({name:e.name,symbol:e.symbol,address:e.address,decimals:Number(e.decimals),exchangeRate:BigInt(e.exchangeRate)})),paymasterMetadata:t.paymasterMetadata};if(e==D)return{tokens:t.tokens.map(e=>({name:e.name,symbol:e.symbol,address:e.address,decimals:Number(e.decimals),exchangeRate:BigInt(e.exchangeRate)})),paymasterMetadata:t.paymasterMetadata};throw new RangeError("unsupported entrypoint.")}catch(e){const t=G(e);throw new O("PAYMASTER_ERROR","fetchSupportedERC20TokensAndPaymasterMetadata failed",{cause:t})}}}class ze extends He{constructor(e="0x36A337b8b4cE5CF6ca1dDaeef73Da4928d714DF2"){super(),this.address=void 0,this.address=e}async getPaymasterFieldsInitValues(e){return{paymaster:this.address,paymasterVerificationGasLimit:45000n,paymasterPostOpGasLimit:45000n,paymasterData:"0x22e325a297439656"}}async getApprovedPaymasterData(e){return"0x7603fbcd3c6cebdb7193b716f62fe7e9d4afd859df4bf7fcdb2e9d486f57a1ca002022e325a297439656"}}class Ye extends He{constructor(e){super(),this.address=void 0,this.address=e}async createPaymasterUserOperation(e,a,n,r,i,s){if("0x"!=i.slice(0,2)||514!=i.length)throw new RangeError("Invalid proof.");const o=["0x"+(i=i.slice(2)).slice(0,64),"0x"+i.slice(64,128),"0x"+i.slice(128,192),"0x"+i.slice(192,256),"0x"+i.slice(256,320),"0x"+i.slice(320,384),"0x"+i.slice(384,448),"0x"+i.slice(448,512)],l=t.defaultAbiCoder(),c=l.encode(["uint256"],[r])+l.encode(["uint256"],[n]).slice(2)+l.encode(["uint256[8]"],[o]).slice(2);e.paymaster=this.address,e.paymasterData=c,e.paymasterPostOpGasLimit=45000n,e.paymasterVerificationGasLimit=350000n,null==s&&(s={});let d=s.entrypoint;null==d&&(d="eip7702Auth"in e?y:S);let u=e.preVerificationGas,f=e.verificationGasLimit,A=e.callGasLimit;e.preVerificationGas=0n;const h=new le(a),p=await h.estimateUserOperationGas(e,d,s.state_override_set);return u<p.preVerificationGas&&(u=p.preVerificationGas),f<p.verificationGasLimit&&(f=p.verificationGasLimit),A<p.callGasLimit&&(A=p.callGasLimit),e.preVerificationGas=u,e.verificationGasLimit=f,e.callGasLimit=A,e}}function Xe(e,t,n){return a(i(["address","uint256","uint256"],[e,t,n]))}var je={__proto__:null,SmartAccount:p,Simple7702Account:ue,Simple7702AccountV09:fe,ExperimentalSafeMultiChainSigAccount:ve,SocialRecoveryModule:Oe,get SocialRecoveryModuleGracePeriodSelector(){return Ie},EXECUTE_RECOVERY_PRIMARY_TYPE:Ge,EIP712_RECOVERY_MODULE_TYPE:Me,AllowanceModule:Ve,SafeAccountV0_2_0:Be,SafeAccountV0_3_0:We,SafeAccountV1_5_0_M_0_3_0:Ne,SendUseroperationResponse:ce,SmartAccountFactory:Te,SafeAccountFactory:Fe,Bundler:le,CandidePaymaster:ke,ExperimentalAllowAllParallelPaymaster:ze,WorldIdPermissionlessPaymaster:Ye,createWorldIdSignal:Xe,createUserOperationHash:V,createCallData:N,getFunctionSelector:k,fetchAccountNonce:z,calculateUserOperationMaxGasCost:X,sendJsonRpcRequest:H,fetchGasPrice:Y,getDepositInfo:J,getBalanceOf:j,shareTenderlySimulationAndCreateLink:Ae,simulateUserOperationWithTenderlyAndCreateShareLink:he,simulateUserOperationWithTenderly:pe,simulateUserOperationCallDataWithTenderly:Ee,simulateSenderCallDataWithTenderlyAndCreateShareLink:ge,simulateUserOperationCallDataWithTenderlyAndCreateShareLink:me,simulateSenderCallDataWithTenderly:ye,callTenderlySimulateBundle:Se,createAndSignLegacyRawTransaction:Q,createAndSignEip7702RawTransaction:ne,createEip7702TransactionHash:re,createAndSignEip7702DelegationAuthorization:ee,createEip7702DelegationAuthorizationHash:te,signHash:ae,get SafeModuleExecutorFunctionSelector(){return De},EOADummySignerSignaturePair:_e,WebauthnDummySignerSignaturePair:be,get Operation(){return L},get GasOption(){return v},get PolygonChain(){return x},ZeroAddress:E,BaseUserOperationDummyValues:w,EIP712_MULTI_CHAIN_OPERATIONS_TYPE:R,EIP712_MULTI_CHAIN_OPERATIONS_PRIMARY_TYPE:U,EIP712_SAFE_OPERATION_V7_TYPE:P,EIP712_SAFE_OPERATION_V6_TYPE:F,EIP712_SAFE_OPERATION_PRIMARY_TYPE:T,DEFAULT_SECP256R1_PRECOMPILE_ADDRESS:C,AbstractionKitError:O,SAFE_MESSAGE_PRIMARY_TYPE:Pe,SAFE_MESSAGE_MODULE_TYPE:Ue,getSafeMessageEip712Data:Re};export{O as AbstractionKitError,Ve as AllowanceModule,w as BaseUserOperationDummyValues,le as Bundler,ke as CandidePaymaster,C as DEFAULT_SECP256R1_PRECOMPILE_ADDRESS,U as EIP712_MULTI_CHAIN_OPERATIONS_PRIMARY_TYPE,R as EIP712_MULTI_CHAIN_OPERATIONS_TYPE,Me as EIP712_RECOVERY_MODULE_TYPE,T as EIP712_SAFE_OPERATION_PRIMARY_TYPE,F as EIP712_SAFE_OPERATION_V6_TYPE,P as EIP712_SAFE_OPERATION_V7_TYPE,_e as EOADummySignerSignaturePair,Ge as EXECUTE_RECOVERY_PRIMARY_TYPE,ze as ExperimentalAllowAllParallelPaymaster,ve as ExperimentalSafeMultiChainSigAccount,v as GasOption,L as Operation,x as PolygonChain,Ue as SAFE_MESSAGE_MODULE_TYPE,Pe as SAFE_MESSAGE_PRIMARY_TYPE,Fe as SafeAccountFactory,Be as SafeAccountV0_2_0,We as SafeAccountV0_3_0,Ne as SafeAccountV1_5_0_M_0_3_0,De as SafeModuleExecutorFunctionSelector,ce as SendUseroperationResponse,ue as Simple7702Account,fe as Simple7702AccountV09,p as SmartAccount,Te as SmartAccountFactory,Oe as SocialRecoveryModule,Ie as SocialRecoveryModuleGracePeriodSelector,be as WebauthnDummySignerSignaturePair,Ye as WorldIdPermissionlessPaymaster,E as ZeroAddress,je as abstractionkit,X as calculateUserOperationMaxGasCost,Se as callTenderlySimulateBundle,ee as createAndSignEip7702DelegationAuthorization,ne as createAndSignEip7702RawTransaction,Q as createAndSignLegacyRawTransaction,N as createCallData,te as createEip7702DelegationAuthorizationHash,re as createEip7702TransactionHash,V as createUserOperationHash,Xe as createWorldIdSignal,z as fetchAccountNonce,Y as fetchGasPrice,j as getBalanceOf,J as getDepositInfo,k as getFunctionSelector,Re as getSafeMessageEip712Data,H as sendJsonRpcRequest,Ae as shareTenderlySimulationAndCreateLink,ae as signHash,ye as simulateSenderCallDataWithTenderly,ge as simulateSenderCallDataWithTenderlyAndCreateShareLink,Ee as simulateUserOperationCallDataWithTenderly,me as simulateUserOperationCallDataWithTenderlyAndCreateShareLink,pe as simulateUserOperationWithTenderly,he as simulateUserOperationWithTenderlyAndCreateShareLink};
|
|
1
|
+
import*as e from"isomorphic-unfetch";import{AbiCoder as t,keccak256 as a,id as n,JsonRpcProvider as r,getAddress as i,solidityPacked as s,encodeRlp as o,Wallet as l,getBytes as c,toBeArray as d,hashMessage as u,solidityPackedKeccak256 as A,TypedDataEncoder as f,ethers as h}from"ethers";class p{constructor(e){this.accountAddress=void 0,this.accountAddress=e}}function m(){return m=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)({}).hasOwnProperty.call(a,n)&&(e[n]=a[n])}return e},m.apply(null,arguments)}p.proxyByteCode=void 0,p.initializerFunctionSelector=void 0,p.initializerFunctionInputAbi=void 0,p.executorFunctionSelector=void 0,p.executorFunctionInputAbi=void 0;const y="0x0000000000000000000000000000000000000000",g="0x433709009B8330FDa32311DF1C2AFA402eD8D009",E="0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108",D="0x0000000071727De22E5E9d8BAf0edAc6f37da032",S="0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",b={singletonAddress:"0xEdd160fEBBD92E350D4D398fb636302fccd67C7e",singletonInitHash:"0x1b94aebb5a7df6dff11d93589204a6bbc99b4b8c9014bf1d386d006c2c17a881"},_={singletonAddress:"0x29fcB43b46531BcA003ddC8FCB67FFE91900C762",singletonInitHash:"0xe298282cefe913ab5d282047161268a8222e4bd4ed106300c547894bbefd31ee"},w={sender:y,nonce:0n,callData:"0x",callGasLimit:0n,verificationGasLimit:0n,preVerificationGas:0n,maxFeePerGas:0n,maxPriorityFeePerGas:0n,signature:"0x"},F="SafeOp",T={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"}]},P={SafeOp:[{type:"address",name:"safe"},{type:"uint256",name:"nonce"},{type:"bytes",name:"initCode"},{type:"bytes",name:"callData"},{type:"uint128",name:"verificationGasLimit"},{type:"uint128",name:"callGasLimit"},{type:"uint256",name:"preVerificationGas"},{type:"uint128",name:"maxPriorityFeePerGas"},{type:"uint128",name:"maxFeePerGas"},{type:"bytes",name:"paymasterAndData"},{type:"uint48",name:"validAfter"},{type:"uint48",name:"validUntil"},{type:"address",name:"entryPoint"}]},x="MerkleTreeRoot",U={MerkleTreeRoot:[{type:"bytes32",name:"merkleTreeRoot"}]},C="0x0000000000000000000000000000000000000100",R="0x000000009B1D0aF20D8C6d0A44e162d11F9b8f00",v="0x71032285A847c4311Eb7ec2E7A636aB94A9805Aa";var L,I,G;!function(e){e[e.Call=0]="Call",e[e.Delegate=1]="Delegate"}(L||(L={})),function(e){e[e.Slow=1]="Slow",e[e.Medium=1.2]="Medium",e[e.Fast=1.5]="Fast"}(I||(I={})),function(e){e.Mainnet="v2",e.ZkMainnet="zkevm",e.Amoy="amoy",e.Cardona="cardona"}(G||(G={}));const O={"-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"};class M extends Error{constructor(e,t,a={}){const{cause:n,errno:r,context:i}=a;super(t,{cause:n}),this.code=void 0,this.context=void 0,this.errno=void 0,this.name=this.constructor.name,this.code=e,this.errno=r,this.context=i}stringify(){return JSON.stringify(this,["name","code","message","cause","errno","context"])}}function V(e){if(e instanceof Error)return e;let 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}`)}function B(e,n){const r=t.defaultAbiCoder().encode(["(bytes32,bytes32,bytes32,uint256,address)"],[["0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f","0x364da28a5c92bcc87fe97c8813a6c6b8a3a049b0ea0a328fcb0b4f0e00337586","0xc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6",e,n]]);return a(r)}function N(e,n,r){let i;const s=t.defaultAbiCoder();let o;if(n.toLowerCase()==S.toLowerCase()){i=a(function(e){const n=[e.sender,e.nonce,a(e.initCode),a(e.callData),e.callGasLimit,e.verificationGasLimit,e.preVerificationGas,e.maxFeePerGas,e.maxPriorityFeePerGas,a(e.paymasterAndData)];return t.defaultAbiCoder().encode(["address","uint256","bytes32","bytes32","uint256","uint256","uint256","uint256","uint256","bytes32"],n)}(e));const l=s.encode(["bytes32","address","uint256"],[i,n,r]);o=a(l)}else if(n.toLowerCase()==D.toLowerCase()){i=a(function(e){const n=t.defaultAbiCoder();let r="0x";null!=e.factory&&(r=e.factory,null!=e.factoryData&&(r+=e.factoryData.slice(2)));const i="0x"+n.encode(["uint128"],[e.verificationGasLimit]).slice(34)+n.encode(["uint128"],[e.callGasLimit]).slice(34),s="0x"+n.encode(["uint128"],[e.maxPriorityFeePerGas]).slice(34)+n.encode(["uint128"],[e.maxFeePerGas]).slice(34);let o="0x";null!=e.paymaster&&(o=e.paymaster,null!=e.paymasterVerificationGasLimit&&(o+=n.encode(["uint128"],[e.paymasterVerificationGasLimit]).slice(34)),null!=e.paymasterPostOpGasLimit&&(o+=n.encode(["uint128"],[e.paymasterPostOpGasLimit]).slice(34)),null!=e.paymasterData&&(o+=e.paymasterData.slice(2)));const l=[e.sender,e.nonce,a(r),a(e.callData),i,e.preVerificationGas,s,a(o)];return n.encode(["address","uint256","bytes32","bytes32","bytes32","uint256","bytes32","bytes32"],l)}(e));const l=s.encode(["bytes32","address","uint256"],[i,n,r]);o=a(l)}else if(n.toLowerCase()==E.toLowerCase()){i=a(function(e){return H(e,!1)}(e));const t=B(r,n);o=a("0x1901"+t.slice(2)+i.slice(2))}else{if(n.toLowerCase()!=g.toLowerCase())throw new RangeError("unsupported entrypoint address: "+n);{i=a(function(e){return H(e,!0)}(e));const t=B(r,n);o=a("0x1901"+t.slice(2)+i.slice(2))}}return o}function W(e){const t="22e325a297439656",n=e.split(t);return a(n.length>1?s(["bytes","bytes"],[n[0],"0x"+t]):e)}function H(e,n){const r=t.defaultAbiCoder();let i="0x";if(null!=e.factory){const t=e.eip7702Auth;i=null!=t&&null!=t.address?t.address:e.factory,null!=e.factoryData&&(i+=e.factoryData.slice(2))}const s="0x"+r.encode(["uint128"],[e.verificationGasLimit]).slice(34)+r.encode(["uint128"],[e.callGasLimit]).slice(34),o="0x"+r.encode(["uint128"],[e.maxPriorityFeePerGas]).slice(34)+r.encode(["uint128"],[e.maxFeePerGas]).slice(34);let l="0x";null!=e.paymaster&&(l=e.paymaster,null!=e.paymasterVerificationGasLimit&&(l+=r.encode(["uint128"],[e.paymasterVerificationGasLimit]).slice(34)),null!=e.paymasterPostOpGasLimit&&(l+=r.encode(["uint128"],[e.paymasterPostOpGasLimit]).slice(34)),null!=e.paymasterData&&(l+=e.paymasterData.slice(2)));const c=["0x29a0bca4af4be3421398da00295e58e6d7de38cb492214754cb6a47507dd6f8e",e.sender,e.nonce,a(i),a(e.callData),s,e.preVerificationGas,o,n?W(l):a(l)];return r.encode(["bytes32","address","uint256","bytes32","bytes32","bytes32","uint256","bytes32","bytes32"],c)}function k(e,a,n){return e+t.defaultAbiCoder().encode(a,n).slice(2)}async function Y(t,a,n,r={"Content-Type":"application/json"},i="params"){const s=e.default||e,o={method:"POST",headers:r,body:JSON.stringify({method:a,[i]:n,id:(new Date).getTime(),jsonrpc:"2.0"},(e,t)=>"bigint"==typeof t?"0x"+t.toString(16):t),redirect:"follow"},l=await s(t,o),c=await l.json();if("result"in c)return c.result;if("simulation_results"in c)return c.simulation_results;{const e=c.error,a=String(e.code);throw new M(a in O?O[a]:"UNKNOWN_ERROR",e.message,{errno:e.code,context:{url:t,requestOptions:JSON.stringify(o)}})}}function z(e){return n(e).slice(0,10)}async function K(e,t,a,n=0){const r=[{from:"0x0000000000000000000000000000000000000000",to:t,data:k(z("getNonce(address,uint192)"),["address","uint192"],[a,n])},"latest"];try{const t=await Y(e,"eth_call",r);if("string"!=typeof t)throw new M("BAD_DATA","getNonce returned ill formed data",{context:JSON.stringify(t)});try{return BigInt(t)}catch(e){const t=V(e);throw new M("BAD_DATA","getNonce returned ill formed data",{cause:t})}}catch(e){const t=V(e);throw new M("BAD_DATA","getNonce failed",{cause:t})}}async function X(e,t=I.Medium){try{const a=new r(e),n=await a.getFeeData();let i,s;return null!=n.maxFeePerGas&&null!=n.maxPriorityFeePerGas?(i=BigInt(Math.ceil(Number(n.maxFeePerGas)*t)),s=BigInt(Math.ceil(Number(n.maxPriorityFeePerGas)*t))):null!=n.gasPrice?(i=BigInt(Math.ceil(Number(n.gasPrice)*t)),s=i):(i=BigInt(Math.ceil(1e9*t)),s=i),0n==i&&(i=1n),0n==s&&(s=1n),[i,s]}catch(e){const t=V(e);throw new M("BAD_DATA","fetching gas prices from node failed.",{cause:t})}}function j(e){return"initCode"in e?(e.callGasLimit+e.verificationGasLimit*("0x"!=e.paymasterAndData&&null!=e.paymasterAndData?3n:0n)+e.preVerificationGas)*e.maxFeePerGas:(e.verificationGasLimit+e.callGasLimit+(null!=(t=e.paymasterVerificationGasLimit)?t:0n)+(null!=(a=e.paymasterPostOpGasLimit)?a:0n)+e.preVerificationGas)*e.maxFeePerGas;var t,a}async function J(e,t,a){return(await $(e,t,a)).deposit}async function $(e,a,n){const r={from:"0x0000000000000000000000000000000000000000",to:n,data:k("0x5287ce12",["address"],[a])};try{const a=await q(e,r,"latest"),n=t.defaultAbiCoder().decode(["uint256","bool","uint112","uint32","uint48"],a);if(5!==n.length)throw new M("BAD_DATA","getDepositInfo returned ill formed data",{context:JSON.stringify(n)});try{return{deposit:BigInt(n[0]),staked:Boolean(n[1]),stake:BigInt(n[2]),unstakeDelaySec:BigInt(n[3]),withdrawTime:BigInt(n[4])}}catch(e){const t=V(e);throw new M("BAD_DATA","getDepositInfo returned ill formed data",{cause:t})}}catch(e){const t=V(e);throw new M("BAD_DATA","getDepositInfo failed",{cause:t})}}async function q(e,t,a,n){let r=[];r=null==n?[t,a]:[t,a,n];try{const t=await Y(e,"eth_call",r);if("string"!=typeof t)throw new M("BAD_DATA","eth_call returned ill formed data",{context:JSON.stringify(t)});try{return t}catch(e){const t=V(e);throw new M("BAD_DATA","eth_call returned ill formed data",{cause:t})}}catch(e){const t=V(e);throw new M("BAD_DATA","eth_call failed",{cause:t})}}async function Z(e,t,a){const n=[t,a];try{const t=await Y(e,"eth_getCode",n);if("string"!=typeof t)throw new M("BAD_DATA","eth_getCode returned ill formed data",{context:JSON.stringify(t)});try{return t}catch(e){const t=V(e);throw new M("BAD_DATA","eth_getCode returned ill formed data",{cause:t})}}catch(e){const t=V(e);throw new M("BAD_DATA","eth_getCode failed",{cause:t})}}async function Q(e,t){const a=(await Z(t,e,"latest")).toLowerCase();return 48===a.length&&a.startsWith("0xef0100")?i("0x"+a.slice(8)):null}async function ee(e,t,a=I.Medium){let n,r;if(null!=t)[n,r]=await async function(e,t=I.Medium){const a="https://gasstation.polygon.technology/"+e;try{const e=await fetch(a),n=await e.json();let r;r=t==I.Slow?n.safeLow:t==I.Medium?n.standard:n.fast;let i=BigInt(Math.ceil(1e9*Number(r.maxFee))),s=BigInt(Math.ceil(1e9*Number(r.maxPriorityFee)));return 0n==i&&(i=1n),0n==s&&(s=1n),[i,s]}catch(e){const t=V(e);throw new M("BAD_DATA","fetching gas prices from "+a+" failed.",{cause:t})}}(t,a);else{if(null==e)throw new M("BAD_DATA","providerRpc cant't be null if maxFeePerGas and maxPriorityFeePerGas are not overriden");[n,r]=await X(e,a)}return[n,r]}const te="0x04";function ae(e,t,n,r,i,s,d,u){if(e>=2**64)throw new RangeError("Invalid chainId.");if(t>=2**64)throw new RangeError("Invalid nonce.");if(42!=i.length)throw new RangeError("Invalid destination.");let A=[ce(t),ce(n),ce(r),i,ce(s),d,ce(e),ce(0n),ce(0n)];const f=a(o(A)),h=new l(u).signingKey.sign(f);return A=[ce(t),ce(n),ce(r),i,ce(s),d,ce(BigInt(h.yParity+2*Number(e)+35)),c(h.r),c(h.s)],o(A)}function ne(e,t,a,n){const r=re(e,t,a);if("string"==typeof n){const i=ie(r,n);return{chainId:de(e),address:t,nonce:de(a),yParity:de(BigInt(i.yParity)),r:de(i.r),s:de(i.s)}}return n(r).then(n=>{const r=function(e){const t=e.startsWith("0x")?e.slice(2):e,a=BigInt("0x"+t.slice(0,64)),n=BigInt("0x"+t.slice(64,128)),r=parseInt(t.slice(128,130),16);return{yParity:r>=27?r-27:r,r:a,s:n}}(n);return{chainId:de(e),address:t,nonce:de(a),yParity:de(BigInt(r.yParity)),r:de(r.r),s:de(r.s)}})}function re(e,t,n){const r=[ce(e),t,ce(n)],i=o(r);return a("0x05"+i.slice(2))}function ie(e,t){const a=new l(t).signingKey.sign(e);return{yParity:a.yParity,r:BigInt(a.r),s:BigInt(a.s)}}function se(e,t,a,n,r,i,s,l,c,d,u){const A=oe(e,t,a,n,r,i,s,l,c,d),f=le(e,t,a,n,r,i,s,l,c,d),h=ie(A,u),p=f.concat([ce(BigInt(h.yParity)),ce(h.r),ce(h.s)]),m=o(p);return te+m.slice(2)}function oe(e,t,n,r,i,s,l,c,d,u){const A=le(e,t,n,r,i,s,l,c,d,u);return a(te+o(A).slice(2))}function le(e,t,a,n,r,i,s,o,l,d){if(e>=2**64)throw new RangeError("Invalid chainId.");if(t>=2**64)throw new RangeError("Invalid nonce.");if(42!=i.length)throw new RangeError("Invalid destination.");const u=function(e){let t=[];for(const a of e){if(42!=a.address.length)throw new RangeError("Invalid authorization list address: "+a);const e=[ce(a.chainId),a.address,ce(a.nonce),ce(BigInt(a.yParity)),ce(a.r),ce(a.s)];t.push(e)}return t}(d),A=function(e){let t=[];for(const[a,n]of e){if(42!=a.length)throw new RangeError("Invalid access list address: "+a);let e=[];for(const t of n){if(66!=t.length)throw new RangeError("Invalid access list storage: "+t);e.push(c(t))}t.push([c(a),e])}return t}(l);return[ce(e),ce(t),ce(a),ce(n),ce(r),i,ce(s),o,A,u]}function ce(e){return c(d(e))}function de(e){let t=e.toString(16);return t.length%2?"0x0"+t:"0x"+t}class ue{constructor(e){this.rpcUrl=void 0,this.rpcUrl=e}async chainId(){try{const e=await Y(this.rpcUrl,"eth_chainId",[]);if("string"==typeof e)return e;throw new M("BAD_DATA","bundler eth_chainId rpc call failed")}catch(e){const t=V(e);throw new M("BUNDLER_ERROR","bundler eth_chainId rpc call failed",{cause:t})}}async supportedEntryPoints(){try{return await Y(this.rpcUrl,"eth_supportedEntryPoints",[])}catch(e){const t=V(e);throw new M("BUNDLER_ERROR","bundler eth_supportedEntryPoints rpc call failed",{cause:t})}}async estimateUserOperationGas(e,t,a){try{let n={};n=void 0===a?await Y(this.rpcUrl,"eth_estimateUserOperationGas",[e,t]):await Y(this.rpcUrl,"eth_estimateUserOperationGas",[e,t,a]);const r=n;return{callGasLimit:BigInt(r.callGasLimit),preVerificationGas:BigInt(r.preVerificationGas),verificationGasLimit:BigInt(r.verificationGasLimit)}}catch(e){const t=V(e);throw new M("BUNDLER_ERROR","bundler eth_estimateUserOperationGas rpc call failed",{cause:t})}}async sendUserOperation(e,t){try{return await Y(this.rpcUrl,"eth_sendUserOperation",[e,t])}catch(e){const t=V(e);throw new M("BUNDLER_ERROR","bundler eth_sendUserOperation rpc call failed",{cause:t})}}async getUserOperationReceipt(e){try{const t=await Y(this.rpcUrl,"eth_getUserOperationReceipt",[e]);if(null!=t){const e=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:e})}return null}catch(t){const a=V(t);throw new M("BUNDLER_ERROR","bundler eth_getUserOperationReceipt rpc call failed",{cause:a,context:{useroperationhash:e}})}}async getUserOperationByHash(e){try{const t=await Y(this.rpcUrl,"eth_getUserOperationByHash",[e]);return null!=t?m({},t,{blockNumber:null==t.blockNumber?null:BigInt(t.blockNumber)}):null}catch(t){const a=V(t);throw new M("BUNDLER_ERROR","bundler eth_getUserOperationByHash rpc call failed",{cause:a,context:{useroperationhash:e}})}}}class Ae{constructor(e,t,a){this.userOperationHash=void 0,this.bundler=void 0,this.entrypointAddress=void 0,this.bundler=t,this.userOperationHash=e,this.entrypointAddress=a}delay(e){return new Promise(t=>setTimeout(t,e))}async included(e=180,t=2){if(e<=0||t<=0)throw new RangeError("timeoutInSeconds and requestIntervalInSeconds should be bigger than zero");if(e<t)throw new RangeError("timeoutInSeconds can't be less than requestIntervalInSeconds");let a=0;for(;a<=e;){await this.delay(1e3*t);const e=await this.bundler.getUserOperationReceipt(this.userOperationHash);if(null!=e)return e;a+=t}throw new M("TIMEOUT","can't find useroperation",{context:this.userOperationHash})}}class fe extends p{constructor(e,t,a){super(e),this.entrypointAddress=void 0,this.delegateeAddress=void 0,this.entrypointAddress=t,this.delegateeAddress=a}async isDelegatedToThisAccount(e){const t=await Q(this.accountAddress,e);return null!==t&&t.toLowerCase()===this.delegateeAddress.toLowerCase()}async createRevokeDelegationTransaction(e,t,a={}){var n,r,i,s,o,l,c,d,u,A;const f=await Q(this.accountAddress,t);if(null===f)throw new M("BAD_DATA","Account is not delegated — nothing to revoke");if(f.toLowerCase()!==this.delegateeAddress.toLowerCase())throw new M("BAD_DATA","Account is delegated to a different address ("+f+"), not "+this.delegateeAddress+" — use the correct account class to revoke");const h={},p=[];null==a.nonce&&p.push(Y(t,"eth_getTransactionCount",[this.accountAddress,"latest"]).then(e=>{h.nonce=BigInt(e)})),null!=a.maxFeePerGas&&null!=a.maxPriorityFeePerGas||p.push(ee(t,void 0).then(([e,t])=>{h.maxFeePerGas=e,h.maxPriorityFeePerGas=t})),null==a.chainId&&p.push(Y(t,"eth_chainId",[]).then(e=>{h.chainId=BigInt(e)})),p.length>0&&await Promise.all(p);const m=null!=(n=null!=(r=a.nonce)?r:h.nonce)?n:0n,y=null!=(i=null!=(s=a.maxFeePerGas)?s:h.maxFeePerGas)?i:0n,g=null!=(o=null!=(l=a.maxPriorityFeePerGas)?l:h.maxPriorityFeePerGas)?o:0n,E=null!=(c=null!=(d=a.chainId)?d:h.chainId)?c:0n,D=function(e,t,a){return ne(e,"0x0000000000000000000000000000000000000000",t,a)}(E,null!=(u=a.authorizationNonce)?u:m+1n,e),S={chainId:BigInt(D.chainId),address:D.address,nonce:BigInt(D.nonce),yParity:0n===BigInt(D.yParity)?0:1,r:BigInt(D.r),s:BigInt(D.s)};return se(E,m,g,y,null!=(A=a.gasLimit)?A:60000n,this.accountAddress,0n,"0x",[],[S],e)}static createAccountCallData(e,t,a){return k(fe.executorFunctionSelector,fe.executorFunctionInputAbi,[e,t,a])}static createAccountCallDataSingleTransaction(e){var t,a;const n=null!=(t=e.value)?t:0,r=null!=(a=e.data)?a:"0x";return fe.createAccountCallData(e.to,n,r)}static createAccountCallDataBatchTransactions(e){const t=[e.map(e=>[e.to,e.value,e.data])];return k(fe.batchExecutorFunctionSelector,fe.batchExecutorFunctionInputAbi,t)}async baseCreateUserOperation(e,t,a,n={}){var r,i,s,o,l,c,d,u,A,f;if(e.length<1)throw new RangeError("There should be at least one transaction");let h=null,p=null;if(null==n.nonce){if(null==t)throw new M("BAD_DATA","providerRpc cant't be null if nonce is not overriden");p=K(t,this.entrypointAddress,this.accountAddress)}else h=n.nonce;if("bigint"==typeof n.maxFeePerGas&&n.maxFeePerGas<0n)throw new RangeError("maxFeePerGas override can't be negative");if("bigint"==typeof n.maxPriorityFeePerGas&&n.maxPriorityFeePerGas<0n)throw new RangeError("maxPriorityFeePerGas override can't be negative");let y=w.maxFeePerGas,E=w.maxPriorityFeePerGas,D=null;null!=n.maxFeePerGas&&null!=n.maxPriorityFeePerGas||(D=ee(t,n.polygonGasStation,n.gasLevel));let S=null,b=null,_=null,F=!1;var T,P;null!=n.eip7702Auth&&(S=n.eip7702Auth.chainId,b=null!=(T=n.eip7702Auth.address)?T:this.delegateeAddress,_=null!=(P=n.eip7702Auth.nonce)?P:null);let x=null;if(null!=n.eip7702Auth&&null!=t&&(x=Q(this.accountAddress,t).catch(()=>null)),null!=n.eip7702Auth&&null==_){let e;if(null==t)throw new M("BAD_DATA","providerRpc cant't be null if eoaDelegatorNonce is not overriden");e=Y(t,"eth_getTransactionCount",[this.accountAddress,"latest"]);const a=[e];null!=p&&a.push(p),null!=D&&a.push(D),null!=x&&a.push(x);const n=await Promise.all(a);let r=0;if(_=BigInt(n[r++]),null!=p&&(h=n[r++]),null!=D&&([y,E]=n[r++]),null!=x){const e=n[r++];null!=e&&e.toLowerCase()===b.toLowerCase()&&(F=!0)}}else if(null!=n.eip7702Auth){const e=[];if(null!=p&&e.push(p),null!=D&&e.push(D),null!=x&&e.push(x),e.length>0){const t=await Promise.all(e);let a=0;if(null!=p&&(h=t[a++]),null!=D&&([y,E]=t[a++]),null!=x){const e=t[a++];null!=e&&e.toLowerCase()===b.toLowerCase()&&(F=!0)}}}else null!=D&&null!=p?await Promise.all([p,D]).then(e=>{h=e[0],[y,E]=e[1]}):null!=D?[y,E]=await D:null!=p&&(h=await p);if(y=null!=(r=n.maxFeePerGas)?r:BigInt(Math.floor(Number(y)*(((null!=(i=n.maxFeePerGasPercentageMultiplier)?i:0)+100)/100))),E=null!=(s=n.maxPriorityFeePerGas)?s:BigInt(Math.floor(Number(E)*(((null!=(o=n.maxPriorityFeePerGasPercentageMultiplier)?o:0)+100)/100))),null==h)throw new RangeError("failed to determine nonce");if(h<0n)throw new RangeError("nonce can't be negative");let U,C="0x";if(C=null==n.callData?1==e.length?fe.createAccountCallDataSingleTransaction(e[0]):fe.createAccountCallDataBatchTransactions(e):n.callData,null==n.eip7702Auth||F)U=m({},w,{sender:this.accountAddress,nonce:h,callData:C,maxFeePerGas:y,maxPriorityFeePerGas:E,factory:null,factoryData:null,paymaster:null,paymasterVerificationGasLimit:null,paymasterPostOpGasLimit:null,paymasterData:null,eip7702Auth:null});else{var R,v,L;const e=null!=(R=n.eip7702Auth.yParity)?R:"0x0";if("0x0"!=e&&"0x00"!=e&&"0x1"!=e&&"0x01"!=e)throw new M("BAD_DATA","invalide yParity value for eoaDelegatorSignature. must be '0x0' or '0x1'");const t={chainId:de(S),address:b,nonce:de(_),yParity:e,r:null!=(v=n.eip7702Auth.r)?v:"0x4277ba564d2c138823415df0ec8e8f97f30825056d54ec5128a8b29ec2dd81b2",s:null!=(L=n.eip7702Auth.s)?L:"0x1075a1bec7f59848cca899ece93075199cd2aabceb0654b9ae00b881a30044cd"};U=m({},w,{sender:this.accountAddress,nonce:h,callData:C,maxFeePerGas:y,maxPriorityFeePerGas:E,factory:"0x7702",factoryData:null,paymaster:null,paymasterVerificationGasLimit:null,paymasterPostOpGasLimit:null,paymasterData:null,eip7702Auth:t})}let I=w.preVerificationGas,G=w.verificationGasLimit,O=w.callGasLimit;if(null==n.preVerificationGas||null==n.verificationGasLimit||null==n.callGasLimit){const e=n.parallelPaymasterInitValues;if(null!=e){if(this.entrypointAddress!=g)throw new RangeError("parallelPaymasterInitValues only works with ep v0.9");U.paymaster=e.paymaster,U.paymasterVerificationGasLimit=e.paymasterVerificationGasLimit,U.paymasterPostOpGasLimit=e.paymasterPostOpGasLimit,U.paymasterData=e.paymasterData}if(null==a)throw new M("BAD_DATA","bundlerRpc cant't be null if preVerificationGas,verificationGasLimit and callGasLimit are not overriden");{var V;U.callGasLimit=0n,U.verificationGasLimit=0n,U.preVerificationGas=0n;const e=U.maxFeePerGas,t=U.maxPriorityFeePerGas;let r;U.maxFeePerGas=0n,U.maxPriorityFeePerGas=0n,r=m({},U),U.signature=null!=(V=n.dummySignature)?V:fe.dummySignature,[I,G,O]=await this.baseEstimateUserOperationGas(r,a,{stateOverrideSet:n.state_override_set}),G+=55000n,U.maxFeePerGas=e,U.maxPriorityFeePerGas=t}}if("bigint"==typeof n.preVerificationGas&&n.preVerificationGas<0n)throw new RangeError("preVerificationGas override can't be negative");if("bigint"==typeof n.verificationGasLimit&&n.verificationGasLimit<0n)throw new RangeError("verificationGasLimit override can't be negative");if("bigint"==typeof n.callGasLimit&&n.callGasLimit<0n)throw new RangeError("callGasLimit override can't be negative");return U.preVerificationGas=null!=(l=n.preVerificationGas)?l:BigInt(Math.floor(Number(I)*(((null!=(c=n.preVerificationGasPercentageMultiplier)?c:0)+100)/100))),U.verificationGasLimit=null!=(d=n.verificationGasLimit)?d:BigInt(Math.floor(Number(G)*(((null!=(u=n.verificationGasLimitPercentageMultiplier)?u:0)+100)/100))),U.callGasLimit=null!=(A=n.callGasLimit)?A:BigInt(Math.floor(Number(O)*(((null!=(f=n.callGasLimitPercentageMultiplier)?f:0)+100)/100))),U}async baseEstimateUserOperationGas(e,t,a={}){var n;e.signature=null!=(n=a.dummySignature)?n:fe.dummySignature;const r=new ue(t),i=e.maxFeePerGas,s=e.maxPriorityFeePerGas;e.maxFeePerGas=0n,e.maxPriorityFeePerGas=0n;const o=await r.estimateUserOperationGas(e,this.entrypointAddress,a.stateOverrideSet);return e.maxFeePerGas=i,e.maxPriorityFeePerGas=s,[BigInt(o.preVerificationGas),BigInt(o.verificationGasLimit),BigInt(o.callGasLimit)]}baseSignUserOperation(e,t,a){const n=N(e,this.entrypointAddress,a);return new l(t).signingKey.sign(n).serialized}async baseSendUserOperation(e,t){const a=new ue(t),n=await a.sendUserOperation(e,this.entrypointAddress);return new Ae(n,a,this.entrypointAddress)}prependTokenPaymasterApproveToCallData(e,t,a,n){return fe.prependTokenPaymasterApproveToCallDataStatic(e,t,a,n)}static prependTokenPaymasterApproveToCallDataStatic(e,a,n,r){const i={to:a,value:0n,data:k(z("approve(address,uint256)"),["address","uint256"],[n,r])},s=t.defaultAbiCoder();let o;if(e.startsWith(fe.batchExecutorFunctionSelector))o=s.decode(fe.batchExecutorFunctionInputAbi,"0x"+e.slice(10))[0].map(e=>({to:e[0],value:BigInt(e[1]),data:"string"!=typeof e[2]?(new TextDecoder).decode(e[2]):e[2]}));else{if(!e.startsWith(fe.executorFunctionSelector))throw new M("BAD_DATA","Invalid calldata, should start with "+fe.batchExecutorFunctionSelector+" or "+fe.executorFunctionSelector,{context:{callData:e}});{const t=s.decode(fe.executorFunctionInputAbi,"0x"+e.slice(10));o=[{to:t[0],value:BigInt(t[1]),data:"string"!=typeof t[2]?(new TextDecoder).decode(t[2]):t[2]}]}}return o.unshift(i),fe.createAccountCallDataBatchTransactions(o)}}fe.executorFunctionSelector="0xb61d27f6",fe.executorFunctionInputAbi=["address","uint256","bytes"],fe.batchExecutorFunctionSelector="0x34fcd5be",fe.batchExecutorFunctionInputAbi=["(address,uint256,bytes)[]"],fe.dummySignature="0xd2614025fc173b86704caf37b2fb447f7618101a0d31f5f304c777024cef38a060a29ee43fcf0c46f9107d4f670b8a85c2c017a1fe9e4af891f24f0be6ba5d671c";class he extends fe{constructor(e,t={}){var a,n;super(e,null!=(a=t.entrypointAddress)?a:E,null!=(n=t.delegateeAddress)?n:he.DEFAULT_DELEGATEE_ADDRESS)}async createUserOperation(e,t,a,n={}){return this.baseCreateUserOperation(e,t,a,n)}async estimateUserOperationGas(e,t,a={}){return this.baseEstimateUserOperationGas(e,t,a)}signUserOperation(e,t,a){return this.baseSignUserOperation(e,t,a)}async sendUserOperation(e,t){return this.baseSendUserOperation(e,t)}}he.DEFAULT_DELEGATEE_ADDRESS="0xe6Cae83BdE06E4c305530e199D7217f42808555B";class pe extends fe{constructor(e,t={}){var a,n;super(e,null!=(a=t.entrypointAddress)?a:g,null!=(n=t.delegateeAddress)?n:pe.DEFAULT_DELEGATEE_ADDRESS)}async createUserOperation(e,t,a,n={}){return this.baseCreateUserOperation(e,t,a,n)}async estimateUserOperationGas(e,t,a={}){return this.baseEstimateUserOperationGas(e,t,a)}signUserOperation(e,t,a){return this.baseSignUserOperation(e,t,a)}async sendUserOperation(e,t){return this.baseSendUserOperation(e,t)}}async function me(t,a,n,r){const i="https://api.tenderly.co/api/v1/account/"+t+"/project/"+a+"/simulations/"+r+"/share",s=e.default||e,o={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json","X-Access-Key":n},redirect:"follow"},l=(await s(i,o)).status;if(204!=l)throw new M("BAD_DATA","tenderly share simulation failed.",{context:{tenderlyAccountSlug:t,tenderlyProjectSlug:a,tenderlyAccessKey:n,tenderlySimulationId:r,status:l}})}async function ye(e,t,a,n,r,i,s=null,o){const l=await ge(e,t,a,n,r,i,s,o);return await me(e,t,a,l.simulation.id),{simulation:l,simulationShareLink:"https://dashboard.tenderly.co/shared/simulation/"+l.simulation.id}}async function ge(e,a,n,r,i,s,o=null,l){const c=i.toLowerCase();let d=null;const u=t.defaultAbiCoder(),A="initCode"in s;if(A!==("0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789"==c))throw new RangeError("UserOperation version does not match entrypoint.");if(A)d="0x1fad948c"+u.encode(["(address,uint256,bytes,bytes,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[]","address"],[[[s.sender,s.nonce,s.initCode,s.callData,s.callGasLimit,s.verificationGasLimit,s.preVerificationGas,s.maxFeePerGas,s.maxPriorityFeePerGas,s.paymasterAndData,s.signature]],"0x1000000000000000000000000000000000000000"]).slice(2);else{let e="0x";null!=s.factory&&(e=s.factory,null!=s.factoryData&&(e+=s.factoryData.slice(2)));const t="0x"+u.encode(["uint128"],[s.verificationGasLimit]).slice(34)+u.encode(["uint128"],[s.callGasLimit]).slice(34),a="0x"+u.encode(["uint128"],[s.maxPriorityFeePerGas]).slice(34)+u.encode(["uint128"],[s.maxFeePerGas]).slice(34);let n="0x";null!=s.paymaster&&(n=s.paymaster,null!=s.paymasterVerificationGasLimit&&(n+=u.encode(["uint128"],[s.paymasterVerificationGasLimit]).slice(34)),null!=s.paymasterPostOpGasLimit&&(n+=u.encode(["uint128"],[s.paymasterPostOpGasLimit]).slice(34)),null!=s.paymasterData&&(n+=s.paymasterData.slice(2)));const r=u.encode(["(address,uint256,bytes,bytes,bytes32,uint256,bytes32,bytes,bytes)[]","address"],[[[s.sender,s.nonce,e,s.callData,t,s.preVerificationGas,a,n,s.signature]],"0x1000000000000000000000000000000000000000"]);if("0x0000000071727de22e5e9d8baf0edac6f37da032"!=c&&"0x4337084d9e255ff0702461cf8895ce9e3b5ff108"!=c&&"0x433709009b8330fda32311df1c2afa402ed8d009"!=c)throw new RangeError("Invalid entrypoint.");d="0x765e827f"+r.slice(2)}if(!A&&"0x7702"===s.factory){const e=s.eip7702Auth;if(null!=e&&null!=e.address){const t="0xef0100"+e.address.toLowerCase().replace("0x",""),a=s.sender.toLowerCase();(l=l?m({},l):{})[a]=m({},l[a]||{},{code:t})}}return(await _e(e,a,n,[{chainId:r,blockNumber:o,from:"0x1000000000000000000000000000000000000000",to:i,data:d,stateOverrides:l}]))[0]}async function Ee(e,t,a,n,r,i,s=null,o){const l=await De(e,t,a,n,r,i,s,o),c=l.map(e=>e.simulation.id);await Promise.all(c.map(n=>me(e,t,a,n)));const d=c.map(e=>"https://dashboard.tenderly.co/shared/simulation/"+e);if(1==d.length)return{simulation:l,callDataSimulationShareLink:d[0]};if(2==d.length)return{simulation:l,accountDeploymentSimulationShareLink:d[0],callDataSimulationShareLink:d[1]};throw new M("BAD_DATA","invalid number of simulations retuned",{context:JSON.stringify(l,(e,t)=>"bigint"==typeof t?"0x"+t.toString(16):t)})}async function De(e,a,n,r,i,s,o=null,l){let c=null,d=null;if("initCode"in s!=("0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789"==i.toLowerCase()))throw new RangeError("UserOperation version does not match entrypoint.");let u=s.callData;if("initCode"in s)null!=s.initCode&&s.initCode.length>2&&(c=s.initCode.slice(0,22),d=s.initCode.slice(22));else{c=s.factory,d=s.factoryData,"0x7702"===c&&(c=null,d=null);const e="0x8dd7712f";if(u.toLowerCase().startsWith(e)){const a=t.defaultAbiCoder();let n="0x";null!=s.factory&&(n=s.factory,null!=s.factoryData&&(n+=s.factoryData.slice(2)));const o="0x"+a.encode(["uint128"],[s.verificationGasLimit]).slice(34)+a.encode(["uint128"],[s.callGasLimit]).slice(34),l="0x"+a.encode(["uint128"],[s.maxPriorityFeePerGas]).slice(34)+a.encode(["uint128"],[s.maxFeePerGas]).slice(34);let c="0x";null!=s.paymaster&&(c=s.paymaster,null!=s.paymasterVerificationGasLimit&&(c+=a.encode(["uint128"],[s.paymasterVerificationGasLimit]).slice(34)),null!=s.paymasterPostOpGasLimit&&(c+=a.encode(["uint128"],[s.paymasterPostOpGasLimit]).slice(34)),null!=s.paymasterData&&(c+=s.paymasterData.slice(2)));const d=N(s,i,r);u=e+a.encode(["(address,uint256,bytes,bytes,bytes32,uint256,bytes32,bytes,bytes)","bytes32"],[[s.sender,s.nonce,n,s.callData,o,s.preVerificationGas,l,c,s.signature],d]).slice(2)}}return await be(e,a,n,r,i,s.sender,u,c,d,o,l)}async function Se(e,t,a,n,r,i,s,o=null,l=null,c=null,d){const u=await be(e,t,a,n,r,i,s,o,l,c,d),A=u.map(e=>e.simulation.id);await Promise.all(A.map(n=>me(e,t,a,n)));const f=A.map(e=>"https://dashboard.tenderly.co/shared/simulation/"+e);if(1==f.length)return{simulation:u,callDataSimulationShareLink:f[0]};if(2==f.length)return{simulation:u,accountDeploymentSimulationShareLink:f[0],callDataSimulationShareLink:f[1]};throw new M("BAD_DATA","invalid number of simulations retuned",{context:JSON.stringify(u,(e,t)=>"bigint"==typeof t?"0x"+t.toString(16):t)})}async function be(e,t,a,n,r,i,s,o=null,l=null,c=null,d){const u=[],A=r.toLowerCase();let f;if("0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789"==A)f="0x7fc98430eaedbb6070b35b39d798725049088348";else if("0x0000000071727de22e5e9d8baf0edac6f37da032"==A)f="0xefc2c1444ebcc4db75e7613d20c6a62ff67a167c";else if("0x4337084d9e255ff0702461cf8895ce9e3b5ff108"==A)f="0x449ed7c3e6fee6a97311d4b55475df59c44add33";else{if("0x433709009b8330fda32311df1c2afa402ed8d009"!=A)throw new RangeError(`Invalid entrypoint: ${r}`);f="0x0A630a99Df908A81115A3022927Be82f9299987e"}if(null==o&&null!=l||null!=o&&null==l)throw new RangeError("Invalid factory and factoryData");null!=o&&null!=l&&u.push({chainId:n,blockNumber:c,from:f,to:o,data:l,stateOverrides:d}),u.push({chainId:n,blockNumber:c,from:r,to:i,data:s,stateOverrides:d});const h=await _e(e,t,a,u);for(const e of h)if(""==e.simulation.id)throw new M("TENDERLY_SIMULATION_ERROR","tenderly simulation failed",{context:JSON.stringify(h,(e,t)=>"bigint"==typeof t?"0x"+t.toString(16):t)});return h}async function _e(e,t,a,n){const r="https://api.tenderly.co/api/v1/account/"+e+"/project/"+t+"/simulate-bundle",i=n.map(e=>{var t,a,n;const r={network_id:e.chainId.toString(),save:null==(t=e.save)||t,save_if_fails:null==(a=e.saveIfFails)||a,from:e.from,to:e.to,input:e.data,simulation_type:null!=(n=e.simulationType)?n:"full"};if(null!=e.blockNumber&&(r.block_number=e.blockNumber),null!=e.gas&&(r.gas=e.gas),null!=e.gasPrice&&(r.gas_price=e.gasPrice),null!=e.value&&(r.value=e.value),null!=e.stateOverrides){const t=e.stateOverrides;for(const e in t)for(const a in t[e]){if("balance"!=a&&"code"!=a&&"storage"!=a&&"stateDiff"!=a)throw new RangeError(`Invalide stateOverrides key: ${a}.`);if("storage"in t[e]&&"stateDiff"in t[e])throw new RangeError("can't set both storage and stateDiff for stateOverrides");"stateDiff"in t[e]&&(t[e].storage=t[e].stateDiff,delete t[e].stateDiff)}r.state_objects=t}return null!=e.transactionIndex&&(r.transaction_index=e.transactionIndex),null!=e.estimateGas&&(r.estimate_gas=e.estimateGas),null!=e.generateAccessList&&(r.generate_access_list=e.generateAccessList),null!=e.accessList&&(r.access_list=e.accessList),r}),s={Accept:"application/json","Content-Type":"application/json","X-Access-Key":a};return await Y(r,"tenderly_simulateBundle",i,s,"simulations")}var we;pe.DEFAULT_DELEGATEE_ADDRESS="0xa46cc63eBF4Bd77888AA327837d20b23A63a56B5",function(e){e.executeUserOpWithErrorString="0x541d63c8",e.executeUserOp="0x7bb37428"}(we||(we={}));const Fe={signer:"0xfD90FAd33ee8b58f32c00aceEad1358e4AFC23f9",signature:"0x47003599ffa7e9198f321afa774e34a12a959844efd6363b88896e9c24ed33cf4e1be876ef123a3c4467e7d451511434039539699f2baa2f44955fa3d1c1c6d81c",isContractSignature:!1},Te={signer:"0xfD90FAd33ee8b58f32c00aceEad1358e4AFC23f9",signature:"0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e06c92f0ac5c4ef9e74721c23d80a9fc12f259ca84afb160f0890483539b9e6080d824c0e6c795157ad5d1ee5eff1ceeb3031009a595f9360919b83dd411c5a78d0000000000000000000000000000000000000000000000000000000000000025a24f744b28d73f066bf3203d145765a7bc735e6328168c8b03e476da3ad0d8fe0400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001e226f726967696e223a2268747470733a2f2f736166652e676c6f62616c220000",isContractSignature:!0};function Pe(e){return"0x"+e.map(e=>function(e){var t;const a=null!=(t=e.operation)?t:L.Call,n=c(e.data);return s(["uint8","address","uint256","uint256","bytes"],[a,e.to,e.value,n.length,n]).slice(2)}(e)).join("")}class xe{constructor(e,t,a){this.address=void 0,this.generatorFunctionSelector=void 0,this.generatorFunctionInputAbi=void 0,this.address=e,this.generatorFunctionSelector=t,this.generatorFunctionInputAbi=a}getFactoryGeneratorFunctionCallData(e){return k(this.generatorFunctionSelector,this.generatorFunctionInputAbi,e)}}class Ue extends xe{constructor(e=Ue.DEFAULT_FACTORY_ADDRESS){super(e,"0x1688f0b9",["address","bytes","uint256"])}}Ue.DEFAULT_FACTORY_ADDRESS="0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67";const Ce="SafeMessage",Re={SafeMessage:[{type:"bytes",name:"message"}]};function ve(e,t,a){const n={message:u(a)};return{domain:{chainId:Number(t),verifyingContract:e},types:Re,messageValue:n}}class Le extends p{constructor(e,t,n,r={}){var i;if(super(e),this.isInitWebAuthn=void 0,this.x=null,this.y=null,this.safeAccountSingleton=void 0,this.entrypointAddress=void 0,this.safe4337ModuleAddress=void 0,this.factoryAddress=void 0,this.factoryData=void 0,this.onChainIdentifier=void 0,this.entrypointAddress=n,this.safe4337ModuleAddress=t,this.factoryAddress=null,this.factoryData=null,this.isInitWebAuthn=!1,null!=r.onChainIdentifierParams&&null!=r.onChainIdentifier)throw new RangeError("can't override both onChainIdentifier and onChainIdentifierParams");if(null!=r.onChainIdentifierParams)this.onChainIdentifier=function(e,t="Web",n="abstractionkit",r="0.2.40"){const i=a("0x"+Buffer.from(e,"utf8").toString("hex")).slice(-20),s=a("0x"+Buffer.from(t,"utf8").toString("hex")).slice(-3),o=a("0x"+Buffer.from(n,"utf8").toString("hex")).slice(-3),l=a("0x"+Buffer.from(r,"utf8").toString("hex")).slice(-3);return`5afe00${Buffer.from(i,"utf8").toString("hex")}${Buffer.from(s,"utf8").toString("hex")}${Buffer.from(o,"utf8").toString("hex")}${Buffer.from(l,"utf8").toString("hex")}`}(r.onChainIdentifierParams.project,r.onChainIdentifierParams.platform,r.onChainIdentifierParams.tool,r.onChainIdentifierParams.toolVersion);else if(null!=r.onChainIdentifier){let e=r.onChainIdentifier;if(e.startsWith("0x")&&(e=e.slice(2)),64!=e.length)throw new RangeError("onChainIdentifier length must be 64.");this.onChainIdentifier=e}else this.onChainIdentifier=null;this.safeAccountSingleton=null!=(i=r.safeAccountSingleton)?i:_}static createProxyAddress(e,t={}){var n,r,o;const l=null!=(n=t.c2Nonce)?n:0n;if(l<0n)throw new RangeError("c2Nonce can't be negative");const c=null!=(r=t.safeFactoryAddress)?r:Ue.DEFAULT_FACTORY_ADDRESS,d=null!=(o=t.singletonInitHash)?o:_.singletonInitHash,u=a(s(["bytes32","uint256"],[a(e),l])),f=A(["bytes1","address","bytes32","bytes32"],["0xff",c,u,d]).slice(-40);return i("0x"+f)}static createAccountCallDataSingleTransaction(e,t={}){var a,n,r,i;const s=null!=(a=e.value)?a:0,o=null!=(n=e.data)?n:"0x",l=null!=(r=e.operation)?r:L.Call,c=null!=(i=t.safeModuleExecutorFunctionSelector)?i:Le.DEFAULT_EXECUTOR_FUCNTION_SELECTOR;return Le.createAccountCallData(e.to,s,o,l,{safeModuleExecutorFunctionSelector:c})}static createAccountCallDataBatchTransactions(e,t={}){var a,n;if(e.length<1)throw new RangeError("There should be at least one metaTransaction");const r=null!=(a=t.safeModuleExecutorFunctionSelector)?a:Le.DEFAULT_EXECUTOR_FUCNTION_SELECTOR,i=null!=(n=t.multisendContractAddress)?n:Le.DEFAULT_MULTISEND_CONTRACT_ADDRESS,s=k("0x8d80ff0a",["bytes"],[Pe(e)]);return Le.createAccountCallData(i,0n,s,L.Delegate,{safeModuleExecutorFunctionSelector:r})}static createAccountCallData(e,t,a,n,r={}){var i;return k(null!=(i=r.safeModuleExecutorFunctionSelector)?i:Le.DEFAULT_EXECUTOR_FUCNTION_SELECTOR,Le.executorFunctionInputAbi,[e,t,a,n])}static decodeAccountCallData(e){let a=null;if(e.startsWith(we.executeUserOpWithErrorString)?a=we.executeUserOpWithErrorString:e.startsWith(we.executeUserOp)&&(a=we.executeUserOp),null!=a){const n=t.defaultAbiCoder(),r="0x"+e.slice(10),i=n.decode(["address","uint256","bytes","uint8"],r);let s;return s="string"!=typeof i[2]?(new TextDecoder).decode(i[2]):i[2],[{to:i[0],value:BigInt(i[1]),data:s,operation:Number(i[3])},a]}throw new M("BAD_DATA","Invalid calldata, should start with "+we.executeUserOpWithErrorString+" or "+we.executeUserOp,{context:{callData:e}})}static prependTokenPaymasterApproveToCallDataStatic(e,a,n,r,i={}){var s;const o=null!=(s=i.multisendContractAddress)?s:Le.DEFAULT_MULTISEND_CONTRACT_ADDRESS,[l,c]=Le.decodeAccountCallData(e),d=Pe([{to:a,value:0n,data:k(z("approve(address,uint256)"),["address","uint256"],[n,r]),operation:L.Call}]);let u="";const A="0x8d80ff0a";if(l.data.startsWith(A)){const e=function(e){return t.defaultAbiCoder().decode(["bytes"],"0x"+e.slice(10))[0]}(l.data);u=d+e.slice(2)}else u=d+Pe([l]).slice(2);const f=k(A,["bytes"],[u]);return Le.createAccountCallData(o,0n,f,L.Delegate,{safeModuleExecutorFunctionSelector:c})}static formatEip712SignaturesToUseroperationSignature(e,t,a={}){if(e.length!=t.length)throw new RangeError("signersAddresses and signatures arrays should be the same length");const n=[];return e.forEach((e,a)=>{n.push({signer:e.toLowerCase(),signature:t[a]})}),Le.formatSignaturesToUseroperationSignature(n,{validAfter:a.validAfter,validUntil:a.validUntil,isMultiChainSignature:a.isMultiChainSignature,multiChainMerkleProof:a.merkleProof})}static getUserOperationEip712Hash(e,t,a={}){return"initCode"in e?Le.getUserOperationEip712Hash_V6(e,t,a):a.entrypointAddress&&a.entrypointAddress.toLowerCase()===g.toLowerCase()?Le.getUserOperationEip712Hash_V9(e,t,a):Le.getUserOperationEip712Hash_V7(e,t,a)}static getUserOperationEip712Data(e,t,a){if("initCode"in e){const n=Le.getUserOperationEip712Data_V6(e,t,a);return{domain:n.domain,types:n.types,messageValue:n.messageValue}}{let n;return n=null!=a&&a.entrypointAddress&&a.entrypointAddress.toLowerCase()===g.toLowerCase()?Le.getUserOperationEip712Data_V9(e,t,a):Le.getUserOperationEip712Data_V7(e,t,a),{domain:n.domain,types:n.types,messageValue:n.messageValue}}}static getUserOperationEip712Data_V6(e,t,a={}){var n,r,i,s;const o=null!=(n=a.validAfter)?n:0n,l=null!=(r=a.validUntil)?r:0n,c=null!=(i=a.entrypointAddress)?i:S,d=null!=(s=a.safe4337ModuleAddress)?s:"0xa581c4A4DB7175302464fF3C06380BC3270b4037",u={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:o,validUntil:l,entryPoint:c};return{domain:{chainId:Number(t),verifyingContract:d},types:T,messageValue:u}}static getUserOperationEip712Hash_V6(e,t,a={}){const n=Le.getUserOperationEip712Data_V6(e,t,a);return f.hash(n.domain,n.types,n.messageValue)}static baseGetUserOperationEip712DataV7V8V9(e,a,n,r={}){var i,s,o;const l=null!=(i=r.validAfter)?i:0n,c=null!=(s=r.validUntil)?s:0n,d=null!=(o=r.safe4337ModuleAddress)?o:"0x75cf11467937ce3F2f357CE24ffc3DBF8fD5c226",u=t.defaultAbiCoder();let A="0x";null!=e.factory&&(A=e.factory,null!=e.factoryData&&(A+=e.factoryData.slice(2)));let f="0x";if(null!=e.paymaster&&(f=e.paymaster,null!=e.paymasterVerificationGasLimit&&(f+=u.encode(["uint128"],[e.paymasterVerificationGasLimit]).slice(34)),null!=e.paymasterPostOpGasLimit&&(f+=u.encode(["uint128"],[e.paymasterPostOpGasLimit]).slice(34)),null!=e.paymasterData)){const t="22e325a297439656";r.is_v9&&e.paymasterData.endsWith(t)?f+=t:f+=e.paymasterData.slice(2)}const h={safe:e.sender,nonce:e.nonce,initCode:A,callData:e.callData,verificationGasLimit:e.verificationGasLimit,callGasLimit:e.callGasLimit,preVerificationGas:e.preVerificationGas,maxPriorityFeePerGas:e.maxPriorityFeePerGas,maxFeePerGas:e.maxFeePerGas,paymasterAndData:f,validAfter:l,validUntil:c,entryPoint:n};return{domain:{chainId:Number(a),verifyingContract:d},types:P,messageValue:h}}static getUserOperationEip712Data_V7(e,t,a={}){var n;return Le.baseGetUserOperationEip712DataV7V8V9(e,t,null!=(n=a.entrypointAddress)?n:D,a)}static getUserOperationEip712Hash_V7(e,t,a={}){const n=Le.getUserOperationEip712Data_V7(e,t,a);return f.hash(n.domain,n.types,n.messageValue)}static getUserOperationEip712Data_V9(e,t,a={}){var n,r;const i=null!=(n=a.safe4337ModuleAddress)?n:"0xee8005d7e79f9a6829ea61A81Fc2A85055fB2a42";return Le.baseGetUserOperationEip712DataV7V8V9(e,t,null!=(r=a.entrypointAddress)?r:g,m({},a,{safe4337ModuleAddress:i,is_v9:!0}))}static getUserOperationEip712Hash_V9(e,t,a={}){const n=Le.getUserOperationEip712Data_V9(e,t,a);return f.hash(n.domain,n.types,n.messageValue)}static formatEip712SingleSignatureToUseroperationSignature(e,t={}){return Le.formatSignaturesToUseroperationSignature([{signer:"0x0000000000000000000000000000000000000000",signature:e}],t)}async sendUserOperation(e,t){const a=new ue(t),n=await a.sendUserOperation(e,this.entrypointAddress);return new Ae(n,a,this.entrypointAddress)}static createAccountAddressAndFactoryAddressAndData(e,t,a,n){var r,i,s,o,l,c,d,u;if(e.length<1)throw new RangeError("There should be at least one owner");const A=Le.createBaseInitializerCallData(e,null!=(r=t.threshold)?r:1,a,n,null!=(i=t.multisendContractAddress)?i:Le.DEFAULT_MULTISEND_CONTRACT_ADDRESS,null!=(s=t.webAuthnSharedSigner)?s:Le.DEFAULT_WEB_AUTHN_SHARED_SIGNER,null!=(o=t.eip7212WebAuthnPrecompileVerifierForSharedSigner)?o:Le.DEFAULT_WEB_AUTHN_PRECOMPILE,null!=(l=t.eip7212WebAuthnContractVerifierForSharedSigner)?l:Le.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER);let f;f=null!=t.safeAccountFactoryAddress?new Ue(t.safeAccountFactoryAddress):new Ue;const h=null!=(c=t.safeAccountSingleton)?c:_,p=this.createProxyAddress(A,{c2Nonce:null!=(d=t.c2Nonce)?d:0n,safeFactoryAddress:f.address,singletonInitHash:h.singletonInitHash}),m=[h.singletonAddress,A,null!=(u=t.c2Nonce)?u:0n],y=f.getFactoryGeneratorFunctionCallData(m);return[p,f.address,y]}static createBaseInitializerCallData(e,t,a,n,r=Le.DEFAULT_MULTISEND_CONTRACT_ADDRESS,i=Le.DEFAULT_WEB_AUTHN_SHARED_SIGNER,s=Le.DEFAULT_WEB_AUTHN_PRECOMPILE,o=Le.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER){if(e.length<1)throw new RangeError("There should be at least one owner");if(t<1)throw new RangeError("threshold should be at least one");if(t>e.length)throw new RangeError("threshold can't be larger than number of owners");const l=k("0x8d0dc49f",["address[]"],[[a]]);let c,d=!1;const u=[];for(const t of e)"string"!=typeof t?d=!0:u.push(t);if(d){const d=[];d.push({to:n,value:0n,data:l,operation:L.Delegate});const u=[];let A=0;for(const t of e)if("string"!=typeof t){if(A>0)throw new RangeError("Only one WebAuthn owner can be set during initialization");const e=k("0x0dd9692f",["uint256","uint256","uint176"],[t.x,t.y,"0x"+s.slice(-4)+o.slice(2)]);d.push({to:i,value:0n,data:e,operation:L.Delegate}),u.push(i),A++}else u.push(t);c=[u,t,r,k("0x8d80ff0a",["bytes"],[Pe(d)]),a,y,0,y]}else c=[u,t,n,l,a,y,0,y];return k(Le.initializerFunctionSelector,Le.initializerFunctionInputAbi,c)}static createFactoryAddressAndData(e,t={},a,n){var r,i,s,o,l,c,d,u;if(e.length<1)throw new RangeError("There should be at least one owner");const A=null!=(r=t.threshold)?r:1,f=null!=(i=t.c2Nonce)?i:0;if(A<1)throw new RangeError("threshold should be at least one");if(A>e.length)throw new RangeError("threshold can't be larger than number of owners");if(f<0n)throw new RangeError("c2Nonce can't be negative");const h=Le.createBaseInitializerCallData(e,null!=(s=t.threshold)?s:1,a,n,null!=(o=t.multisendContractAddress)?o:Le.DEFAULT_MULTISEND_CONTRACT_ADDRESS,null!=(l=t.webAuthnSharedSigner)?l:Le.DEFAULT_WEB_AUTHN_SHARED_SIGNER,null!=(c=t.eip7212WebAuthnPrecompileVerifierForSharedSigner)?c:Le.DEFAULT_WEB_AUTHN_PRECOMPILE,null!=(d=t.eip7212WebAuthnContractVerifierForSharedSigner)?d:Le.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER);let p;p=null!=t.safeAccountFactoryAddress?new Ue(t.safeAccountFactoryAddress):new Ue;const m=null!=(u=t.safeAccountSingleton)?u:_,y=p.getFactoryGeneratorFunctionCallData([m.singletonAddress,h,f]);return[p.address,y]}prependTokenPaymasterApproveToCallData(e,t,a,n,r={}){var i;const s=null!=(i=r.multisendContractAddress)?i:Le.DEFAULT_MULTISEND_CONTRACT_ADDRESS;return Le.prependTokenPaymasterApproveToCallDataStatic(e,t,a,n,{multisendContractAddress:s})}async baseEstimateUserOperationGas(e,t,a={}){const n=0xffffffffffffn,r=0xffffffffffffn;if(null!=a.dummySignerSignaturePairs){if(null!=a.expectedSigners)throw new RangeError("Can't use both dummySignerSignaturePairs and expectedSigners overrides.");if(a.dummySignerSignaturePairs.length<1)throw new RangeError("Number of dummy signers signature pairs can't be less than 1");e.signature=Le.formatSignaturesToUseroperationSignature(a.dummySignerSignaturePairs,{validAfter:n,validUntil:r,isMultiChainSignature:a.isMultiChainSignature})}else if(null!=a.expectedSigners){let t;t="initCode"in e?e.initCode:e.factory;const i=Le.createDummySignerSignaturePairForExpectedSigners(a.expectedSigners,{isInit:null!=t&&"0x"!=t,webAuthnSharedSigner:a.webAuthnSharedSigner,eip7212WebAuthnPrecompileVerifier:a.eip7212WebAuthnPrecompileVerifier,eip7212WebAuthnContractVerifier:a.eip7212WebAuthnContractVerifier,webAuthnSignerFactory:a.webAuthnSignerFactory,webAuthnSignerSingleton:a.webAuthnSignerSingleton,webAuthnSignerProxyCreationCode:a.webAuthnSignerProxyCreationCode,validAfter:n,validUntil:r});e.signature=Le.formatSignaturesToUseroperationSignature(i,{validAfter:n,validUntil:r,isMultiChainSignature:a.isMultiChainSignature})}else e.signature.length<3&&(e.signature=Le.formatSignaturesToUseroperationSignature([Fe],{validAfter:n,validUntil:r,isMultiChainSignature:a.isMultiChainSignature}));const i=new ue(t),s=e.maxFeePerGas,o=e.maxPriorityFeePerGas;e.maxFeePerGas=0n,e.maxPriorityFeePerGas=0n;const l=await i.estimateUserOperationGas(e,this.entrypointAddress,a.stateOverrideSet);e.maxFeePerGas=s,e.maxPriorityFeePerGas=o;const c=BigInt(l.preVerificationGas);let d;return d=null!=a.dummySignerSignaturePairs?BigInt(l.verificationGasLimit)+55000n*BigInt(a.dummySignerSignaturePairs.length):BigInt(l.verificationGasLimit),[c,d,BigInt(l.callGasLimit)]}async createBaseUserOperationAndFactoryAddressAndFactoryData(e,t,a,n,r={}){var i,s,o,l,c,d,u,A,f,h,p,y,E,D,S,b,_,F;if(e.length<1)throw new RangeError("There should be at least one transaction");const T=null!=(i=r.webAuthnSharedSigner)?i:Le.DEFAULT_WEB_AUTHN_SHARED_SIGNER,P=null!=(s=r.safeModuleExecutorFunctionSelector)?s:Le.DEFAULT_EXECUTOR_FUCNTION_SELECTOR,x=null!=(o=r.multisendContractAddress)?o:Le.DEFAULT_MULTISEND_CONTRACT_ADDRESS;let U=null,C=null;if(null==r.nonce){if(null==a)throw new M("BAD_DATA","providerRpc cant't be null if nonce is not overriden");C=K(a,this.entrypointAddress,this.accountAddress)}else U=r.nonce;if("bigint"==typeof r.maxFeePerGas&&r.maxFeePerGas<0n)throw new RangeError("maxFeePerGas overrid can't be negative");if("bigint"==typeof r.maxPriorityFeePerGas&&r.maxPriorityFeePerGas<0n)throw new RangeError("maxPriorityFeePerGas overrid can't be negative");let R=w.maxFeePerGas,v=w.maxPriorityFeePerGas,L=null;null!=r.maxFeePerGas&&null!=r.maxPriorityFeePerGas||(L=ee(a,r.polygonGasStation,r.gasLevel)),null!=L&&null!=C?await Promise.all([C,L]).then(e=>{U=e[0],[R,v]=e[1]}):null!=L?[R,v]=await L:null!=C&&(U=await C),R=null!=(l=r.maxFeePerGas)?l:R*BigInt((null!=(c=r.maxFeePerGasPercentageMultiplier)?c:0)+100)/100n,v=null!=(d=r.maxPriorityFeePerGas)?d:v*BigInt((null!=(u=r.maxPriorityFeePerGasPercentageMultiplier)?u:0)+100)/100n;const I=null!=(A=r.eip7212WebAuthnPrecompileVerifier)?A:Le.DEFAULT_WEB_AUTHN_PRECOMPILE,G=null!=(f=r.eip7212WebAuthnContractVerifier)?f:Le.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER,O=null!=(h=r.webAuthnSignerFactory)?h:Le.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,V=null!=(p=r.webAuthnSignerSingleton)?p:Le.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON,B=null!=(y=r.webAuthnSignerProxyCreationCode)?y:Le.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE;let N=this.factoryAddress,W=this.factoryData;if(null==U)throw new RangeError("failed to determine nonce");if(U<0n)throw new RangeError("nonce can't be negative");if(U>0n)N=null,W=null;else if(this.isInitWebAuthn){if(null==this.x||null==this.y)throw new RangeError("Invalide account initialization with Webauthnn signer.Webauthnn signer publickey can be null!!");const t=Le.createDeployWebAuthnVerifierMetaTransaction(this.x,this.y,{eip7212WebAuthnPrecompileVerifier:I,eip7212WebAuthnContractVerifier:G,webAuthnSignerFactory:O}),a=k("0xe318b52b",["address","address","address"],["0x0000000000000000000000000000000000000001",T,Le.createWebAuthnSignerVerifierAddress(this.x,this.y,{eip7212WebAuthnPrecompileVerifier:I,eip7212WebAuthnContractVerifier:G,webAuthnSignerFactory:O,webAuthnSignerSingleton:V,webAuthnSignerProxyCreationCode:B})]);e=[t,{to:this.accountAddress,value:0n,data:a}].concat(e)}let H="0x";H=null==r.callData?1==e.length?Le.createAccountCallDataSingleTransaction(e[0],{safeModuleExecutorFunctionSelector:P}):Le.createAccountCallDataBatchTransactions(e,{safeModuleExecutorFunctionSelector:P,multisendContractAddress:x}):r.callData,null!=this.onChainIdentifier&&(H+=this.onChainIdentifier);const Y=m({},w,{sender:this.accountAddress,nonce:U,callData:H,maxFeePerGas:R,maxPriorityFeePerGas:v});let z=w.preVerificationGas,X=w.verificationGasLimit,j=w.callGasLimit;if(null==r.preVerificationGas||null==r.verificationGasLimit||null==r.callGasLimit){if(null==n)throw new M("BAD_DATA","bundlerRpc cant't be null if preVerificationGas,verificationGasLimit and callGasLimit are not overriden");{Y.callGasLimit=0n,Y.verificationGasLimit=0n,Y.preVerificationGas=0n;const e=Y.maxFeePerGas,a=Y.maxPriorityFeePerGas;let i;if(Y.maxFeePerGas=0n,Y.maxPriorityFeePerGas=0n,t){let e="0x";null!=N&&(e=N,null!=W&&(e+=W.slice(2))),i=m({},Y,{initCode:e,paymasterAndData:"0x"})}else{i=m({},Y,{factory:N,factoryData:W,paymaster:null,paymasterVerificationGasLimit:null,paymasterPostOpGasLimit:null,paymasterData:null});const e=r.parallelPaymasterInitValues;if(null!=e){if("0x22e325a297439656"!=e.paymasterData)throw new RangeError("Invalid paymasterData override, the only valid value is 0x22e325a297439656.");if(this.entrypointAddress!=g)throw new RangeError("parallelPaymasterInitValues only works with ep v0.9");i.paymaster=e.paymaster,i.paymasterVerificationGasLimit=e.paymasterVerificationGasLimit,i.paymasterPostOpGasLimit=e.paymasterPostOpGasLimit,i.paymasterData=e.paymasterData}}const s=0xffffffffffffn,o=0xffffffffffffn;let l;if(null!=r.dummySignerSignaturePairs){if(null!=r.expectedSigners)throw new RangeError("Can't use both dummySignerSignaturePairs and expectedSigners overrides.");if(r.dummySignerSignaturePairs.length<1)throw new RangeError("Number of dummySignerSignaturePairs can't be less than 1");l=r.dummySignerSignaturePairs}else l=null==r.expectedSigners?[Fe]:Le.createDummySignerSignaturePairForExpectedSigners(r.expectedSigners,{isInit:null!=N&&"0x"!=N,webAuthnSharedSigner:T,eip7212WebAuthnPrecompileVerifier:I,eip7212WebAuthnContractVerifier:G,webAuthnSignerFactory:O,webAuthnSignerSingleton:V,webAuthnSignerProxyCreationCode:B,validAfter:s,validUntil:o});Y.signature=Le.formatSignaturesToUseroperationSignature(l,{validAfter:s,validUntil:o,webAuthnSharedSigner:T,isMultiChainSignature:r.isMultiChainSignature}),[z,X,j]=await this.baseEstimateUserOperationGas(i,n,{stateOverrideSet:r.state_override_set,isMultiChainSignature:r.isMultiChainSignature}),X+=55000n*BigInt(l.length),Y.maxFeePerGas=e,Y.maxPriorityFeePerGas=a}}if("bigint"==typeof r.preVerificationGas&&r.preVerificationGas<0n)throw new RangeError("preVerificationGas overrid can't be negative");if("bigint"==typeof r.verificationGasLimit&&r.verificationGasLimit<0n)throw new RangeError("verificationGasLimit overrid can't be negative");if("bigint"==typeof r.callGasLimit&&r.callGasLimit<0n)throw new RangeError("callGasLimit overrid can't be negative");return Y.preVerificationGas=null!=(E=r.preVerificationGas)?E:z*BigInt((null!=(D=r.preVerificationGasPercentageMultiplier)?D:0)+100)/100n,Y.verificationGasLimit=null!=(S=r.verificationGasLimit)?S:X*BigInt((null!=(b=r.verificationGasLimitPercentageMultiplier)?b:0)+100)/100n,Y.callGasLimit=null!=(_=r.callGasLimit)?_:j*BigInt((null!=(F=r.callGasLimitPercentageMultiplier)?F:0)+100)/100n,[Y,N,W]}static baseSignSingleUserOperation(e,t,a,n,r,i={}){var s,o;const c=null!=(s=i.validAfter)?s:0n,d=null!=(o=i.validUntil)?o:0n;if(t.length<1)throw new RangeError("There should be at least one privateKey");if(a<0n)throw new RangeError("chainId can't be negative");if(c<0n)throw new RangeError("validAfter can't be negative");if(d<0n)throw new RangeError("validUntil can't be negative");const u=Le.getUserOperationEip712Hash(e,a,{validAfter:c,validUntil:d,entrypointAddress:n,safe4337ModuleAddress:r}),A=[];for(const e of t){const t=new l(e),a=t.signingKey.sign(u).serialized;A.push({signer:t.address,signature:a})}return Le.formatSignaturesToUseroperationSignature(A,{validAfter:c,validUntil:d,isMultiChainSignature:i.isMultiChainSignature})}static createWebAuthnSignerVerifierAddress(e,t,n={}){var r,i,o,l,c;const d=null!=(r=n.eip7212WebAuthnPrecompileVerifier)?r:Le.DEFAULT_WEB_AUTHN_PRECOMPILE,u=null!=(i=n.eip7212WebAuthnContractVerifier)?i:Le.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER,f=null!=(o=n.webAuthnSignerFactory)?o:Le.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,h=null!=(l=n.webAuthnSignerSingleton)?l:Le.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON;if(42!=d.length||d.slice(0,38)!=y.slice(0,38))throw new RangeError("Invalide precompile address. It should have the format 0x000000000000000000000000000000000000____");const p=a(s(["bytes","uint256","uint256","uint256","uint256"],[null!=(c=n.webAuthnSignerProxyCreationCode)?c:Le.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE,h,e,t,"0x"+d.slice(-4)+u.slice(2)]));return"0x"+A(["bytes1","address","bytes32","bytes32"],["0xff",f,"0x0000000000000000000000000000000000000000000000000000000000000000",p]).slice(-40)}static formatSignaturesToUseroperationSignature(e,t={}){var a,n;const r=null!=(a=t.validAfter)?a:0n,i=null!=(n=t.validUntil)?n:0n,o=this.buildSignaturesFromSingerSignaturePairs(e,t);if(t.isMultiChainSignature){if(null!=t.multiChainMerkleProof){const e=t.multiChainMerkleProof.slice(2).length;if(e<128||e%64!=0)throw new RangeError("invalid multiChainMerkleProof length.");let a=(e/64-1).toString(16);return a=a.length%2==0?"0x"+a:"0x0"+a,s(["bytes1","uint48","uint48","bytes"],[a,r,i,t.multiChainMerkleProof+o.slice(2)])}return s(["bytes1","uint48","uint48","bytes"],["0x00",r,i,o])}return s(["uint48","uint48","bytes"],[r,i,o])}static getSignerLowerCaseAddress(e,t={}){if("string"==typeof e)return e.toLowerCase();{var a,n,r,i,s;const o=null!=(a=t.eip7212WebAuthnPrecompileVerifier)?a:Le.DEFAULT_WEB_AUTHN_PRECOMPILE,l=null!=(n=t.eip7212WebAuthnContractVerifier)?n:Le.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER,c=null!=(r=t.webAuthnSignerFactory)?r:Le.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,d=null!=(i=t.webAuthnSignerSingleton)?i:Le.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON,u=null!=(s=t.webAuthnSignerProxyCreationCode)?s:Le.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE;return Le.createWebAuthnSignerVerifierAddress(e.x,e.y,{eip7212WebAuthnPrecompileVerifier:o,eip7212WebAuthnContractVerifier:l,webAuthnSignerFactory:c,webAuthnSignerSingleton:d,webAuthnSignerProxyCreationCode:u}).toLowerCase()}}static sortSignatures(e,t={}){e.sort((e,a)=>Le.getSignerLowerCaseAddress(e.signer,t).localeCompare(Le.getSignerLowerCaseAddress(a.signer,t)))}static buildSignaturesFromSingerSignaturePairs(e,t={}){Le.sortSignatures(e,t);const a=65*e.length,{segments:n}=e.reduce(({segments:e,offset:n},{signer:r,signature:i,isContractSignature:s})=>{if(s=s||"string"!=typeof r){if("string"!=typeof r){if(null==t.isInit)throw new RangeError("Must define isInit parameter when using WebAuthn");if(t.isInit){var o;r=null!=(o=t.webAuthnSharedSigner)?o:Le.DEFAULT_WEB_AUTHN_SHARED_SIGNER}else{var l,c,d,u,A;const e=null!=(l=t.eip7212WebAuthnPrecompileVerifier)?l:Le.DEFAULT_WEB_AUTHN_PRECOMPILE,a=null!=(c=t.eip7212WebAuthnContractVerifier)?c:Le.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER,n=null!=(d=t.webAuthnSignerFactory)?d:Le.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,i=null!=(u=t.webAuthnSignerSingleton)?u:Le.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON,s=null!=(A=t.webAuthnSignerProxyCreationCode)?A:Le.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE;r=Le.createWebAuthnSignerVerifierAddress(r.x,r.y,{eip7212WebAuthnPrecompileVerifier:e,eip7212WebAuthnContractVerifier:a,webAuthnSignerFactory:n,webAuthnSignerSingleton:i,webAuthnSignerProxyCreationCode:s})}}return{segments:[...e,h.solidityPacked(["uint256","uint256","uint8"],[r,a+n,0])],offset:n+32+h.dataLength(i)}}return{segments:[...e,h.solidityPacked(["bytes"],[i])],offset:n}},{segments:[],offset:0});return h.concat([...n,...e.map(({signer:e,signature:t,isContractSignature:a})=>(a=a||"string"!=typeof e)?h.solidityPacked(["uint256","bytes"],[h.dataLength(t),t]):"0x")])}static createWebAuthnSignature(e){return h.AbiCoder.defaultAbiCoder().encode(["bytes","bytes","uint256[2]"],[new Uint8Array(e.authenticatorData),e.clientDataFields,e.rs])}async createSwapOwnerMetaTransactions(e,t,a,n={}){var r;let i,s,o=null;const l=null!=(r=n.webAuthnSignerProxyCreationCode)?r:Le.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE;"string"!=typeof t?(i=Le.createWebAuthnSignerVerifierAddress(t.x,t.y,{eip7212WebAuthnPrecompileVerifier:n.eip7212WebAuthnPrecompileVerifier,eip7212WebAuthnContractVerifier:n.eip7212WebAuthnContractVerifier,webAuthnSignerFactory:n.webAuthnSignerFactory,webAuthnSignerSingleton:n.webAuthnSignerSingleton,webAuthnSignerProxyCreationCode:l}),(await Z(e,i,"latest")).length<3&&(o=Le.createDeployWebAuthnVerifierMetaTransaction(t.x,t.y,{eip7212WebAuthnPrecompileVerifier:n.eip7212WebAuthnPrecompileVerifier,eip7212WebAuthnContractVerifier:n.eip7212WebAuthnContractVerifier,webAuthnSignerFactory:n.webAuthnSignerFactory}))):i=t,s="string"!=typeof a?Le.createWebAuthnSignerVerifierAddress(a.x,a.y,{eip7212WebAuthnPrecompileVerifier:n.eip7212WebAuthnPrecompileVerifier,eip7212WebAuthnContractVerifier:n.eip7212WebAuthnContractVerifier,webAuthnSignerFactory:n.webAuthnSignerFactory,webAuthnSignerSingleton:n.webAuthnSignerSingleton,webAuthnSignerProxyCreationCode:l}):a;let c=n.prevOwner;if(null==c){const t=await this.getOwners(e),a=t.indexOf(s);if(-1==a)throw new RangeError("oldOwner is not a current owner.");c=0==a?"0x0000000000000000000000000000000000000001":t[a-1]}const d=this.createStandardSwapOwnerMetaTransaction(i,s,c);return null==o?[d]:[o,d]}async createRemoveOwnerMetaTransaction(e,t,a,n={}){let r;if("string"!=typeof t){var i;const e=null!=(i=n.webAuthnSignerProxyCreationCode)?i:Le.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE;r=Le.createWebAuthnSignerVerifierAddress(t.x,t.y,{eip7212WebAuthnPrecompileVerifier:n.eip7212WebAuthnPrecompileVerifier,eip7212WebAuthnContractVerifier:n.eip7212WebAuthnContractVerifier,webAuthnSignerFactory:n.webAuthnSignerFactory,webAuthnSignerSingleton:n.webAuthnSignerSingleton,webAuthnSignerProxyCreationCode:e})}else r=t;let s=n.prevOwner;if(null==s){const t=await this.getOwners(e),a=t.indexOf(r);if(-1==a)throw new RangeError("ownerToDelete is not a current owner.");s=0==a?"0x0000000000000000000000000000000000000001":t[a-1]}return this.createStandardRemoveOwnerMetaTransaction(r,a,s)}async createAddOwnerWithThresholdMetaTransactions(e,t,a={}){let n,r=null;if("string"!=typeof e){var i;const t=null!=(i=a.webAuthnSignerProxyCreationCode)?i:Le.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE;if(n=Le.createWebAuthnSignerVerifierAddress(e.x,e.y,{eip7212WebAuthnPrecompileVerifier:a.eip7212WebAuthnPrecompileVerifier,eip7212WebAuthnContractVerifier:a.eip7212WebAuthnContractVerifier,webAuthnSignerFactory:a.webAuthnSignerFactory,webAuthnSignerSingleton:a.webAuthnSignerSingleton,webAuthnSignerProxyCreationCode:t}),null==a.nodeRpcUrl)throw new RangeError("overrides.nodeRpcUrl can't be null if adding a webauthn owner");(await Z(a.nodeRpcUrl,n,"latest")).length<3&&(r=Le.createDeployWebAuthnVerifierMetaTransaction(e.x,e.y,{eip7212WebAuthnPrecompileVerifier:a.eip7212WebAuthnPrecompileVerifier,eip7212WebAuthnContractVerifier:a.eip7212WebAuthnContractVerifier,webAuthnSignerFactory:a.webAuthnSignerFactory}))}else n=e;const s=this.createStandardAddOwnerWithThresholdMetaTransaction(n,t);return null==r?[s]:[r,s]}createStandardAddOwnerWithThresholdMetaTransaction(e,t){const a=k("0x0d582f13",["address","uint256"],[e,t]);return{to:this.accountAddress,data:a,value:0n}}createStandardSwapOwnerMetaTransaction(e,t,a){const n=k("0xe318b52b",["address","address","address"],[a,t,e]);return{to:this.accountAddress,data:n,value:0n}}createStandardRemoveOwnerMetaTransaction(e,t,a){const n=k("0xf8dc5dd9",["address","address","uint256"],[a,e,t]);return{to:this.accountAddress,data:n,value:0n}}createChangeThresholdMetaTransaction(e){if(e<1)throw new RangeError("threshold can't be less than 1.");const t=k("0x694e80c3",["uint256"],[e]);return{to:this.accountAddress,data:t,value:0n}}createApproveHashMetaTransaction(e){const t=k("0xd4d9bdcd",["bytes32"],[e]);return{to:this.accountAddress,data:t,value:0n}}static createDeployWebAuthnVerifierMetaTransaction(e,t,a={}){var n,r,i;const s=null!=(n=a.eip7212WebAuthnPrecompileVerifier)?n:Le.DEFAULT_WEB_AUTHN_PRECOMPILE,o=null!=(r=a.eip7212WebAuthnContractVerifier)?r:Le.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER;return{to:null!=(i=a.webAuthnSignerFactory)?i:Le.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,value:0n,data:k("0x0d2f0489",["uint256","uint256","uint176"],[e,t,"0x"+s.slice(-4)+o.slice(2)])}}async getOwners(e){const a=k(z("getOwners()"),[],[]),n={to:this.accountAddress,data:a},r=await q(e,n,"latest");return t.defaultAbiCoder().decode(["address[]"],r)[0]}async getThreshold(e){const a=k("0xe75235b8",[],[]),n={to:this.accountAddress,data:a},r=await q(e,n,"latest"),i=t.defaultAbiCoder().decode(["uint256"],r);return Number(i[0])}async getModules(e,a={}){try{let n=a.start;null==n&&(n="0x0000000000000000000000000000000000000001");let r=a.pageSize;null==r&&(r=10n);const i=k("0xcc2f8452",["address","uint256"],[n,r]),s={to:this.accountAddress,data:i},o=await q(e,s,"latest");if("0x"==o)throw new M("BAD_DATA","getModules retuned an empty result, the target account is probably not deployed yet.");const l=t.defaultAbiCoder().decode(["address[]","address"],o);return[l[0],l[1]]}catch(e){const t=V(e);throw new M("BAD_DATA","getModules failed",{cause:t})}}async isModuleEnabled(e,a){const n=k(z("isModuleEnabled(address)"),["address"],[a]),r={to:this.accountAddress,data:n},i=await q(e,r,"latest");return t.defaultAbiCoder().decode(["bool"],i)[0]}static createDummySignerSignaturePairForExpectedSigners(e,t={}){const a=[...e],n=[];for(let e of a){let a;if("string"==typeof e)a=Fe;else{if(null==t.isInit)throw new RangeError("Must define isInit parameter when using WebAuthn");if(a=m({},Te),t.isInit){var r;const e=null!=(r=t.webAuthnSharedSigner)?r:Le.DEFAULT_WEB_AUTHN_SHARED_SIGNER;a.signer=e}else{var i,s,o,l,c;const n=null!=(i=t.eip7212WebAuthnPrecompileVerifier)?i:Le.DEFAULT_WEB_AUTHN_PRECOMPILE,r=null!=(s=t.eip7212WebAuthnContractVerifier)?s:Le.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER,d=null!=(o=t.webAuthnSignerFactory)?o:Le.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,u=null!=(l=t.webAuthnSignerSingleton)?l:Le.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON,A=null!=(c=t.webAuthnSignerProxyCreationCode)?c:Le.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE;a.signer=Le.createWebAuthnSignerVerifierAddress(e.x,e.y,{eip7212WebAuthnPrecompileVerifier:n,eip7212WebAuthnContractVerifier:r,webAuthnSignerFactory:d,webAuthnSignerSingleton:u,webAuthnSignerProxyCreationCode:A})}}n.push(a)}return n}static async verifyWebAuthnSignatureForMessageHash(e,a,n,r,i={}){var s,o,l;if(66!=n.length||"0x"!=n.slice(0,2))throw new RangeError("Invalide messageHash ,must be a 0x prefixed keccak256 hash.");const c=null!=(s=i.eip7212WebAuthnPrecompileVerifier)?s:Le.DEFAULT_WEB_AUTHN_PRECOMPILE,d=null!=(o=i.eip7212WebAuthnContractVerifier)?o:Le.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER,u=null!=(l=i.webAuthnSignerSingleton)?l:Le.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON;if(42!=c.length||c.slice(0,38)!=y.slice(0,38))throw new RangeError("Invalide precompile address. It should have the format 0x000000000000000000000000000000000000____");const A="0x1111111111111111111111111111111111111111",f={to:A,data:k("0x1626ba7e",["bytes32","bytes"],[n,r])},h=Le.createSafeWebAuthnSignerProxyDeployedByteCode(a,c,d,u),p=await q(e,f,"latest",{[A]:{code:h}});return t.defaultAbiCoder().decode(["bool"],p)[0]}static createSafeWebAuthnSignerProxyDeployedByteCode(e,a,n,r){const i=t.defaultAbiCoder(),s=i.encode(["uint256"],[e.x]),o=i.encode(["uint256"],[e.y]);return"0x608060408190527f"+i.encode(["uint176"],["0x"+a.slice(-4)+n.slice(2)]).slice(2)+"3660b681018290527f"+o.slice(2)+"60a082018190527f"+s.slice(2)+"8285018190527f000000000000000000000000"+r.slice(2)+"9490939192600082376000806056360183885af490503d6000803e8060c3573d6000fd5b503d6000f3fea2646970667358221220ddd9bb059ba7a6497d560ca97aadf4dbf0476f578378554a50d41c6bb654beae64736f6c63430008180033"}static createEnableModuleMetaTransaction(e,t){return{to:t,data:k("0x610b5925",["address"],[e]),value:0n}}async createDisableModuleMetaTransaction(e,t,a,n={}){try{let r=n.prevModuleAddress;if(null==r){const[a,i]=await this.getModules(e,{start:n.modulesStart,pageSize:n.modulesPageSize}),s=a.indexOf(t);if(-1==s)throw new RangeError("moduleToDisable "+t+" is not an enabled module.");if(0==s)r="0x0000000000000000000000000000000000000001";else{if(!(s>0))throw new RangeError("Invalid module index for "+t);r=a[s-1]}}return Le.createStandardDisableModuleMetaTransaction(t,r,a)}catch(e){const t=V(e);throw new M("BAD_DATA","createDisableModuleMetaTransaction failed",{cause:t})}}static createStandardDisableModuleMetaTransaction(e,t,a){return{to:a,data:k("0xe009cfde",["address","address"],[t,e]),value:0n}}async simulateCallDataWithTenderlyAndCreateShareLink(e,t,a,n=null,r,i,s=null,o={}){var l;let c=!1;if(null==n&&null==o.isInit)throw new RangeError("nodeRpcUrl and overrides.isInit can't both be null");c=null==o.isInit?0n==await K(n,this.entrypointAddress,this.accountAddress):o.isInit;let d="0x";return d=null==o.callData?1==i.length?Le.createAccountCallDataSingleTransaction(i[0],{safeModuleExecutorFunctionSelector:o.safeModuleExecutorFunctionSelector}):Le.createAccountCallDataBatchTransactions(i,{safeModuleExecutorFunctionSelector:o.safeModuleExecutorFunctionSelector,multisendContractAddress:o.multisendContractAddress}):o.callData,null==(l=o.createShareLink)||l?await Se(e,t,a,r,this.entrypointAddress,this.accountAddress,d,c?this.factoryAddress:null,c?this.factoryData:null,s):{simulation:await be(e,t,a,r,this.entrypointAddress,this.accountAddress,d,c?this.factoryAddress:null,c?this.factoryData:null,s)}}getSafeMessageEip712Data(e,t){return ve(this.accountAddress,e,t)}}function Ie(e){if(0===e.length)throw new Error("Cannot create Merkle tree with empty hash list");const t=[...e];let n=[...e];const r=[n];for(;n.length>1;){const e=[];for(let t=0;t<n.length;t+=2)e.push(a((i=n[t])<(s=t+1<n.length?n[t+1]:n[t])?i+s.slice(2):s+i.slice(2)));r.push(e),n=e}var i,s;const o=r[r.length-1][0],l=t.map((e,t)=>{const a=[];let n=t;for(let e=0;e<r.length-1;e++){const t=r[e];a.push(n%2==1?t[n-1]:n+1<t.length?t[n+1]:t[n]),n=Math.floor(n/2)}let i=o;return a.reverse().forEach(e=>{i+=e.slice(2)}),i});return[o,l]}Le.DEFAULT_WEB_AUTHN_SHARED_SIGNER="0xfD90FAd33ee8b58f32c00aceEad1358e4AFC23f9",Le.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON="0x270D7E4a57E6322f336261f3EaE2BADe72E68d72",Le.DEFAULT_WEB_AUTHN_SIGNER_FACTORY="0xF7488fFbe67327ac9f37D5F722d83Fc900852Fbf",Le.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER="0x445a0683e494ea0c5AF3E83c5159fBE47Cf9e765",Le.DEFAULT_WEB_AUTHN_PRECOMPILE="0x0000000000000000000000000000000000000000",Le.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE="0x61010060405234801561001157600080fd5b506040516101ee3803806101ee83398101604081905261003091610058565b6001600160a01b0390931660805260a09190915260c0526001600160b01b031660e0526100bc565b6000806000806080858703121561006e57600080fd5b84516001600160a01b038116811461008557600080fd5b60208601516040870151606088015192965090945092506001600160b01b03811681146100b157600080fd5b939692955090935050565b60805160a05160c05160e05160ff6100ef60003960006008015260006031015260006059015260006080015260ff6000f3fe608060408190527f00000000000000000000000000000000000000000000000000000000000000003660b681018290527f000000000000000000000000000000000000000000000000000000000000000060a082018190527f00000000000000000000000000000000000000000000000000000000000000008285018190527f00000000000000000000000000000000000000000000000000000000000000009490939192600082376000806056360183885af490503d6000803e8060c3573d6000fd5b503d6000f3fea2646970667358221220ddd9bb059ba7a6497d560ca97aadf4dbf0476f578378554a50d41c6bb654beae64736f6c63430008180033",Le.DEFAULT_MULTISEND_CONTRACT_ADDRESS="0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526",Le.initializerFunctionSelector="0xb63e800d",Le.initializerFunctionInputAbi=["address[]","uint256","address","bytes","address","address","uint256","address"],Le.DEFAULT_EXECUTOR_FUCNTION_SELECTOR=we.executeUserOpWithErrorString,Le.executorFunctionInputAbi=["address","uint256","bytes","uint8"];class Ge extends Le{constructor(e,t={}){var a,n;super(e,null!=(a=t.safe4337ModuleAddress)?a:Ge.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(n=t.entrypointAddress)?n:Ge.DEFAULT_ENTRYPOINT_ADDRESS,{onChainIdentifierParams:t.onChainIdentifierParams,onChainIdentifier:t.onChainIdentifier,safeAccountSingleton:t.safeAccountSingleton})}static createAccountAddress(e,t={}){var a,n,r,i;const s=m({},t,{eip7212WebAuthnPrecompileVerifierForSharedSigner:null!=(a=t.eip7212WebAuthnPrecompileVerifierForSharedSigner)?a:Ge.DEFAULT_WEB_AUTHN_PRECOMPILE,eip7212WebAuthnContractVerifierForSharedSigner:null!=(n=t.eip7212WebAuthnContractVerifierForSharedSigner)?n:Ge.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER}),[o,,]=Le.createAccountAddressAndFactoryAddressAndData(e,s,null!=(r=t.safe4337ModuleAddress)?r:Ge.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(i=t.safeModuleSetupAddress)?i:Ge.DEFAULT_SAFE_MODULE_SETUP_ADDRESS);return o}static initializeNewAccount(e,t={}){var a,n,r,i;let s=!1,o=0n,l=0n;for(const t of e)if("string"!=typeof t){if(s)throw new RangeError("Only one Webauthn signer is allowed during initialization");if(0!=e.indexOf(t))throw new RangeError("Webauthn owner has to be the first owner for an init transaction.");s=!0,o=t.x,l=t.y}const c=m({},t,{eip7212WebAuthnPrecompileVerifierForSharedSigner:null!=(a=t.eip7212WebAuthnPrecompileVerifierForSharedSigner)?a:Ge.DEFAULT_WEB_AUTHN_PRECOMPILE,eip7212WebAuthnContractVerifierForSharedSigner:null!=(n=t.eip7212WebAuthnContractVerifierForSharedSigner)?n:Ge.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER}),[d,u,A]=Le.createAccountAddressAndFactoryAddressAndData(e,c,null!=(r=t.safe4337ModuleAddress)?r:Ge.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(i=t.safeModuleSetupAddress)?i:Ge.DEFAULT_SAFE_MODULE_SETUP_ADDRESS),f=new Ge(d,{safe4337ModuleAddress:t.safe4337ModuleAddress,entrypointAddress:t.entrypointAddress,onChainIdentifierParams:t.onChainIdentifierParams,onChainIdentifier:t.onChainIdentifier,safeAccountSingleton:t.safeAccountSingleton});return f.factoryAddress=u,f.factoryData=A,s&&(f.isInitWebAuthn=!0,f.x=o,f.y=l),f}static getUserOperationEip712Hash(e,t,a={}){var n,r,i,s;const o=null!=(n=a.validAfter)?n:0n,l=null!=(r=a.validUntil)?r:0n,c=null!=(i=a.entrypointAddress)?i:Ge.DEFAULT_ENTRYPOINT_ADDRESS,d=null!=(s=a.safe4337ModuleAddress)?s:Ge.DEFAULT_SAFE_4337_MODULE_ADDRESS;return Le.getUserOperationEip712Hash(e,t,{validAfter:o,validUntil:l,entrypointAddress:c,safe4337ModuleAddress:d})}static getUserOperationEip712Data(e,t,a={}){var n,r,i,s;const o=null!=(n=a.validAfter)?n:0n,l=null!=(r=a.validUntil)?r:0n,c=null!=(i=a.entrypointAddress)?i:Ge.DEFAULT_ENTRYPOINT_ADDRESS,d=null!=(s=a.safe4337ModuleAddress)?s:Ge.DEFAULT_SAFE_4337_MODULE_ADDRESS;return Le.getUserOperationEip712Data(e,t,{validAfter:o,validUntil:l,entrypointAddress:c,safe4337ModuleAddress:d})}static createInitializerCallData(e,t,a={}){var n,r,i,s;const o=null!=(n=a.safe4337ModuleAddress)?n:Ge.DEFAULT_SAFE_4337_MODULE_ADDRESS,l=null!=(r=a.safeModuleSetupAddress)?r:Ge.DEFAULT_SAFE_MODULE_SETUP_ADDRESS;return Le.createBaseInitializerCallData(e,t,o,l,a.multisendContractAddress,a.webAuthnSharedSigner,null!=(i=a.eip7212WebAuthnPrecompileVerifierForSharedSigner)?i:Ge.DEFAULT_WEB_AUTHN_PRECOMPILE,null!=(s=a.eip7212WebAuthnContractVerifierForSharedSigner)?s:Ge.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER)}static createFactoryAddressAndData(e,t={}){var a,n,r,i;const s=m({},t,{eip7212WebAuthnPrecompileVerifierForSharedSigner:null!=(a=t.eip7212WebAuthnPrecompileVerifierForSharedSigner)?a:Ge.DEFAULT_WEB_AUTHN_PRECOMPILE,eip7212WebAuthnContractVerifierForSharedSigner:null!=(n=t.eip7212WebAuthnContractVerifierForSharedSigner)?n:Ge.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER});return Le.createFactoryAddressAndData(e,s,null!=(r=t.safe4337ModuleAddress)?r:Ge.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(i=t.safeModuleSetupAddress)?i:Ge.DEFAULT_SAFE_MODULE_SETUP_ADDRESS)}async createUserOperation(e,t,a,n={}){var r,i;const s=n.parallelPaymasterInitValues;if(null!=s&&"0x22e325a297439656"!=s.paymasterData)throw new RangeError("Invalid paymasterData override, the only valid value is 0x22e325a297439656.");const[o,l,c]=await this.createBaseUserOperationAndFactoryAddressAndFactoryData(e,!1,t,a,m({},n,{isMultiChainSignature:!0,eip7212WebAuthnPrecompileVerifier:null!=(r=n.eip7212WebAuthnPrecompileVerifier)?r:Ge.DEFAULT_WEB_AUTHN_PRECOMPILE,eip7212WebAuthnContractVerifier:null!=(i=n.eip7212WebAuthnContractVerifier)?i:Ge.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER}));return null!=s?m({},o,{factory:l,factoryData:c},s,{eip7702Auth:null}):m({},o,{factory:l,factoryData:c,paymaster:null,paymasterVerificationGasLimit:null,paymasterPostOpGasLimit:null,paymasterData:null,eip7702Auth:null})}signUserOperation(e,t,a,n={}){return Le.baseSignSingleUserOperation(e,t,a,this.entrypointAddress,this.safe4337ModuleAddress,m({},n,{isMultiChainSignature:!0}))}signUserOperations(e,t){if(e.length<1)throw new RangeError("There should be at least one userOperationsToSign");if(t.length<1)throw new RangeError("There should be at least one privateKey");if(e.length>1){const a=[];e.forEach((e,t)=>{const n=Le.getUserOperationEip712Hash_V9(e.userOperation,e.chainId,{validAfter:e.validAfter,validUntil:e.validUntil,safe4337ModuleAddress:this.safe4337ModuleAddress,entrypointAddress:this.entrypointAddress});a.push(n)});const[n,r]=Ie(a),i=f.hash({verifyingContract:this.safe4337ModuleAddress},U,{merkleTreeRoot:n}),s=[];for(const e of t){const t=new l(e),a=t.signingKey.sign(i).serialized;s.push({signer:t.address,signature:a})}const o=[];return e.forEach((e,t)=>{o.push(Le.formatSignaturesToUseroperationSignature(s,{validAfter:e.validAfter,validUntil:e.validUntil,isMultiChainSignature:!0,multiChainMerkleProof:r[t]}))}),o}return[this.signUserOperation(e[0].userOperation,t,e[0].chainId,{validUntil:e[0].validUntil,validAfter:e[0].validAfter})]}static getMultiChainSingleSignatureUserOperationsEip712Hash(e,t={}){const a=Ge.getMultiChainSingleSignatureUserOperationsEip712Data(e,t);return f.hash(a.domain,a.types,a.messageValue)}static getMultiChainSingleSignatureUserOperationsEip712Data(e,t={}){var a;if(e.length<1)throw new RangeError("There should be at least one userOperationsToSign");const n=null!=(a=t.safe4337ModuleAddress)?a:Ge.DEFAULT_SAFE_4337_MODULE_ADDRESS,r=[];e.forEach((e,a)=>{const i=Le.getUserOperationEip712Hash_V9(e.userOperation,e.chainId,{validAfter:e.validAfter,validUntil:e.validUntil,safe4337ModuleAddress:n,entrypointAddress:t.entrypointAddress});r.push(i)});const[i,s]=Ie(r);return{domain:{verifyingContract:n},types:U,messageValue:{merkleTreeRoot:i}}}static formatSignaturesToUseroperationsSignatures(e,t,a={}){if(e.length<1)throw new RangeError("There should be at least one userOperationsToSign");const n=m({eip7212WebAuthnPrecompileVerifier:Ge.DEFAULT_WEB_AUTHN_PRECOMPILE,eip7212WebAuthnContractVerifier:Ge.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER,safe4337ModuleAddress:Ge.DEFAULT_SAFE_4337_MODULE_ADDRESS},a);if(1===e.length)return[Le.formatSignaturesToUseroperationSignature(t,m({},n,{isMultiChainSignature:!0}))];const r=[];e.forEach((e,t)=>{const a=Le.getUserOperationEip712Hash_V9(e.userOperation,e.chainId,{validAfter:e.validAfter,validUntil:e.validUntil,safe4337ModuleAddress:n.safe4337ModuleAddress});r.push(a)});const[i,s]=Ie(r),o=[];return e.forEach((e,a)=>{o.push(Le.formatSignaturesToUseroperationSignature(t,m({},n,{isMultiChainSignature:!0,multiChainMerkleProof:s[a]})))}),o}static createWebAuthnSignerVerifierAddress(e,t,a={}){var n,r;return Le.createWebAuthnSignerVerifierAddress(e,t,m({},a,{eip7212WebAuthnPrecompileVerifier:null!=(n=a.eip7212WebAuthnPrecompileVerifier)?n:Ge.DEFAULT_WEB_AUTHN_PRECOMPILE,eip7212WebAuthnContractVerifier:null!=(r=a.eip7212WebAuthnContractVerifier)?r:Ge.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER}))}static createDeployWebAuthnVerifierMetaTransaction(e,t,a={}){var n,r;return Le.createDeployWebAuthnVerifierMetaTransaction(e,t,m({},a,{eip7212WebAuthnPrecompileVerifier:null!=(n=a.eip7212WebAuthnPrecompileVerifier)?n:Ge.DEFAULT_WEB_AUTHN_PRECOMPILE,eip7212WebAuthnContractVerifier:null!=(r=a.eip7212WebAuthnContractVerifier)?r:Ge.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER}))}static createDummySignerSignaturePairForExpectedSigners(e,t={}){var a,n;return Le.createDummySignerSignaturePairForExpectedSigners(e,m({},t,{eip7212WebAuthnPrecompileVerifier:null!=(a=t.eip7212WebAuthnPrecompileVerifier)?a:Ge.DEFAULT_WEB_AUTHN_PRECOMPILE,eip7212WebAuthnContractVerifier:null!=(n=t.eip7212WebAuthnContractVerifier)?n:Ge.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER}))}static async verifyWebAuthnSignatureForMessageHash(e,t,a,n,r={}){var i,s;return Le.verifyWebAuthnSignatureForMessageHash(e,t,a,n,m({},r,{eip7212WebAuthnPrecompileVerifier:null!=(i=r.eip7212WebAuthnPrecompileVerifier)?i:Ge.DEFAULT_WEB_AUTHN_PRECOMPILE,eip7212WebAuthnContractVerifier:null!=(s=r.eip7212WebAuthnContractVerifier)?s:Ge.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER}))}}var Oe;Ge.DEFAULT_ENTRYPOINT_ADDRESS=g,Ge.DEFAULT_SAFE_4337_MODULE_ADDRESS="0x22939E839e3c0F479B713eAF95e0df128554AEAd",Ge.DEFAULT_SAFE_MODULE_SETUP_ADDRESS="0x2dd68b007B46fBe91B9A7c3EDa5A7a1063cB5b47",Ge.DEFAULT_WEB_AUTHN_PRECOMPILE="0x0000000000000000000000000000000000000100",Ge.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER="0xc2b78104907F722DABAc4C69f826a522B2754De4",function(e){e[e.P256=0]="P256",e[e.WebAuthnP256=1]="WebAuthnP256",e[e.Secp256k1=2]="Secp256k1"}(Oe||(Oe={}));const Me=R,Ve="0x0000000000000000000000000000000000000000000000000000000000000000",Be="0x8dd7712f",Ne="0xa58bb84a";class We extends p{static createDummyWebAuthnSignature(e){const a=t.defaultAbiCoder();return a.encode(["bytes32","bytes","bytes"],[e,a.encode(["(bytes,string,uint256,uint256,uint256,uint256)"],[["0x49960de5880e8c687434170f6476605b8fe4aeb9a28632c7995cf3ba831d97630500000000",'{"type":"webauthn.get","challenge":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA","origin":"https://example.com","crossOrigin":false}',36n,8n,BigInt("0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0"),BigInt("0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0")]]),"0x"])}static wrapSignature(e,a,n="0x"){return t.defaultAbiCoder().encode(["bytes32","bytes","bytes"],[e,a,n])}constructor(e,t={}){var a,n;super(e),this.entrypointAddress=void 0,this.delegateeAddress=void 0,this.entrypointAddress=null!=(a=t.entrypointAddress)?a:E,this.delegateeAddress=null!=(n=t.delegateeAddress)?n:Me}getUserOperationHash(e,t){return N(e,this.entrypointAddress,t)}static createAccountCallData(e,a=!0){const n=t.defaultAbiCoder(),r=e.map(e=>[e.to,e.value,e.data]),i=n.encode(["((address,uint256,bytes)[],bool)"],[[r,a]]);return Be+i.slice(2)}async createUserOperation(e,t,a,n={}){var r,i,s,o,l,c,d,u,A,f,h;if(e.length<1)throw new RangeError("There should be at least one transaction");let p=null,y=null;if(null==n.nonce){if(null==t)throw new M("BAD_DATA","providerRpc can't be null if nonce is not overridden");y=K(t,this.entrypointAddress,this.accountAddress)}else p=n.nonce;if("bigint"==typeof n.maxFeePerGas&&n.maxFeePerGas<0n)throw new RangeError("maxFeePerGas override can't be negative");if("bigint"==typeof n.maxPriorityFeePerGas&&n.maxPriorityFeePerGas<0n)throw new RangeError("maxPriorityFeePerGas override can't be negative");let g=w.maxFeePerGas,E=w.maxPriorityFeePerGas,D=null;null!=n.maxFeePerGas&&null!=n.maxPriorityFeePerGas||(D=ee(t,n.polygonGasStation,n.gasLevel));let S=null,b=null,_=null;var F,T;if(null!=n.eip7702Auth&&(S=n.eip7702Auth.chainId,b=null!=(F=n.eip7702Auth.address)?F:this.delegateeAddress,_=null!=(T=n.eip7702Auth.nonce)?T:null),null!=n.eip7702Auth&&null==_){let e;if(null==t)throw new M("BAD_DATA","providerRpc can't be null if eoaDelegatorNonce is not overriden");e=Y(t,"eth_getTransactionCount",[this.accountAddress,"latest"]),null!=D&&null!=y?await Promise.all([e,y,D]).then(e=>{_=BigInt(e[0]),p=e[1],[g,E]=e[2]}):null!=D?await Promise.all([e,D]).then(e=>{_=BigInt(e[0]),[g,E]=e[1]}):null!=y?await Promise.all([e,y]).then(e=>{_=BigInt(e[0]),p=e[1]}):_=BigInt(await e)}else null!=D&&null!=y?await Promise.all([y,D]).then(e=>{p=e[0],[g,E]=e[1]}):null!=D?[g,E]=await D:null!=y&&(p=await y);if(g=null!=(r=n.maxFeePerGas)?r:BigInt(Math.floor(Number(g)*(((null!=(i=n.maxFeePerGasPercentageMultiplier)?i:0)+100)/100))),E=null!=(s=n.maxPriorityFeePerGas)?s:BigInt(Math.floor(Number(E)*(((null!=(o=n.maxPriorityFeePerGasPercentageMultiplier)?o:0)+100)/100))),null==p)throw new RangeError("failed to determine nonce");if(p<0n)throw new RangeError("nonce can't be negative");let P="0x";var x;P=null==n.callData?We.createAccountCallData(e,null==(x=n.revertOnFailure)||x):n.callData;const U=n.paymasterFields;let C;if(null!=n.eip7702Auth){var R,v,L,I,G,O,V;const e=null!=(R=n.eip7702Auth.yParity)?R:"0x0";if("0x0"!=e&&"0x00"!=e&&"0x1"!=e&&"0x01"!=e)throw new M("BAD_DATA","invalid yParity value for eoaDelegatorSignature. must be '0x0' or '0x1'");const t={chainId:de(S),address:b,nonce:de(_),yParity:e,r:null!=(v=n.eip7702Auth.r)?v:"0x4277ba564d2c138823415df0ec8e8f97f30825056d54ec5128a8b29ec2dd81b2",s:null!=(L=n.eip7702Auth.s)?L:"0x1075a1bec7f59848cca899ece93075199cd2aabceb0654b9ae00b881a30044cd"};C=m({},w,{sender:this.accountAddress,nonce:p,callData:P,maxFeePerGas:g,maxPriorityFeePerGas:E,factory:"0x7702",factoryData:null,paymaster:null!=(I=null==U?void 0:U.paymaster)?I:null,paymasterVerificationGasLimit:null!=(G=null==U?void 0:U.paymasterVerificationGasLimit)?G:null,paymasterPostOpGasLimit:null!=(O=null==U?void 0:U.paymasterPostOpGasLimit)?O:null,paymasterData:null!=(V=null==U?void 0:U.paymasterData)?V:null,eip7702Auth:t})}else{var B,N,W,H;C=m({},w,{sender:this.accountAddress,nonce:p,callData:P,maxFeePerGas:g,maxPriorityFeePerGas:E,factory:null,factoryData:null,paymaster:null!=(B=null==U?void 0:U.paymaster)?B:null,paymasterVerificationGasLimit:null!=(N=null==U?void 0:U.paymasterVerificationGasLimit)?N:null,paymasterPostOpGasLimit:null!=(W=null==U?void 0:U.paymasterPostOpGasLimit)?W:null,paymasterData:null!=(H=null==U?void 0:U.paymasterData)?H:null,eip7702Auth:null})}let k=w.preVerificationGas,z=w.verificationGasLimit,X=w.callGasLimit;if(null==n.preVerificationGas||null==n.verificationGasLimit||null==n.callGasLimit){if(null==a)throw new M("BAD_DATA","bundlerRpc can't be null if preVerificationGas,verificationGasLimit and callGasLimit are not overriden");{var j;C.callGasLimit=0n,C.verificationGasLimit=0n,C.preVerificationGas=0n;const e=C.maxFeePerGas,t=C.maxPriorityFeePerGas;C.maxFeePerGas=0n,C.maxPriorityFeePerGas=0n;const r=m({},C);r.signature=null!=(j=n.dummySignature)?j:We.dummySignature;const i=new ue(a),s=await i.estimateUserOperationGas(r,this.entrypointAddress,n.state_override_set);k=BigInt(s.preVerificationGas),z=BigInt(s.verificationGasLimit),X=BigInt(s.callGasLimit),z+=55000n,C.maxFeePerGas=e,C.maxPriorityFeePerGas=t}}if("bigint"==typeof n.preVerificationGas&&n.preVerificationGas<0n)throw new RangeError("preVerificationGas override can't be negative");if("bigint"==typeof n.verificationGasLimit&&n.verificationGasLimit<0n)throw new RangeError("verificationGasLimit override can't be negative");if("bigint"==typeof n.callGasLimit&&n.callGasLimit<0n)throw new RangeError("callGasLimit override can't be negative");return C.preVerificationGas=null!=(l=n.preVerificationGas)?l:BigInt(Math.floor(Number(k)*(((null!=(c=n.preVerificationGasPercentageMultiplier)?c:0)+100)/100))),C.verificationGasLimit=null!=(d=n.verificationGasLimit)?d:BigInt(Math.floor(Number(z)*(((null!=(u=n.verificationGasLimitPercentageMultiplier)?u:0)+100)/100))),C.callGasLimit=null!=(A=n.callGasLimit)?A:BigInt(Math.floor(Number(X)*(((null!=(f=n.callGasLimitPercentageMultiplier)?f:0)+100)/100))),C.signature=null!=(h=n.dummySignature)?h:We.dummySignature,C}signUserOperation(e,t,a,n={}){var r,i;const s=N(e,this.entrypointAddress,a),o=null!=(r=n.keyHash)?r:Ve,c=null!=(i=n.hookData)?i:"0x",d=new l(t).signingKey.sign(s).serialized;return We.wrapSignature(o,d,c)}async signUserOperationWithSigner(e,t,a,n={}){var r,i;const s=N(e,this.entrypointAddress,a),o=null!=(r=n.keyHash)?r:Ve,l=null!=(i=n.hookData)?i:"0x",c=await t(s);return We.wrapSignature(o,c,l)}formatWebAuthnSignature(e,a,n={}){var r;const i=t.defaultAbiCoder(),s=null!=(r=n.hookData)?r:"0x",o=i.encode(["(bytes,string,uint256,uint256,uint256,uint256)"],[[a.authenticatorData,a.clientDataJSON,a.challengeIndex,a.typeIndex,a.r,a.s]]);return i.encode(["bytes32","bytes","bytes"],[e,o,s])}async sendUserOperation(e,t){const a=new ue(t),n=await a.sendUserOperation(e,this.entrypointAddress);return new Ae(n,a,this.entrypointAddress)}static createSecp256k1Key(e){const a=t.defaultAbiCoder();return{keyType:Oe.Secp256k1,publicKey:a.encode(["address"],[e])}}static createWebAuthnP256Key(e,a){const n=t.defaultAbiCoder();return{keyType:Oe.WebAuthnP256,publicKey:n.encode(["uint256","uint256"],[e,a])}}static createP256Key(e,a){const n=t.defaultAbiCoder();return{keyType:Oe.P256,publicKey:n.encode(["uint256","uint256"],[e,a])}}static getKeyHash(e){const n=a(e.publicKey),r=t.defaultAbiCoder().encode(["uint8","bytes32"],[e.keyType,n]);return a(r)}static packKeySettings(e){var t,a;const n=BigInt(null!=(t=e.hook)?t:y),r=BigInt(null!=(a=e.expiration)?a:0);return(e.isAdmin?1n:0n)<<200n|r<<160n|n}static unpackKeySettings(e){return{hook:"0x"+(e&(1n<<160n)-1n).toString(16).padStart(40,"0"),expiration:Number(e>>160n&(1n<<40n)-1n),isAdmin:1n===(e>>200n&1n)}}static createRegisterKeyMetaTransactions(e,a={}){if(!0===a.isAdmin)throw new M("BAD_DATA","createRegisterKeyMetaTransactions does not allow setting isAdmin to true. Encode the calldata manually for admin keys.");const n=t.defaultAbiCoder(),r="0x30b1fa3b"+n.encode(["(uint8,bytes)"],[[e.keyType,e.publicKey]]).slice(2),i=m({},a,{isAdmin:!1}),s=We.getKeyHash(e),o=We.packKeySettings(i),l=Ne+n.encode(["bytes32","uint256"],[s,o]).slice(2);return[{to:y,value:0n,data:r},{to:y,value:0n,data:l}]}static createRevokeKeyMetaTransaction(e){const a="0xb75c7dc6"+t.defaultAbiCoder().encode(["bytes32"],[e]).slice(2);return{to:y,value:0n,data:a}}static createUpdateKeySettingsMetaTransaction(e,a){if(!0===a.isAdmin)throw new M("BAD_DATA","createUpdateKeySettingsMetaTransaction does not allow setting isAdmin to true. Encode the calldata manually for admin keys.");const n=t.defaultAbiCoder(),r=We.packKeySettings(a),i=Ne+n.encode(["bytes32","uint256"],[e,r]).slice(2);return{to:y,value:0n,data:i}}static createInvalidateNonceMetaTransaction(e){const a="0xb70e36f0"+t.defaultAbiCoder().encode(["uint256"],[e]).slice(2);return{to:y,value:0n,data:a}}async isDelegated(e){const t=await Q(this.accountAddress,e);return null!==t&&t.toLowerCase()===this.delegateeAddress.toLowerCase()}async getNonce(e,t=0){return K(e,this.entrypointAddress,this.accountAddress,t)}async isKeyRegistered(e,a){const n=t.defaultAbiCoder(),r="0x27258b22"+n.encode(["bytes32"],[a]).slice(2),i=await Y(e,"eth_call",[{from:y,to:this.accountAddress,data:r},"latest"]);if("string"==typeof i)return n.decode(["bool"],i)[0];throw new M("BAD_DATA","Unexpected response from isRegistered call")}async getKeySettings(e,a){const n=t.defaultAbiCoder(),r="0x0f3ebf6e"+n.encode(["bytes32"],[a]).slice(2),i=await Y(e,"eth_call",[{from:y,to:this.accountAddress,data:r},"latest"]);if("string"==typeof i){const e=n.decode(["uint256"],i);return We.unpackKeySettings(BigInt(e[0]))}throw new M("BAD_DATA","Unexpected response from getKeySettings call")}async getKey(e,a){const n=t.defaultAbiCoder(),r="0x12aaac70"+n.encode(["bytes32"],[a]).slice(2),i=await Y(e,"eth_call",[{from:y,to:this.accountAddress,data:r},"latest"]);if("string"==typeof i){const e=n.decode(["(uint8,bytes)"],i)[0];return{keyType:Number(e[0]),publicKey:e[1]}}throw new M("BAD_DATA","Unexpected response from getKey call")}async listKeys(e){const a=t.defaultAbiCoder(),n=await Y(e,"eth_call",[{from:y,to:this.accountAddress,data:"0xfac750e0"},"latest"]);if("string"!=typeof n)throw new M("BAD_DATA","Unexpected response from keyCount call");const r=Number(BigInt(n)),i=[];for(let t=0;t<r;t++){const n="0x4223b5c2"+a.encode(["uint256"],[t]).slice(2),r=await Y(e,"eth_call",[{from:y,to:this.accountAddress,data:n},"latest"]);if("string"==typeof r){const e=a.decode(["(uint8,bytes)"],r)[0];i.push({keyType:Number(e[0]),publicKey:e[1]})}}return i}prependTokenPaymasterApproveToCallData(e,t,a,n){return We.prependTokenPaymasterApproveToCallDataStatic(e,t,a,n)}static prependTokenPaymasterApproveToCallDataStatic(e,a,n,r){const i=t.defaultAbiCoder(),s=k(z("approve(address,uint256)"),["address","uint256"],[n,r]);if(!e.startsWith(Be))throw new M("BAD_DATA","Invalid calldata, should start with "+Be+" (executeUserOp selector)",{context:{callData:e}});const o=i.decode(["((address,uint256,bytes)[],bool)"],"0x"+e.slice(10)),l=o[0][1],c=o[0][0].map(e=>({to:e[0],value:BigInt(e[1]),data:"string"!=typeof e[2]?(new TextDecoder).decode(e[2]):e[2]}));c.unshift({to:a,value:0n,data:s});const d=c.map(e=>[e.to,e.value,e.data]),u=i.encode(["((address,uint256,bytes)[],bool)"],[[d,l]]);return Be+u.slice(2)}}We.executorFunctionSelector=Be,We.dummySignature=t.defaultAbiCoder().encode(["bytes32","bytes","bytes"],[Ve,"0xd2614025fc173b86704caf37b2fb447f7618101a0d31f5f304c777024cef38a060a29ee43fcf0c46f9107d4f670b8a85c2c017a1fe9e4af891f24f0be6ba5d671c","0x"]);class He{constructor(e){this.moduleAddress=void 0,this.abiCoder=void 0,this.moduleAddress=e,this.abiCoder=t.defaultAbiCoder()}createEnableModuleMetaTransaction(e){return Le.createEnableModuleMetaTransaction(this.moduleAddress,e)}checkForEmptyResultAndRevert(e,t){if("0x"==e)throw new M("BAD_DATA",t+" returned 0x, module contract "+this.moduleAddress+" is probably not deployed")}}var ke;!function(e){e.After3Minutes="0x949d01d424bE050D09C16025dd007CB59b3A8c66",e.After3Days="0x38275826E1933303E508433dD5f289315Da2541c",e.After7Days="0x088f6cfD8BB1dDb1BB069CCb3fc1A98927D233f2",e.After14Days="0x9BacD92F4687Db306D7ded5d4513a51EA05df25b"}(ke||(ke={}));class Ye extends He{constructor(e=Ye.DEFAULT_SOCIAL_RECOVERY_ADDRESS){super(e)}createConfirmRecoveryMetaTransaction(e,t,a,n){const r=k("0x064e2d0e",["address","address[]","uint256","bool"],[e,t,a,n]);return{to:this.moduleAddress,data:r,value:0n}}createMultiConfirmRecoveryMetaTransaction(e,t,a,n,r){const i=k("0x0728e1e7",["address","address[]","uint256","(address,bytes)","bool"],[e,t,a,n.map(e=>[e.signer,e.signature]),r]);return{to:this.moduleAddress,data:i,value:0n}}createExecuteRecoveryMetaTransaction(e,t,a){const n=k("0xb1f85f69",["address","address[]","uint256"],[e,t,a]);return{to:this.moduleAddress,data:n,value:0n}}createFinalizeRecoveryMetaTransaction(e){const t=k("0x315a7af3",["address"],[e]);return{to:this.moduleAddress,data:t,value:0n}}createCancelRecoveryMetaTransaction(){return{to:this.moduleAddress,data:"0x0ba234d6",value:0n}}createAddGuardianWithThresholdMetaTransaction(e,t){const a=k("0xbe0e54d7",["address","uint256"],[e,t]);return{to:this.moduleAddress,data:a,value:0n}}async createRevokeGuardianWithThresholdMetaTransaction(e,t,a,n,r={}){let i=r.prevGuardianAddress;if(null==i){const n=await this.getGuardians(e,t),r=n.indexOf(a);if(-1==r)throw new RangeError(a+" is not a current guardian for account : "+t);if(0==r)i="0x0000000000000000000000000000000000000001";else{if(!(r>0))throw new RangeError("Invalid guardian index");i=n[r-1]}}return this.createStandardRevokeGuardianWithThresholdMetaTransaction(i,a,n)}createStandardRevokeGuardianWithThresholdMetaTransaction(e,t,a){const n=k("0x936f7d86",["address","address","uint256"],[e,t,a]);return{to:this.moduleAddress,data:n,value:0n}}createChangeThresholdMetaTransaction(e){const t=k("0x694e80c3",["uint256"],[e]);return{to:this.moduleAddress,data:t,value:0n}}async getRecoveryHash(e,t,a,n,r){const i=k("0x5f19df08",["address","address[]","uint256","uint256"],[t,a,n,r]),s={to:this.moduleAddress,data:i},o=await q(e,s,"latest");return this.checkForEmptyResultAndRevert(o,"getRecoveryHash"),this.abiCoder.decode(["bytes32"],o)[0]}async getRecoveryRequest(e,t){const a=k("0x4f9a28b9",["address"],[t]),n={to:this.moduleAddress,data:a},r=await q(e,n,"latest");this.checkForEmptyResultAndRevert(r,"getRecoveryRequest");const i=this.abiCoder.decode(["(uint256,uint256,uint64,address[])"],r);return{guardiansApprovalCount:BigInt(i[0][0]),newThreshold:BigInt(i[0][1]),executeAfter:BigInt(i[0][2]),newOwners:i[0][3]}}async getRecoveryApprovals(e,t,a,n){const r=k("0x6c6595ca",["address","address[]","uint256"],[t,a,n]),i={to:this.moduleAddress,data:r},s=await q(e,i,"latest");this.checkForEmptyResultAndRevert(s,"getRecoveryApprovals");const o=this.abiCoder.decode(["uint256"],s);return BigInt(o[0])}async hasGuardianApproved(e,t,a,n,r){const i=k("0x37d82c36",["address","address","address[]","uint256"],[t,a,n,r]),s={to:this.moduleAddress,data:i},o=await q(e,s,"latest");this.checkForEmptyResultAndRevert(o,"hasGuardianApproved");const l=this.abiCoder.decode(["bool"],o);return Boolean(l[0])}async isGuardian(e,t,a){const n=k("0xd4ee9734",["address","address"],[t,a]),r={to:this.moduleAddress,data:n},i=await q(e,r,"latest");this.checkForEmptyResultAndRevert(i,"isGuardian");const s=this.abiCoder.decode(["bool"],i);return Boolean(s[0])}async guardiansCount(e,t){const a=k("0xc026e7ee",["address"],[t]),n={to:this.moduleAddress,data:a},r=await q(e,n,"latest");this.checkForEmptyResultAndRevert(r,"guardiansCount");const i=this.abiCoder.decode(["uint256"],r);return BigInt(i[0])}async threshold(e,t){const a=k("0xc86ec2bf",["address"],[t]),n={to:this.moduleAddress,data:a},r=await q(e,n,"latest");this.checkForEmptyResultAndRevert(r,"threshold");const i=this.abiCoder.decode(["uint256"],r);return BigInt(i[0])}async getGuardians(e,t){const a=k("0xf18858ab",["address"],[t]),n={to:this.moduleAddress,data:a},r=await q(e,n,"latest");return this.checkForEmptyResultAndRevert(r,"threshold"),this.abiCoder.decode(["address[]"],r)[0]}async nonce(e,t){const a=k("0x70ae92d2",["address"],[t]),n={to:this.moduleAddress,data:a},r=await q(e,n,"latest");this.checkForEmptyResultAndRevert(r,"threshold");const i=this.abiCoder.decode(["uint256"],r);return BigInt(i[0])}async getRecoveryRequestEip712Data(e,t,a,n,r,i={}){let s;if(null==i.recoveryNonce){const t=new Ye(this.moduleAddress);s=await t.nonce(e,a)}else s=i.recoveryNonce;const o={wallet:a,newOwners:n,newThreshold:r,nonce:s};return{domain:{name:"Social Recovery Module",version:"0.0.1",chainId:Number(t),verifyingContract:this.moduleAddress},types:Ke,messageValue:o}}}Ye.DEFAULT_SOCIAL_RECOVERY_ADDRESS=ke.After3Days;const ze="ExecuteRecovery",Ke={ExecuteRecovery:[{type:"address",name:"wallet"},{type:"address[]",name:"newOwners"},{type:"uint256",name:"newThreshold"},{type:"uint256",name:"nonce"}]},Xe="0xAA46724893dedD72658219405185Fb0Fc91e091C";class je extends He{constructor(e=je.DEFAULT_ALLOWANCE_MODULE_ADDRESS){super(e)}createOneTimeAllowanceMetaTransaction(e,t,a,n){return this.createBaseSetAllowanceMetaTransaction(e,t,a,0n,n)}createRecurringAllowanceMetaTransaction(e,t,a,n,r){return this.createBaseSetAllowanceMetaTransaction(e,t,a,n,r)}createBaseSetAllowanceMetaTransaction(e,t,a,n,r){const i=k("0xbeaeb388",["address","address","uint96","uint16","uint32"],[e,t,a,n,r]);return{to:this.moduleAddress,data:i,value:0n}}createRenewAllowanceMetaTransaction(e,t){const a=k("0xc19bf50e",["address","address"],[e,t]);return{to:this.moduleAddress,data:a,value:0n}}createDeleteAllowanceMetaTransaction(e,t){const a=k("0x885133e3",["address","address"],[e,t]);return{to:this.moduleAddress,data:a,value:0n}}createAllowanceTransferMetaTransaction(e,t,a,n,r,i={}){var s;let o="0x0000000000000000000000000000000000000000",l=0n;if(null!=i.paymentToken){if(o=i.paymentToken,null==i.paymentAmount)throw new RangeError("must specify paymentAmount if paymentToken is set");l=i.paymentAmount}let c=null!=(s=i.delegateSignature)?s:"0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001";return this.createBaseExecuteAllowanceTransferMetaTransaction(e,t,a,n,o,l,r,c)}createBaseExecuteAllowanceTransferMetaTransaction(e,t,a,n,r,i,s,o){const l=k("0x4515641a",["address","address","address","uint96","address","uint96","address","bytes"],[e,t,a,n,r,i,s,o]);return{to:this.moduleAddress,data:l,value:0n}}createAddDelegateMetaTransaction(e){const t=k("0xe71bdf41",["address"],[e]);return{to:this.moduleAddress,data:t,value:0n}}createRemoveDelegateMetaTransaction(e,t){const a=k("0xdd43a79f",["address","bool"],[e,t]);return{to:this.moduleAddress,data:a,value:0n}}async getTokens(e,t,a){const n=k("0x8d0e8e1d",["address","address"],[t,a]),r={to:this.moduleAddress,data:n},i=await q(e,r,"latest");return this.checkForEmptyResultAndRevert(i,"getTokens"),this.abiCoder.decode(["address[]"],i)[0]}async getTokensAllowance(e,t,a,n){const r=k("0x94b31fbd",["address","address","address"],[t,a,n]),i={to:this.moduleAddress,data:r},s=await q(e,i,"latest");this.checkForEmptyResultAndRevert(s,"getTokenAllowance");const o=this.abiCoder.decode(["uint256[5]"],s)[0];return{amount:BigInt(o[0]),spent:BigInt(o[1]),resetTimeMin:BigInt(o[2]),lastResetMin:BigInt(o[3]),nonce:BigInt(o[4])}}async getDelegates(e,t,a={}){var n;let r=null!=(n=a.start)?n:0n;if(null!=a.maxNumberOfResults)return(await this.baseGetDelegates(e,t,r,a.maxNumberOfResults)).results;const i=[];for(;;){const a=await this.baseGetDelegates(e,t,r,20n);if(i.push.apply(i,a.results),0n==a.next)break;r=a.next}return i}async baseGetDelegates(e,t,a,n){const r=k("0xeb37abe0",["address","uint48","uint8"],[t,a,n]),i={to:this.moduleAddress,data:r},s=await q(e,i,"latest");this.checkForEmptyResultAndRevert(s,"getDelegates");const o=this.abiCoder.decode(["address[]","uint48"],s);return{results:o[0],next:BigInt(o[1])}}}je.DEFAULT_ALLOWANCE_MODULE_ADDRESS="0x691f59471Bfd2B7d639DCF74671a2d648ED1E331";class Je extends Le{constructor(e,t={}){var a,n;super(e,null!=(a=t.safe4337ModuleAddress)?a:Je.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(n=t.entrypointAddress)?n:Je.DEFAULT_ENTRYPOINT_ADDRESS,{onChainIdentifierParams:t.onChainIdentifierParams,onChainIdentifier:t.onChainIdentifier,safeAccountSingleton:t.safeAccountSingleton})}static createAccountAddress(e,t={}){var a,n;const[r,,]=Le.createAccountAddressAndFactoryAddressAndData(e,t,null!=(a=t.safe4337ModuleAddress)?a:Je.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(n=t.safeModuleSetupAddress)?n:Je.DEFAULT_SAFE_MODULE_SETUP_ADDRESS);return r}static initializeNewAccount(e,t={}){var a,n;let r=!1,i=0n,s=0n;for(const t of e)if("string"!=typeof t){if(r)throw new RangeError("Only one Webauthn signer is allowed during initialization");if(0!=e.indexOf(t))throw new RangeError("Webauthn owner has to be the first owner for an init transaction.");r=!0,i=t.x,s=t.y}const[o,l,c]=Le.createAccountAddressAndFactoryAddressAndData(e,t,null!=(a=t.safe4337ModuleAddress)?a:Je.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(n=t.safeModuleSetupAddress)?n:Je.DEFAULT_SAFE_MODULE_SETUP_ADDRESS),d=new Je(o,{safe4337ModuleAddress:t.safe4337ModuleAddress,entrypointAddress:t.entrypointAddress,onChainIdentifierParams:t.onChainIdentifierParams,onChainIdentifier:t.onChainIdentifier,safeAccountSingleton:t.safeAccountSingleton});return d.factoryAddress=l,d.factoryData=c,r&&(d.isInitWebAuthn=!0,d.x=i,d.y=s),d}static getUserOperationEip712Hash(e,t,a={}){var n,r,i,s;const o=null!=(n=a.validAfter)?n:0n,l=null!=(r=a.validUntil)?r:0n,c=null!=(i=a.entrypointAddress)?i:Je.DEFAULT_ENTRYPOINT_ADDRESS,d=null!=(s=a.safe4337ModuleAddress)?s:Je.DEFAULT_SAFE_4337_MODULE_ADDRESS;return Le.getUserOperationEip712Hash(e,t,{validAfter:o,validUntil:l,entrypointAddress:c,safe4337ModuleAddress:d})}static getUserOperationEip712Data(e,t,a={}){var n,r,i,s;const o=null!=(n=a.validAfter)?n:0n,l=null!=(r=a.validUntil)?r:0n,c=null!=(i=a.entrypointAddress)?i:Je.DEFAULT_ENTRYPOINT_ADDRESS,d=null!=(s=a.safe4337ModuleAddress)?s:Je.DEFAULT_SAFE_4337_MODULE_ADDRESS;return Le.getUserOperationEip712Data(e,t,{validAfter:o,validUntil:l,entrypointAddress:c,safe4337ModuleAddress:d})}static createInitializerCallData(e,t,a={}){var n,r;const i=null!=(n=a.safe4337ModuleAddress)?n:Je.DEFAULT_SAFE_4337_MODULE_ADDRESS,s=null!=(r=a.safeModuleSetupAddress)?r:Je.DEFAULT_SAFE_MODULE_SETUP_ADDRESS;return Le.createBaseInitializerCallData(e,t,i,s,a.multisendContractAddress,a.webAuthnSharedSigner,a.eip7212WebAuthnPrecompileVerifierForSharedSigner,a.eip7212WebAuthnContractVerifierForSharedSigner)}static createFactoryAddressAndData(e,t={}){var a,n;return Le.createFactoryAddressAndData(e,t,null!=(a=t.safe4337ModuleAddress)?a:Je.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(n=t.safeModuleSetupAddress)?n:Je.DEFAULT_SAFE_MODULE_SETUP_ADDRESS)}async createUserOperation(e,t,a,n={}){const[r,i,s]=await this.createBaseUserOperationAndFactoryAddressAndFactoryData(e,!1,t,a,n);return m({},r,{factory:i,factoryData:s,paymaster:null,paymasterVerificationGasLimit:null,paymasterPostOpGasLimit:null,paymasterData:null})}async estimateUserOperationGas(e,t,a={}){return this.baseEstimateUserOperationGas(e,t,a)}signUserOperation(e,t,a,n={}){return Le.baseSignSingleUserOperation(e,t,a,this.entrypointAddress,this.safe4337ModuleAddress,n)}}Je.DEFAULT_ENTRYPOINT_ADDRESS=D,Je.DEFAULT_SAFE_4337_MODULE_ADDRESS="0x75cf11467937ce3F2f357CE24ffc3DBF8fD5c226",Je.DEFAULT_SAFE_MODULE_SETUP_ADDRESS="0x2dd68b007B46fBe91B9A7c3EDa5A7a1063cB5b47";class $e extends Le{constructor(e,t={}){var a,n;super(e,null!=(a=t.safe4337ModuleAddress)?a:$e.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(n=t.entrypointAddress)?n:$e.DEFAULT_ENTRYPOINT_ADDRESS,{onChainIdentifierParams:t.onChainIdentifierParams,onChainIdentifier:t.onChainIdentifier})}static createAccountAddress(e,t={}){var a,n;const[r,,]=Le.createAccountAddressAndFactoryAddressAndData(e,t,null!=(a=t.safe4337ModuleAddress)?a:$e.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(n=t.safeModuleSetupAddress)?n:$e.DEFAULT_SAFE_MODULE_SETUP_ADDRESS);return r}static initializeNewAccount(e,t={}){var a,n;let r=!1,i=0n,s=0n;for(const t of e)if("string"!=typeof t){if(r)throw new RangeError("Only one Webauthn signer is allowed during initialization");if(0!=e.indexOf(t))throw new RangeError("Webauthn owner has to be the first owner for an init transaction.");r=!0,i=t.x,s=t.y}const[o,l,c]=$e.createAccountAddressAndFactoryAddressAndData(e,t,null!=(a=t.safe4337ModuleAddress)?a:$e.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(n=t.safeModuleSetupAddress)?n:$e.DEFAULT_SAFE_MODULE_SETUP_ADDRESS),d=new $e(o,{safe4337ModuleAddress:t.safe4337ModuleAddress,entrypointAddress:t.entrypointAddress,onChainIdentifierParams:t.onChainIdentifierParams,onChainIdentifier:t.onChainIdentifier});return d.factoryAddress=l,d.factoryData=c,r&&(d.isInitWebAuthn=!0,d.x=i,d.y=s),d}static getUserOperationEip712Hash(e,t,a={}){var n,r,i,s;const o=null!=(n=a.validAfter)?n:0n,l=null!=(r=a.validUntil)?r:0n,c=null!=(i=a.entrypointAddress)?i:$e.DEFAULT_ENTRYPOINT_ADDRESS,d=null!=(s=a.safe4337ModuleAddress)?s:$e.DEFAULT_SAFE_4337_MODULE_ADDRESS;return Le.getUserOperationEip712Hash(e,t,{validAfter:o,validUntil:l,entrypointAddress:c,safe4337ModuleAddress:d})}static getUserOperationEip712Data(e,t,a={}){var n,r,i,s;const o=null!=(n=a.validAfter)?n:0n,l=null!=(r=a.validUntil)?r:0n,c=null!=(i=a.entrypointAddress)?i:$e.DEFAULT_ENTRYPOINT_ADDRESS,d=null!=(s=a.safe4337ModuleAddress)?s:$e.DEFAULT_SAFE_4337_MODULE_ADDRESS;return Le.getUserOperationEip712Data(e,t,{validAfter:o,validUntil:l,entrypointAddress:c,safe4337ModuleAddress:d})}static createAccountAddressAndInitCode(e,t={}){var a,n;const[r,i,s]=Le.createAccountAddressAndFactoryAddressAndData(e,t,null!=(a=t.safe4337ModuleAddress)?a:$e.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(n=t.safeModuleSetupAddress)?n:$e.DEFAULT_SAFE_MODULE_SETUP_ADDRESS);return[r,i+s.slice(2)]}static createInitializerCallData(e,t,a={}){var n,r;const i=null!=(n=a.safe4337ModuleAddress)?n:$e.DEFAULT_SAFE_4337_MODULE_ADDRESS,s=null!=(r=a.safeModuleSetupAddress)?r:$e.DEFAULT_SAFE_MODULE_SETUP_ADDRESS;return Le.createBaseInitializerCallData(e,t,i,s,a.multisendContractAddress,a.webAuthnSharedSigner,a.eip7212WebAuthnPrecompileVerifierForSharedSigner,a.eip7212WebAuthnContractVerifierForSharedSigner)}static createInitCode(e,t={}){var a,n;const[r,i]=Le.createFactoryAddressAndData(e,t,null!=(a=t.safe4337ModuleAddress)?a:$e.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(n=t.safeModuleSetupAddress)?n:$e.DEFAULT_SAFE_MODULE_SETUP_ADDRESS);return r+i.slice(2)}async createUserOperation(e,t,a,n={}){const[r,i,s]=await this.createBaseUserOperationAndFactoryAddressAndFactoryData(e,!0,t,a,n);let o="0x";if(null==n.initCode){if(null!=i){let e="0x";null!=s&&(e=s),o=i+e.slice(2)}}else o=n.initCode;return m({},r,{initCode:o,paymasterAndData:"0x"})}async createMigrateToSafeAccountV0_3_0MetaTransactions(e,t={}){var a,n;const r=null!=(a=t.safeV06ModuleAddress)?a:$e.DEFAULT_SAFE_4337_MODULE_ADDRESS,i=null!=(n=t.safeV07ModuleAddress)?n:Je.DEFAULT_SAFE_4337_MODULE_ADDRESS,s=await this.createDisableModuleMetaTransaction(e,r,this.accountAddress,{prevModuleAddress:t.safeV06ModuleAddress,modulesPageSize:t.pageSize,modulesStart:t.modulesStart}),o=Le.createEnableModuleMetaTransaction(i,this.accountAddress),l=k("0xf08a0323",["address"],[i]);return[s,o,{to:this.accountAddress,value:0n,data:l}]}async estimateUserOperationGas(e,t,a={}){return this.baseEstimateUserOperationGas(e,t,a)}signUserOperation(e,t,a,n={}){return Le.baseSignSingleUserOperation(e,t,a,this.entrypointAddress,this.safe4337ModuleAddress,n)}}$e.DEFAULT_ENTRYPOINT_ADDRESS=S,$e.DEFAULT_SAFE_4337_MODULE_ADDRESS="0xa581c4A4DB7175302464fF3C06380BC3270b4037",$e.DEFAULT_SAFE_MODULE_SETUP_ADDRESS="0x8EcD4ec46D4D2a6B64fE960B3D64e8B94B2234eb";class qe extends Je{constructor(e,t={}){var a;super(e,{safe4337ModuleAddress:t.safe4337ModuleAddress,entrypointAddress:t.entrypointAddress,onChainIdentifierParams:t.onChainIdentifierParams,onChainIdentifier:t.onChainIdentifier,safeAccountSingleton:null!=(a=t.safeAccountSingleton)?a:b})}static createProxyAddress(e,t={}){var a;const n=m({},t,{singletonInitHash:null!=(a=t.singletonInitHash)?a:b.singletonInitHash});return Je.createProxyAddress(e,n)}static initializeNewAccount(e,t={}){var a,n,r;const i=m({},t,{safeAccountSingleton:null!=(a=t.safeAccountSingleton)?a:b,eip7212WebAuthnPrecompileVerifierForSharedSigner:null!=(n=t.eip7212WebAuthnPrecompileVerifierForSharedSigner)?n:qe.DEFAULT_WEB_AUTHN_PRECOMPILE,eip7212WebAuthnContractVerifierForSharedSigner:null!=(r=t.eip7212WebAuthnContractVerifierForSharedSigner)?r:qe.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER});return Je.initializeNewAccount(e,i)}static createAccountAddress(e,t={}){var a,n,r;const i=m({},t,{safeAccountSingleton:null!=(a=t.safeAccountSingleton)?a:b,eip7212WebAuthnPrecompileVerifierForSharedSigner:null!=(n=t.eip7212WebAuthnPrecompileVerifierForSharedSigner)?n:qe.DEFAULT_WEB_AUTHN_PRECOMPILE,eip7212WebAuthnContractVerifierForSharedSigner:null!=(r=t.eip7212WebAuthnContractVerifierForSharedSigner)?r:qe.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER});return Je.createAccountAddress(e,i)}static createFactoryAddressAndData(e,t={}){var a,n,r;const i=m({},t,{safeAccountSingleton:null!=(a=t.safeAccountSingleton)?a:b,eip7212WebAuthnPrecompileVerifierForSharedSigner:null!=(n=t.eip7212WebAuthnPrecompileVerifierForSharedSigner)?n:qe.DEFAULT_WEB_AUTHN_PRECOMPILE,eip7212WebAuthnContractVerifierForSharedSigner:null!=(r=t.eip7212WebAuthnContractVerifierForSharedSigner)?r:qe.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER});return Je.createFactoryAddressAndData(e,i)}async createUserOperation(e,t,a,n={}){var r,i;return super.createUserOperation(e,t,a,m({},n,{eip7212WebAuthnPrecompileVerifier:null!=(r=n.eip7212WebAuthnPrecompileVerifier)?r:qe.DEFAULT_WEB_AUTHN_PRECOMPILE,eip7212WebAuthnContractVerifier:null!=(i=n.eip7212WebAuthnContractVerifier)?i:qe.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER}))}async estimateUserOperationGas(e,t,a={}){var n,r;return super.estimateUserOperationGas(e,t,m({},a,{eip7212WebAuthnPrecompileVerifier:null!=(n=a.eip7212WebAuthnPrecompileVerifier)?n:qe.DEFAULT_WEB_AUTHN_PRECOMPILE,eip7212WebAuthnContractVerifier:null!=(r=a.eip7212WebAuthnContractVerifier)?r:qe.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER}))}static createWebAuthnSignerVerifierAddress(e,t,a={}){var n,r;return Le.createWebAuthnSignerVerifierAddress(e,t,m({},a,{eip7212WebAuthnPrecompileVerifier:null!=(n=a.eip7212WebAuthnPrecompileVerifier)?n:qe.DEFAULT_WEB_AUTHN_PRECOMPILE,eip7212WebAuthnContractVerifier:null!=(r=a.eip7212WebAuthnContractVerifier)?r:qe.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER}))}static createDeployWebAuthnVerifierMetaTransaction(e,t,a={}){var n,r;return Le.createDeployWebAuthnVerifierMetaTransaction(e,t,m({},a,{eip7212WebAuthnPrecompileVerifier:null!=(n=a.eip7212WebAuthnPrecompileVerifier)?n:qe.DEFAULT_WEB_AUTHN_PRECOMPILE,eip7212WebAuthnContractVerifier:null!=(r=a.eip7212WebAuthnContractVerifier)?r:qe.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER}))}static createDummySignerSignaturePairForExpectedSigners(e,t={}){var a,n;return Le.createDummySignerSignaturePairForExpectedSigners(e,m({},t,{eip7212WebAuthnPrecompileVerifier:null!=(a=t.eip7212WebAuthnPrecompileVerifier)?a:qe.DEFAULT_WEB_AUTHN_PRECOMPILE,eip7212WebAuthnContractVerifier:null!=(n=t.eip7212WebAuthnContractVerifier)?n:qe.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER}))}static async verifyWebAuthnSignatureForMessageHash(e,t,a,n,r={}){var i,s;return Le.verifyWebAuthnSignatureForMessageHash(e,t,a,n,m({},r,{eip7212WebAuthnPrecompileVerifier:null!=(i=r.eip7212WebAuthnPrecompileVerifier)?i:qe.DEFAULT_WEB_AUTHN_PRECOMPILE,eip7212WebAuthnContractVerifier:null!=(s=r.eip7212WebAuthnContractVerifier)?s:qe.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER}))}}qe.DEFAULT_WEB_AUTHN_PRECOMPILE="0x0000000000000000000000000000000000000100",qe.DEFAULT_WEB_AUTHN_DAIMO_VERIFIER="0xc2b78104907F722DABAc4C69f826a522B2754De4";class Ze{}const Qe=["0xdac17f958d2ee523a2206206994597c13d831ec7"];class et extends Ze{constructor(e){super(),this.rpcUrl=void 0,this.entrypointData=new Map,this.initPromises=new Map,this.chainId=null,this.chainIdPromise=null,this.rpcUrl=e,this.chainId=et.extractChainIdFromUrl(e)}static extractChainIdFromUrl(e){const t=e.match(/api\.candide\.dev\/(?:api|public)\/v\d+\/(\d+)(?:\/|$)/);return t?"0x"+BigInt(t[1]).toString(16):null}async getChainId(){return null!=this.chainId?this.chainId:(null==this.chainIdPromise&&(this.chainIdPromise=this.fetchChainId().then(e=>(this.chainId=e,e)).catch(e=>{throw this.chainIdPromise=null,e})),this.chainIdPromise)}async fetchChainId(){try{return await Y(this.rpcUrl,"pm_chainId",[])}catch(e){const t=V(e);throw new M("PAYMASTER_ERROR","pm_chainId failed",{cause:t})}}resolveEntrypoint(e){return"initCode"in e?S:"eip7702Auth"in e?E:D}getEntrypointData(e){return this.entrypointData.get(e.toLowerCase())}static mapTokens(e){return e.map(e=>({name:e.name,symbol:e.symbol,address:e.address,decimals:Number(e.decimals)}))}static mapTokensWithExchangeRate(e){return e.map(e=>({name:e.name,symbol:e.symbol,address:e.address,decimals:Number(e.decimals),exchangeRate:BigInt(e.exchangeRate)}))}static normalizePaymasterMetadata(e){return"string"!=typeof e.dummyPaymasterAndData?m({},e,{dummyPaymasterAndData:m({},e.dummyPaymasterAndData,{paymasterVerificationGasLimit:BigInt(e.dummyPaymasterAndData.paymasterVerificationGasLimit),paymasterPostOpGasLimit:BigInt(e.dummyPaymasterAndData.paymasterPostOpGasLimit)})}):e}ensureInitialized(e){const t=e.toLowerCase();let a=this.initPromises.get(t);return null==a&&(a=this.doInitialize(e).catch(e=>{throw this.initPromises.delete(t),e}),this.initPromises.set(t,a)),a}async doInitialize(e){try{const t=await this.fetchAndTransformTokenData(e);if(null==t)throw new RangeError(`Invalid data received during initialization for entrypoint ${e}.`);this.entrypointData.set(e.toLowerCase(),t)}catch(e){const t=V(e);throw new M("PAYMASTER_ERROR","failed initializing the paymaster",{cause:t})}}async fetchAndTransformTokenData(e){try{const t=await this.fetchSupportedTokensRpc(e);return{tokens:et.mapTokens(t.tokens),paymasterMetadata:et.normalizePaymasterMetadata(t.paymasterMetadata)}}catch(e){const t=V(e);throw new M("PAYMASTER_ERROR","fetchAndTransformTokenData failed",{cause:t})}}async fetchSupportedTokensRpc(e){return await Y(this.rpcUrl,"pm_supportedERC20Tokens",[e])}async getSupportedEntrypoints(){try{return await Y(this.rpcUrl,"pm_supportedEntryPoints",[])}catch(e){const t=V(e);throw new M("PAYMASTER_ERROR","pm_supportedEntryPoints failed",{cause:t})}}async getPaymasterMetaData(e){await this.ensureInitialized(e);const t=this.getEntrypointData(e);if(null==t)throw new RangeError("unsupported entrypoint.");return t.paymasterMetadata}async isSupportedERC20Token(e,t=D){return null!=await this.getSupportedERC20TokenData(e,t)}async getSupportedERC20TokenData(e,t=D){await this.ensureInitialized(t);const a=this.getEntrypointData(t);if(null==a)throw new RangeError("unsupported entrypoint.");const n=a.tokens.find(t=>t.address.toLowerCase()===e.toLowerCase());return n?{name:n.name,symbol:n.symbol,address:n.address,decimals:Number(n.decimals)}:null}setDummyPaymasterFields(e,t){const a=t.paymasterMetadata.dummyPaymasterAndData;if("initCode"in e)e.paymasterAndData=a;else{const t=a;e.paymaster=t.paymaster,e.paymasterVerificationGasLimit=t.paymasterVerificationGasLimit,e.paymasterPostOpGasLimit=t.paymasterPostOpGasLimit,e.paymasterData=t.paymasterData}}async estimateAndApplyGasLimits(e,t,a,n){var r,i,s,o,l,c;let d=e.preVerificationGas,u=e.verificationGasLimit,A=e.callGasLimit;if(null==n.preVerificationGas||null==n.verificationGasLimit||null==n.callGasLimit){if(null==t)throw new M("BAD_DATA","bundlerRpc can't be null if preVerificationGas,verificationGasLimit and callGasLimit are not overridden");const r=new ue(t);e.callGasLimit=0n,e.verificationGasLimit=0n,e.preVerificationGas=0n;const i=e.maxFeePerGas,s=e.maxPriorityFeePerGas;e.maxFeePerGas=0n,e.maxPriorityFeePerGas=0n;const o=await r.estimateUserOperationGas(e,a,n.state_override_set);d<o.preVerificationGas&&(d=o.preVerificationGas),u<o.verificationGasLimit&&(u=o.verificationGasLimit),A<o.callGasLimit&&(A=o.callGasLimit),e.maxFeePerGas=i,e.maxPriorityFeePerGas=s}if("bigint"==typeof n.preVerificationGas&&n.preVerificationGas<0n)throw new RangeError("preVerificationGas override can't be negative");if("bigint"==typeof n.verificationGasLimit&&n.verificationGasLimit<0n)throw new RangeError("verificationGasLimit override can't be negative");if("bigint"==typeof n.callGasLimit&&n.callGasLimit<0n)throw new RangeError("callGasLimit override can't be negative");const f=(e,t)=>e+e*BigInt(Math.round(100*(null!=t?t:0)))/10000n;e.preVerificationGas=null!=(r=n.preVerificationGas)?r:f(d,null!=(i=n.preVerificationGasPercentageMultiplier)?i:5),e.verificationGasLimit=null!=(s=n.verificationGasLimit)?s:f(u,null!=(o=n.verificationGasLimitPercentageMultiplier)?o:10),e.callGasLimit=null!=(l=n.callGasLimit)?l:f(A,null!=(c=n.callGasLimitPercentageMultiplier)?c:10),a==S&&(e.verificationGasLimit+=40000n)}applyPaymasterResult(e,t){var a;const n=t;if("initCode"in e)e.paymasterAndData=t.paymasterAndData;else{const a=t;e.paymaster=a.paymaster,e.paymasterVerificationGasLimit=BigInt(a.paymasterVerificationGasLimit),e.paymasterPostOpGasLimit=BigInt(a.paymasterPostOpGasLimit),e.paymasterData=a.paymasterData}return null!=(a=n.sponsorMetadata)?a:void 0}async createPaymasterUserOperation(e,t={},a={}){const n=m({},e);try{var r;const e=null!=(r=a.entrypoint)?r:this.resolveEntrypoint(n),i=await this.getChainId(),s=await Y(this.rpcUrl,"pm_getPaymasterData",[n,e,i,t]);return[n,this.applyPaymasterResult(n,s)]}catch(e){const t=V(e);throw new M("PAYMASTER_ERROR","pm_getPaymasterData failed",{cause:t})}}async createSponsorPaymasterUserOperation(e,t,a,n){var r;const i=null!=(r=null==n?void 0:n.entrypoint)?r:this.resolveEntrypoint(e);await this.ensureInitialized(i);const s=this.getEntrypointData(i);if(null==s)throw new RangeError(`UserOperation for entrypoint ${i} is not supported`);this.setDummyPaymasterFields(e,s),await this.estimateAndApplyGasLimits(e,t,i,null!=n?n:{});const o={};a&&a.trim().length>0&&(o.sponsorshipPolicyId=a);const l=m({},n||{},{entrypoint:i});return await this.createPaymasterUserOperation(e,o,l)}async createTokenPaymasterUserOperation(e,t,a,n,r){try{var i,s;const o=null!=(i=null==r?void 0:r.entrypoint)?i:this.resolveEntrypoint(t);await this.ensureInitialized(o);const l=this.getEntrypointData(o);if(null==l)throw new RangeError(`UserOperation for entrypoint ${o} is not supported`);this.setDummyPaymasterFields(t,l);const c=t.callData,d=null!=(s=null==r?void 0:r.resetApproval)?s:Qe.includes(a.toLowerCase());let u=e.prependTokenPaymasterApproveToCallData(t.callData,a,l.paymasterMetadata.address,115792089237316195423570985008687907853269984665640564039457584007913129639935n);d&&(u=e.prependTokenPaymasterApproveToCallData(u,a,l.paymasterMetadata.address,0n)),t.callData=u,await this.estimateAndApplyGasLimits(t,n,o,null!=r?r:{});const A=await this.calculateUserOperationErc20TokenMaxGasCost(t,a);u=e.prependTokenPaymasterApproveToCallData(c,a,l.paymasterMetadata.address,2n*A),d&&(u=e.prependTokenPaymasterApproveToCallData(u,a,l.paymasterMetadata.address,0n)),t.callData=u;const f=m({},r||{},{entrypoint:o}),[h]=await this.createPaymasterUserOperation(t,{token:a},f);return h}catch(e){const t=V(e);throw new M("PAYMASTER_ERROR","createTokenPaymasterUserOperation failed",{cause:t})}}async calculateUserOperationErc20TokenMaxGasCost(e,t,a={}){try{var n;const r=null!=(n=a.entrypoint)?n:this.resolveEntrypoint(e);return await this.ensureInitialized(r),await this.fetchTokenPaymasterExchangeRate(t,r)*j(e)/BigInt(10**18)}catch(e){const t=V(e);throw new M("PAYMASTER_ERROR","calculateUserOperationErc20TokenMaxGasCost failed",{cause:t})}}async fetchTokenPaymasterExchangeRate(e,t=D){try{await this.ensureInitialized(t);const a=await this.fetchSupportedTokensRpc(t),n=a.tokens.find(t=>t.address.toLowerCase()===e.toLowerCase());if(n)return BigInt(n.exchangeRate);throw new M("PAYMASTER_ERROR",e+" token is not supported by the paymaster.",{context:{entrypoint:t,supportedTokens:a.tokens.map(e=>e.address)}})}catch(e){const t=V(e);throw new M("PAYMASTER_ERROR","fetchTokenPaymasterExchangeRate failed",{cause:t})}}async fetchSupportedERC20TokensAndPaymasterMetadata(e=D){try{if(await this.ensureInitialized(e),null==this.getEntrypointData(e))throw new RangeError("unsupported entrypoint.");const t=await this.fetchSupportedTokensRpc(e);return{tokens:et.mapTokensWithExchangeRate(t.tokens),paymasterMetadata:et.normalizePaymasterMetadata(t.paymasterMetadata)}}catch(e){const t=V(e);throw new M("PAYMASTER_ERROR","fetchSupportedERC20TokensAndPaymasterMetadata failed",{cause:t})}}}class tt extends Ze{constructor(e="0x36A337b8b4cE5CF6ca1dDaeef73Da4928d714DF2"){super(),this.address=void 0,this.address=e}async getPaymasterFieldsInitValues(e){return{paymaster:this.address,paymasterVerificationGasLimit:45000n,paymasterPostOpGasLimit:45000n,paymasterData:"0x22e325a297439656"}}async getApprovedPaymasterData(e){return"0x7603fbcd3c6cebdb7193b716f62fe7e9d4afd859df4bf7fcdb2e9d486f57a1ca002022e325a297439656"}}class at extends Ze{constructor(e){super(),this.address=void 0,this.address=e}async createPaymasterUserOperation(e,a,n,r,i,s){if("0x"!=i.slice(0,2)||514!=i.length)throw new RangeError("Invalid proof.");const o=["0x"+(i=i.slice(2)).slice(0,64),"0x"+i.slice(64,128),"0x"+i.slice(128,192),"0x"+i.slice(192,256),"0x"+i.slice(256,320),"0x"+i.slice(320,384),"0x"+i.slice(384,448),"0x"+i.slice(448,512)],l=t.defaultAbiCoder(),c=l.encode(["uint256"],[r])+l.encode(["uint256"],[n]).slice(2)+l.encode(["uint256[8]"],[o]).slice(2);e.paymaster=this.address,e.paymasterData=c,e.paymasterPostOpGasLimit=45000n,e.paymasterVerificationGasLimit=350000n,null==s&&(s={});let d=s.entrypoint;null==d&&(d="eip7702Auth"in e?E:D);let u=e.preVerificationGas,A=e.verificationGasLimit,f=e.callGasLimit;e.preVerificationGas=0n;const h=new ue(a),p=await h.estimateUserOperationGas(e,d,s.state_override_set);return u<p.preVerificationGas&&(u=p.preVerificationGas),A<p.verificationGasLimit&&(A=p.verificationGasLimit),f<p.callGasLimit&&(f=p.callGasLimit),e.preVerificationGas=u,e.verificationGasLimit=A,e.callGasLimit=f,e}}function nt(e,t,n){return a(s(["address","uint256","uint256"],[e,t,n]))}var rt={__proto__:null,SmartAccount:p,Simple7702Account:he,Simple7702AccountV09:pe,ExperimentalSafeMultiChainSigAccount:Ge,Calibur7702Account:We,get CaliburKeyType(){return Oe},SocialRecoveryModule:Ye,get SocialRecoveryModuleGracePeriodSelector(){return ke},EXECUTE_RECOVERY_PRIMARY_TYPE:ze,EIP712_RECOVERY_MODULE_TYPE:Ke,AllowanceModule:je,ALLOWANCE_MODULE_V0_1_0_ADDRESS:Xe,SafeAccountV0_2_0:$e,SafeAccountV0_3_0:Je,SafeAccountV1_5_0_M_0_3_0:qe,SendUseroperationResponse:Ae,SmartAccountFactory:xe,SafeAccountFactory:Ue,Bundler:ue,CandidePaymaster:et,ExperimentalAllowAllParallelPaymaster:tt,WorldIdPermissionlessPaymaster:at,createWorldIdSignal:nt,createUserOperationHash:N,createCallData:k,getFunctionSelector:z,fetchAccountNonce:K,calculateUserOperationMaxGasCost:j,sendJsonRpcRequest:Y,fetchGasPrice:X,getDepositInfo:$,getBalanceOf:J,getDelegatedAddress:Q,shareTenderlySimulationAndCreateLink:me,simulateUserOperationWithTenderlyAndCreateShareLink:ye,simulateUserOperationWithTenderly:ge,simulateUserOperationCallDataWithTenderly:De,simulateSenderCallDataWithTenderlyAndCreateShareLink:Se,simulateUserOperationCallDataWithTenderlyAndCreateShareLink:Ee,simulateSenderCallDataWithTenderly:be,callTenderlySimulateBundle:_e,createAndSignLegacyRawTransaction:ae,createAndSignEip7702RawTransaction:se,createEip7702TransactionHash:oe,createAndSignEip7702DelegationAuthorization:ne,createEip7702DelegationAuthorizationHash:re,signHash:ie,get SafeModuleExecutorFunctionSelector(){return we},EOADummySignerSignaturePair:Fe,WebauthnDummySignerSignaturePair:Te,get Operation(){return L},get GasOption(){return I},get PolygonChain(){return G},ZeroAddress:y,BaseUserOperationDummyValues:w,EIP712_MULTI_CHAIN_OPERATIONS_TYPE:U,EIP712_MULTI_CHAIN_OPERATIONS_PRIMARY_TYPE:x,EIP712_SAFE_OPERATION_V7_TYPE:P,EIP712_SAFE_OPERATION_V6_TYPE:T,EIP712_SAFE_OPERATION_PRIMARY_TYPE:F,DEFAULT_SECP256R1_PRECOMPILE_ADDRESS:C,CALIBUR_UNISWAP_V1_0_0_SINGLETON_ADDRESS:R,CALIBUR_CANDIDE_V0_1_0_SINGLETON_ADDRESS:v,ENTRYPOINT_V6:S,ENTRYPOINT_V7:D,ENTRYPOINT_V8:E,ENTRYPOINT_V9:g,AbstractionKitError:M,SAFE_MESSAGE_PRIMARY_TYPE:Ce,SAFE_MESSAGE_MODULE_TYPE:Re,getSafeMessageEip712Data:ve};export{Xe as ALLOWANCE_MODULE_V0_1_0_ADDRESS,M as AbstractionKitError,je as AllowanceModule,w as BaseUserOperationDummyValues,ue as Bundler,v as CALIBUR_CANDIDE_V0_1_0_SINGLETON_ADDRESS,R as CALIBUR_UNISWAP_V1_0_0_SINGLETON_ADDRESS,We as Calibur7702Account,Oe as CaliburKeyType,et as CandidePaymaster,C as DEFAULT_SECP256R1_PRECOMPILE_ADDRESS,x as EIP712_MULTI_CHAIN_OPERATIONS_PRIMARY_TYPE,U as EIP712_MULTI_CHAIN_OPERATIONS_TYPE,Ke as EIP712_RECOVERY_MODULE_TYPE,F as EIP712_SAFE_OPERATION_PRIMARY_TYPE,T as EIP712_SAFE_OPERATION_V6_TYPE,P as EIP712_SAFE_OPERATION_V7_TYPE,S as ENTRYPOINT_V6,D as ENTRYPOINT_V7,E as ENTRYPOINT_V8,g as ENTRYPOINT_V9,Fe as EOADummySignerSignaturePair,ze as EXECUTE_RECOVERY_PRIMARY_TYPE,tt as ExperimentalAllowAllParallelPaymaster,Ge as ExperimentalSafeMultiChainSigAccount,I as GasOption,L as Operation,G as PolygonChain,Re as SAFE_MESSAGE_MODULE_TYPE,Ce as SAFE_MESSAGE_PRIMARY_TYPE,Ue as SafeAccountFactory,$e as SafeAccountV0_2_0,Je as SafeAccountV0_3_0,qe as SafeAccountV1_5_0_M_0_3_0,we as SafeModuleExecutorFunctionSelector,Ae as SendUseroperationResponse,he as Simple7702Account,pe as Simple7702AccountV09,p as SmartAccount,xe as SmartAccountFactory,Ye as SocialRecoveryModule,ke as SocialRecoveryModuleGracePeriodSelector,Te as WebauthnDummySignerSignaturePair,at as WorldIdPermissionlessPaymaster,y as ZeroAddress,rt as abstractionkit,j as calculateUserOperationMaxGasCost,_e as callTenderlySimulateBundle,ne as createAndSignEip7702DelegationAuthorization,se as createAndSignEip7702RawTransaction,ae as createAndSignLegacyRawTransaction,k as createCallData,re as createEip7702DelegationAuthorizationHash,oe as createEip7702TransactionHash,N as createUserOperationHash,nt as createWorldIdSignal,K as fetchAccountNonce,X as fetchGasPrice,J as getBalanceOf,Q as getDelegatedAddress,$ as getDepositInfo,z as getFunctionSelector,ve as getSafeMessageEip712Data,Y as sendJsonRpcRequest,me as shareTenderlySimulationAndCreateLink,ie as signHash,be as simulateSenderCallDataWithTenderly,Se as simulateSenderCallDataWithTenderlyAndCreateShareLink,De as simulateUserOperationCallDataWithTenderly,Ee as simulateUserOperationCallDataWithTenderlyAndCreateShareLink,ge as simulateUserOperationWithTenderly,ye as simulateUserOperationWithTenderlyAndCreateShareLink};
|