abstractionkit 0.2.32 → 0.2.34
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/abstractionkit.d.ts +4 -1
- package/dist/abstractionkit.d.ts.map +1 -1
- package/dist/account/Safe/MerkleTree.d.ts +3 -0
- package/dist/account/Safe/MerkleTree.d.ts.map +1 -0
- package/dist/account/Safe/SafeAccount.d.ts +34 -9
- package/dist/account/Safe/SafeAccount.d.ts.map +1 -1
- package/dist/account/Safe/SafeAccountV0_2_0.d.ts +18 -4
- package/dist/account/Safe/SafeAccountV0_2_0.d.ts.map +1 -1
- package/dist/account/Safe/SafeAccountV0_3_0.d.ts +17 -3
- package/dist/account/Safe/SafeAccountV0_3_0.d.ts.map +1 -1
- package/dist/account/Safe/SafeMultiChainSigAccount.d.ts +66 -0
- package/dist/account/Safe/SafeMultiChainSigAccount.d.ts.map +1 -0
- package/dist/account/Safe/types.d.ts +36 -3
- package/dist/account/Safe/types.d.ts.map +1 -1
- package/dist/account/simple/Simple7702Account.d.ts +19 -9
- package/dist/account/simple/Simple7702Account.d.ts.map +1 -1
- package/dist/account/simple/Simple7702AccountV09.d.ts +17 -0
- package/dist/account/simple/Simple7702AccountV09.d.ts.map +1 -0
- package/dist/constants.d.ts +7 -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/AllowAllPaymaster.d.ts +9 -0
- package/dist/paymaster/AllowAllPaymaster.d.ts.map +1 -0
- package/dist/types.d.ts +8 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +2 -0
- package/dist/utils.d.ts.map +1 -1
- package/package.json +1 -1
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,encodeRlp as i,Wallet as s,getBytes as o,toBeArray as l,solidityPacked as c,hashMessage as d,solidityPackedKeccak256 as u,getAddress as f,TypedDataEncoder as h,ethers as A}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="0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108",E="0x0000000071727De22E5E9d8BAf0edAc6f37da032",D="0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",S={singletonAddress:"0xEdd160fEBBD92E350D4D398fb636302fccd67C7e",singletonInitHash:"0x1b94aebb5a7df6dff11d93589204a6bbc99b4b8c9014bf1d386d006c2c17a881"},b={singletonAddress:"0x29fcB43b46531BcA003ddC8FCB67FFE91900C762",singletonInitHash:"0xe298282cefe913ab5d282047161268a8222e4bd4ed106300c547894bbefd31ee"},_={sender:y,nonce:0n,callData:"0x",callGasLimit:0n,verificationGasLimit:0n,preVerificationGas:0n,maxFeePerGas:0n,maxPriorityFeePerGas:0n,signature:"0x"},w={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"}]},v={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"}]},T="0x0000000000000000000000000000000000000100";var x,F,R;!function(e){e[e.Call=0]="Call",e[e.Delegate=1]="Delegate"}(x||(x={})),function(e){e[e.Slow=1]="Slow",e[e.Medium=1.2]="Medium",e[e.Fast=1.5]="Fast"}(F||(F={})),function(e){e.Mainnet="v2",e.ZkMainnet="zkevm",e.Amoy="amoy",e.Cardona="cardona"}(R||(R={}));const P={"-32602":"INVALID_FIELDS","-32500":"SIMULATE_VALIDATION","-32501":"SIMULATE_PAYMASTER_VALIDATION","-32502":"OPCODE_VALIDATION","-32503":"EXPIRE_SHORTLY","-32504":"REPUTATION","-32505":"INSUFFICIENT_STAKE","-32506":"UNSUPPORTED_SIGNATURE_AGGREGATOR","-32507":"INVALID_SIGNATURE","-32601":"INVALID_USEROPERATION_HASH","-32521":"EXECUTION_REVERTED"};class G 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 L(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 U(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()==E.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{i=a(function(e){const n=t.defaultAbiCoder();let r="0x";if(null!=e.factory){const t=e.eip7702Auth;r=null!=t&&null!=t.address?t.address: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=["0x29a0bca4af4be3421398da00295e58e6d7de38cb492214754cb6a47507dd6f8e",e.sender,e.nonce,a(r),a(e.callData),i,e.preVerificationGas,s,a(o)];return n.encode(["bytes32","address","uint256","bytes32","bytes32","bytes32","uint256","bytes32","bytes32"],l)}(e));const n=function(e){const n=t.defaultAbiCoder().encode(["(bytes32,bytes32,bytes32,uint256,address)"],[["0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f","0x364da28a5c92bcc87fe97c8813a6c6b8a3a049b0ea0a328fcb0b4f0e00337586","0xc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6",e,g]]);return a(n)}(r);o=a("0x1901"+n.slice(2)+i.slice(2))}return o}function C(e,a,n){return e+t.defaultAbiCoder().encode(a,n).slice(2)}async function I(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 G(a in P?P[a]:"UNKNOWN_ERROR",e.message,{errno:e.code,context:{url:t,requestOptions:JSON.stringify(o)}})}}function O(e){return n(e).slice(0,10)}async function M(e,t,a,n=0){const r=[{from:"0x0000000000000000000000000000000000000000",to:t,data:C(O("getNonce(address,uint192)"),["address","uint192"],[a,n])},"latest"];try{const t=await I(e,"eth_call",r);if("string"!=typeof t)throw new G("BAD_DATA","getNonce returned ill formed data",{context:JSON.stringify(t)});try{return BigInt(t)}catch(e){const t=L(e);throw new G("BAD_DATA","getNonce returned ill formed data",{cause:t})}}catch(e){const t=L(e);throw new G("BAD_DATA","getNonce failed",{cause:t})}}async function V(e,t=F.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=L(e);throw new G("BAD_DATA","fetching gas prices from node failed.",{cause:t})}}function B(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 N(e,t,a){return(await W(e,t,a)).deposit}async function W(e,a,n){const r={from:"0x0000000000000000000000000000000000000000",to:n,data:C("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 G("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=L(e);throw new G("BAD_DATA","getDepositInfo returned ill formed data",{cause:t})}}catch(e){const t=L(e);throw new G("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 I(e,"eth_call",r);if("string"!=typeof t)throw new G("BAD_DATA","eth_call returned ill formed data",{context:JSON.stringify(t)});try{return t}catch(e){const t=L(e);throw new G("BAD_DATA","eth_call returned ill formed data",{cause:t})}}catch(e){const t=L(e);throw new G("BAD_DATA","eth_call failed",{cause:t})}}async function H(e,t,a){const n=[t,a];try{const t=await I(e,"eth_getCode",n);if("string"!=typeof t)throw new G("BAD_DATA","eth_getCode returned ill formed data",{context:JSON.stringify(t)});try{return t}catch(e){const t=L(e);throw new G("BAD_DATA","eth_getCode returned ill formed data",{cause:t})}}catch(e){const t=L(e);throw new G("BAD_DATA","eth_getCode failed",{cause:t})}}async function z(e,t,a=F.Medium){let n,r;if(null!=t)[n,r]=await async function(e,t=F.Medium){const a="https://gasstation.polygon.technology/"+e;try{const e=await fetch(a),n=await e.json();let r;r=t==F.Slow?n.safeLow:t==F.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=L(e);throw new G("BAD_DATA","fetching gas prices from "+a+" failed.",{cause:t})}}(t,a);else{if(null==e)throw new G("BAD_DATA","providerRpc cant't be null if maxFeePerGas and maxPriorityFeePerGas are not overriden");[n,r]=await V(e,a)}return[n,r]}const Y="0x04";function j(e,t,n,r,l,c,d,u){if(e>=2**64)throw RangeError("Invalide chainId.");if(t>=2**64)throw RangeError("Invalide nonce.");if(42!=l.length)throw RangeError("Invalide destination.");let f=[Q(t),Q(n),Q(r),l,Q(c),d,Q(e),Q(0n),Q(0n)];const h=a(i(f)),A=new s(u).signingKey.sign(h);return f=[Q(t),Q(n),Q(r),l,Q(c),d,Q(BigInt(A.yParity+2*Number(e)+35)),o(A.r),o(A.s)],i(f)}function J(e,t,a,n){const r=K(X(e,t,a),n);return{chainId:ee(e),address:t,nonce:ee(a),yParity:ee(BigInt(r.yParity)),r:ee(r.r),s:ee(r.s)}}function X(e,t,n){const r=[Q(e),t,Q(n)],s=i(r);return a("0x05"+s.slice(2))}function K(e,t){const a=new s(t).signingKey.sign(e);return{yParity:a.yParity,r:BigInt(a.r),s:BigInt(a.s)}}function q(e,t,a,n,r,s,o,l,c,d,u){const f=$(e,t,a,n,r,s,o,l,c,d),h=Z(e,t,a,n,r,s,o,l,c,d),A=K(f,u),p=h.concat([Q(BigInt(A.yParity)),Q(A.r),Q(A.s)]),m=i(p);return Y+m.slice(2)}function $(e,t,n,r,s,o,l,c,d,u){const f=Z(e,t,n,r,s,o,l,c,d,u);return a(Y+i(f).slice(2))}function Z(e,t,a,n,r,i,s,l,c,d){if(e>=2**64)throw RangeError("Invalide chainId.");if(t>=2**64)throw RangeError("Invalide nonce.");if(42!=i.length)throw RangeError("Invalide destination.");const u=function(e){let t=[];for(const a of e){if(42!=a.address.length)throw RangeError("Invalide authorization list address: "+a);const e=[Q(a.chainId),a.address,Q(a.nonce),Q(BigInt(a.yParity)),Q(a.r),Q(a.s)];t.push(e)}return t}(d),f=function(e){let t=[];for(const[a,n]of e){if(42!=a.length)throw RangeError("Invalide access list address: "+a);let e=[];for(const t of n){if(66!=t.length)throw RangeError("Invalide access list storage: "+t);e.push(o(t))}t.push([o(a),e])}return t}(c);return[Q(e),Q(t),Q(a),Q(n),Q(r),i,Q(s),l,f,u]}function Q(e){return o(l(e))}function ee(e){let t=e.toString(16);return t.length%2?"0x0"+t:"0x"+t}class te{constructor(e){this.rpcUrl=void 0,this.rpcUrl=e}async chainId(){try{const e=await I(this.rpcUrl,"eth_chainId",[]);if("string"==typeof e)return e;throw new G("BAD_DATA","bundler eth_chainId rpc call failed")}catch(e){const t=L(e);throw new G("BUNDLER_ERROR","bundler eth_chainId rpc call failed",{cause:t})}}async supportedEntryPoints(){try{return await I(this.rpcUrl,"eth_supportedEntryPoints",[])}catch(e){const t=L(e);throw new G("BUNDLER_ERROR","bundler eth_supportedEntryPoints rpc call failed",{cause:t})}}async estimateUserOperationGas(e,t,a){try{let n={};n=void 0===a?await I(this.rpcUrl,"eth_estimateUserOperationGas",[e,t]):await I(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=L(e);throw new G("BUNDLER_ERROR","bundler eth_estimateUserOperationGas rpc call failed",{cause:t})}}async sendUserOperation(e,t){try{return await I(this.rpcUrl,"eth_sendUserOperation",[e,t])}catch(e){const t=L(e);throw new G("BUNDLER_ERROR","bundler eth_sendUserOperation rpc call failed",{cause:t})}}async getUserOperationReceipt(e){try{const t=await I(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=L(t);throw new G("BUNDLER_ERROR","bundler eth_getUserOperationReceipt rpc call failed",{cause:a,context:{useroperationhash:e}})}}async getUserOperationByHash(e){try{const t=await I(this.rpcUrl,"eth_getUserOperationByHash",[e]);return null!=t?m({},t,{blockNumber:null==t.blockNumber?null:BigInt(t.blockNumber)}):null}catch(t){const a=L(t);throw new G("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 RangeError("timeoutInSeconds and requestIntervalInSeconds should be bigger than zero");if(e<t)throw 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++}throw new G("TIMEOUT","can't find useroperation",{context:this.userOperationHash})}}class ne extends p{constructor(e,t={}){var a;super(e),this.entrypointAddress=void 0,this.entrypointAddress=null!=(a=t.entrypointAddress)?a:ne.DEFAULT_ENTRYPOINT_ADDRESS}static createAccountCallData(e,t,a){return C(ne.executorFunctionSelector,ne.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 ne.createAccountCallData(e.to,n,r)}static createAccountCallDataBatchTransactions(e){const t=[e.map(e=>[e.to,e.value,e.data])];return C(ne.batchExecutorFunctionSelector,ne.batchExecutorFunctionInputAbi,t)}async createUserOperation(e,t,a,n={}){var r,i,s,o,l,c,d,u,f,h;if(e.length<1)throw RangeError("There should be at least one transaction");let A=null,p=null;if(null==n.nonce){if(null==t)throw new G("BAD_DATA","providerRpc cant't be null if nonce is not overriden");p=M(t,this.entrypointAddress,this.accountAddress)}else A=n.nonce;if("bigint"==typeof n.maxFeePerGas&&n.maxFeePerGas<0n)throw RangeError("maxFeePerGas overrid can't be negative");if("bigint"==typeof n.maxPriorityFeePerGas&&n.maxPriorityFeePerGas<0n)throw RangeError("maxPriorityFeePerGas overrid can't be negative");let y=_.maxFeePerGas,g=_.maxPriorityFeePerGas,E=null;null!=n.maxFeePerGas&&null!=n.maxPriorityFeePerGas||(E=z(t,n.polygonGasStation,n.gasLevel));let D=null,S=null,b=null;var w,v;if(null!=n.eip7702Auth&&(D=n.eip7702Auth.chainId,S=null!=(w=n.eip7702Auth.address)?w:ne.DEFAULT_DELEGATEE_ADDRESS,b=null!=(v=n.eip7702Auth.nonce)?v:null),null!=n.eip7702Auth&&null==b){let e;if(null==t)throw new G("BAD_DATA","providerRpc cant't be null if eoaDelegatorNonce is not overriden");e=I(t,"eth_getTransactionCount",[this.accountAddress,"latest"]),null!=E&&null!=p?await Promise.all([e,p,E]).then(e=>{b=BigInt(e[0]),A=e[1],[y,g]=e[2]}):null!=E?await Promise.all([e,E]).then(e=>{b=BigInt(e[0]),[y,g]=e[1]}):null!=p?await Promise.all([e,E]).then(e=>{b=BigInt(e[0]),A=e[1]}):b=BigInt(await e)}else null!=E&&null!=p?await Promise.all([p,E]).then(e=>{A=e[0],[y,g]=e[1]}):null!=E?[y,g]=await E:null!=p&&(A=await p);if(y=null!=(r=n.maxFeePerGas)?r:y*BigInt(Math.floor(((null!=(i=n.maxFeePerGasPercentageMultiplier)?i:0)+100)/100)),g=null!=(s=n.maxPriorityFeePerGas)?s:g*BigInt(Math.floor(((null!=(o=n.maxPriorityFeePerGasPercentageMultiplier)?o:0)+100)/100)),null==A)throw RangeError("failed to determine nonce");if(A<0n)throw RangeError("nonce can't be negative");let T,x="0x";if(x=null==n.callData?1==e.length?ne.createAccountCallDataSingleTransaction(e[0]):ne.createAccountCallDataBatchTransactions(e):n.callData,null!=n.eip7702Auth){var F,R,P;const e=null!=(F=n.eip7702Auth.yParity)?F:"0x0";if("0x0"!=e&&"0x00"!=e&&"0x1"!=e&&"0x01"!=e)throw new G("BAD_DATA","invalide yParity value for eoaDelegatorSignature. must be '0x0' or '0x1'");const t={chainId:ee(D),address:S,nonce:ee(b),yParity:e,r:null!=(R=n.eip7702Auth.r)?R:"0x4277ba564d2c138823415df0ec8e8f97f30825056d54ec5128a8b29ec2dd81b2",s:null!=(P=n.eip7702Auth.s)?P:"0x1075a1bec7f59848cca899ece93075199cd2aabceb0654b9ae00b881a30044cd"};T=m({},_,{sender:this.accountAddress,nonce:A,callData:x,maxFeePerGas:y,maxPriorityFeePerGas:g,factory:"0x7702",factoryData:null,paymaster:null,paymasterVerificationGasLimit:null,paymasterPostOpGasLimit:null,paymasterData:null,eip7702Auth:t})}else T=m({},_,{sender:this.accountAddress,nonce:A,callData:x,maxFeePerGas:y,maxPriorityFeePerGas:g,factory:null,factoryData:null,paymaster:null,paymasterVerificationGasLimit:null,paymasterPostOpGasLimit:null,paymasterData:null,eip7702Auth:null});let L=_.preVerificationGas,U=_.verificationGasLimit,C=_.callGasLimit;if(null==n.preVerificationGas||null==n.verificationGasLimit||null==n.callGasLimit){if(null==a)throw new G("BAD_DATA","bundlerRpc cant't be null if preVerificationGas,verificationGasLimit and callGasLimit are not overriden");{var O;T.callGasLimit=0n,T.verificationGasLimit=0n,T.preVerificationGas=0n;const e=T.maxFeePerGas,t=T.maxPriorityFeePerGas;let r;T.maxFeePerGas=0n,T.maxPriorityFeePerGas=0n,r=m({},T),T.signature=null!=(O=n.dummySignature)?O:ne.dummySignature,[L,U,C]=await this.estimateUserOperationGas(r,a,{stateOverrideSet:n.state_override_set}),U+=55000n,T.maxFeePerGas=e,T.maxPriorityFeePerGas=t}}if("bigint"==typeof n.preVerificationGas&&n.preVerificationGas<0n)throw RangeError("preVerificationGas overrid can't be negative");if("bigint"==typeof n.verificationGasLimit&&n.verificationGasLimit<0n)throw RangeError("verificationGasLimit overrid can't be negative");if("bigint"==typeof n.callGasLimit&&n.callGasLimit<0n)throw RangeError("callGasLimit overrid can't be negative");return T.preVerificationGas=null!=(l=n.preVerificationGas)?l:L*BigInt(Math.floor(((null!=(c=n.preVerificationGasPercentageMultiplier)?c:0)+100)/100)),T.verificationGasLimit=null!=(d=n.verificationGasLimit)?d:U*BigInt(Math.floor(((null!=(u=n.verificationGasLimitPercentageMultiplier)?u:0)+100)/100)),T.callGasLimit=null!=(f=n.callGasLimit)?f:C*BigInt(Math.floor(((null!=(h=n.callGasLimitPercentageMultiplier)?h:0)+100)/100)),T}async estimateUserOperationGas(e,t,a={}){var n;e.signature=null!=(n=a.dummySignature)?n:ne.dummySignature;const r=new te(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)]}signUserOperation(e,t,a){const n=U(e,this.entrypointAddress,a);return new s(t).signingKey.sign(n).serialized}async sendUserOperation(e,t){const a=new te(t),n=await a.sendUserOperation(e,this.entrypointAddress);return new ae(n,a,this.entrypointAddress)}prependTokenPaymasterApproveToCallData(e,t,a,n){return ne.prependTokenPaymasterApproveToCallDataStatic(e,t,a,n)}static prependTokenPaymasterApproveToCallDataStatic(e,a,n,r){const i={to:a,value:0n,data:C(O("approve(address,uint256)"),["address","uint256"],[n,r])},s=t.defaultAbiCoder();let o;if(e.startsWith(ne.batchExecutorFunctionSelector))o=s.decode(ne.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(ne.executorFunctionSelector))throw new G("BAD_DATA","Invalid calldata, should start with "+ne.batchExecutorFunctionSelector+" or "+ne.executorFunctionSelector,{context:{callData:e}});{const t=s.decode(ne.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),ne.createAccountCallDataBatchTransactions(o)}}async function re(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 G("BAD_DATA","tenderly share simulation failed.",{context:{tenderlyAccountSlug:t,tenderlyProjectSlug:a,tenderlyAccessKey:n,tenderlySimulationId:r,status:l}})}async function ie(e,t,a,n,r,i,s=null,o){const l=await se(e,t,a,n,r,i,s,o);return await re(e,t,a,l.simulation.id),{simulation:l,simulationShareLink:"https://dashboard.tenderly.co/shared/simulation/"+l.simulation.id}}async function se(e,a,n,r,i,s,o=null,l){const c=i.toLowerCase();let d=null;const u=t.defaultAbiCoder();if("initCode"in s&&"0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789"==c)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)throw RangeError("Invalid entrypoint.");d="0x765e827f"+r.slice(2)}return(await ue(e,a,n,[{chainId:r,blockNumber:o,from:"0x1000000000000000000000000000000000000000",to:i,data:d,stateOverrides:l}]))[0]}async function oe(e,t,a,n,r,i,s=null,o){const l=await le(e,t,a,n,r,i,s,o),c=l.map(e=>e.simulation.id);c.map(n=>re(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 G("BAD_DATA","invalid number of simulations retuned",{context:JSON.stringify(l,(e,t)=>"bigint"==typeof t?"0x"+t.toString(16):t)})}async function le(e,t,a,n,r,i,s=null,o){let l=null,c=null;return"initCode"in i?null!=i.initCode&&i.initCode.length>2&&(l=i.initCode.slice(0,22),c=i.initCode.slice(22)):(l=i.factory,c=i.factoryData),await de(e,t,a,n,r,i.sender,i.callData,l,c,s,o)}async function ce(e,t,a,n,r,i,s,o=null,l=null,c=null,d){const u=await de(e,t,a,n,r,i,s,o,l,c,d),f=u.map(e=>e.simulation.id);f.map(n=>re(e,t,a,n));const h=f.map(e=>"https://dashboard.tenderly.co/shared/simulation/"+e);if(1==h.length)return{simulation:u,callDataSimulationShareLink:h[0]};if(2==h.length)return{simulation:u,accountDeploymentSimulationShareLink:h[0],callDataSimulationShareLink:h[1]};throw new G("BAD_DATA","invalid number of simulations retuned",{context:JSON.stringify(u,(e,t)=>"bigint"==typeof t?"0x"+t.toString(16):t)})}async function de(e,t,a,n,r,i,s,o=null,l=null,c=null,d){const u=[],f=r.toLowerCase();let h;if("0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789"==f)h="0x7fc98430eaedbb6070b35b39d798725049088348";else if("0x0000000071727de22e5e9d8baf0edac6f37da032"==f)h="0xefc2c1444ebcc4db75e7613d20c6a62ff67a167c";else{if("0x4337084d9e255ff0702461cf8895ce9e3b5ff108"!=f)throw RangeError(`Invalid entrypoint: ${r}`);h="0x449ed7c3e6fee6a97311d4b55475df59c44add33"}if(null==o&&null!=l||null!=o&&null==l)throw RangeError("Invalid factory and factoryData");null!=o&&null!=l&&u.push({chainId:n,blockNumber:c,from:h,to:o,data:l,stateOverrides:d}),u.push({chainId:n,blockNumber:c,from:r,to:i,data:s,stateOverrides:d});const A=await ue(e,t,a,u);for(const e of A)if(""==e.simulation.id)throw new G("TENDERLY_SIMULATION_ERROR","tenderly simulation failed",{context:JSON.stringify(A,(e,t)=>"bigint"==typeof t?"0x"+t.toString(16):t)});return A}async function ue(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&&"storage"!=a&&"stateDiff"!=a)throw RangeError(`Invalide stateOverrides key: ${a}.`);if("storage"in t[e]&&"stateDiff"in t[e])throw 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 I(r,"tenderly_simulateBundle",i,s,"simulations")}var fe;ne.DEFAULT_DELEGATEE_ADDRESS="0xe6Cae83BdE06E4c305530e199D7217f42808555B",ne.DEFAULT_ENTRYPOINT_ADDRESS=g,ne.executorFunctionSelector="0xb61d27f6",ne.executorFunctionInputAbi=["address","uint256","bytes"],ne.batchExecutorFunctionSelector="0x34fcd5be",ne.batchExecutorFunctionInputAbi=["(address,uint256,bytes)[]"],ne.dummySignature="0xd2614025fc173b86704caf37b2fb447f7618101a0d31f5f304c777024cef38a060a29ee43fcf0c46f9107d4f670b8a85c2c017a1fe9e4af891f24f0be6ba5d671c",function(e){e.executeUserOpWithErrorString="0x541d63c8",e.executeUserOp="0x7bb37428"}(fe||(fe={}));const he={signer:"0xfD90FAd33ee8b58f32c00aceEad1358e4AFC23f9",signature:"0x47003599ffa7e9198f321afa774e34a12a959844efd6363b88896e9c24ed33cf4e1be876ef123a3c4467e7d451511434039539699f2baa2f44955fa3d1c1c6d81c",isContractSignature:!1},Ae={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:x.Call,n=o(e.data);return c(["uint8","address","uint256","uint256","bytes"],[a,e.to,e.value,n.length,n]).slice(2)}(e)).join("")}class me{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 C(this.generatorFunctionSelector,this.generatorFunctionInputAbi,e)}}class ye extends me{constructor(e=ye.DEFAULT_FACTORY_ADDRESS){super(e,"0x1688f0b9",["address","bytes","uint256"])}}ye.DEFAULT_FACTORY_ADDRESS="0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67";const ge="SafeMessage",Ee={SafeMessage:[{type:"bytes",name:"message"}]};function De(e,t,a){const n={message:d(a)};return{domain:{chainId:Number(t),verifyingContract:e},types:Ee,messageValue:n}}class Se 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 RangeError("can't override both onChainIdentifier and onChainIdentifierParams");if(null!=r.onChainIdentifierParams)this.onChainIdentifier=function(e,t="Web",n="abstractionkit",r="0.2.30"){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 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,i;const s=null!=(n=t.c2Nonce)?n:0n;if(s<0n)throw RangeError("c2Nonce can't be negative");const o=null!=(r=t.safeFactoryAddress)?r:ye.DEFAULT_FACTORY_ADDRESS,l=null!=(i=t.singletonInitHash)?i:b.singletonInitHash,d=a(c(["bytes32","uint256"],[a(e),s])),h=u(["bytes1","address","bytes32","bytes32"],["0xff",o,d,l]).slice(-40);return f("0x"+h)}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:x.Call,c=null!=(i=t.safeModuleExecutorFunctionSelector)?i:Se.DEFAULT_EXECUTOR_FUCNTION_SELECTOR;return Se.createAccountCallData(e.to,s,o,l,{safeModuleExecutorFunctionSelector:c})}static createAccountCallDataBatchTransactions(e,t={}){var a,n;if(e.length<1)throw RangeError("There should be at least one metaTransaction");const r=null!=(a=t.safeModuleExecutorFunctionSelector)?a:Se.DEFAULT_EXECUTOR_FUCNTION_SELECTOR,i=null!=(n=t.multisendContractAddress)?n:Se.DEFAULT_MULTISEND_CONTRACT_ADDRESS,s=C("0x8d80ff0a",["bytes"],[pe(e)]);return Se.createAccountCallData(i,0n,s,x.Delegate,{safeModuleExecutorFunctionSelector:r})}static createAccountCallData(e,t,a,n,r={}){var i;return C(null!=(i=r.safeModuleExecutorFunctionSelector)?i:Se.DEFAULT_EXECUTOR_FUCNTION_SELECTOR,Se.executorFunctionInputAbi,[e,t,a,n])}static decodeAccountCallData(e){let a=null;if(e.startsWith(fe.executeUserOpWithErrorString)?a=fe.executeUserOpWithErrorString:e.startsWith(fe.executeUserOp)&&(a=fe.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 G("BAD_DATA","Invalid calldata, should start with "+fe.executeUserOpWithErrorString+" or "+fe.executeUserOp,{context:{callData:e}})}static prependTokenPaymasterApproveToCallDataStatic(e,a,n,r,i={}){var s;const o=null!=(s=i.multisendContractAddress)?s:Se.DEFAULT_MULTISEND_CONTRACT_ADDRESS,[l,c]=Se.decodeAccountCallData(e),d=pe([{to:a,value:0n,data:C(O("approve(address,uint256)"),["address","uint256"],[n,r]),operation:x.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=pe([l])+d.slice(2);const h=C(f,["bytes"],[u]);return Se.createAccountCallData(o,0n,h,x.Delegate,{safeModuleExecutorFunctionSelector:c})}static formatEip712SignaturesToUseroperationSignature(e,t,a={}){var n,r;if(e.length!=t.length)throw RangeError("signersAddresses and signatures arrays should be the same length");const i=null!=(n=a.validAfter)?n:0n,s=null!=(r=a.validUntil)?r:0n,o=new Map;e.forEach((e,a)=>{o.set(e.toLocaleLowerCase(),t[a])});const l=new Map(Array.from(o).sort()),c="0x"+Array.from(l.values()).reduce((e,t)=>e+t.slice(2),"");return Se.formatEip712SingleSignatureToUseroperationSignature(c,{validAfter:i,validUntil:s})}static getUserOperationEip712Hash(e,t,a={}){return"initCode"in e?Se.getUserOperationEip712Hash_V6(e,t,a):Se.getUserOperationEip712Hash_V7(e,t,a)}static getUserOperationEip712Data(e,t,a){if("initCode"in e){const n=Se.getUserOperationEip712Data_V6(e,t,a);return{domain:n.domain,types:n.types,messageValue:n.messageValue}}{const n=Se.getUserOperationEip712Data_V7(e,t,a);return{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:w,messageValue:u}}static getUserOperationEip712Hash_V6(e,t,a={}){const n=Se.getUserOperationEip712Data_V6(e,t,a);return h.hash(n.domain,n.types,n.messageValue)}static getUserOperationEip712Data_V7(e,a,n={}){var r,i,s,o;const l=null!=(r=n.validAfter)?r:0n,c=null!=(i=n.validUntil)?i:0n,d=null!=(s=n.entrypointAddress)?s:E,u=null!=(o=n.safe4337ModuleAddress)?o:"0x75cf11467937ce3F2f357CE24ffc3DBF8fD5c226",f=t.defaultAbiCoder();let h="0x";null!=e.factory&&(h=e.factory,null!=e.factoryData&&(h+=e.factoryData.slice(2)));let A="0x";null!=e.paymaster&&(A=e.paymaster,null!=e.paymasterVerificationGasLimit&&(A+=f.encode(["uint128"],[e.paymasterVerificationGasLimit]).slice(34)),null!=e.paymasterPostOpGasLimit&&(A+=f.encode(["uint128"],[e.paymasterPostOpGasLimit]).slice(34)),null!=e.paymasterData&&(A+=e.paymasterData.slice(2)));const p={safe:e.sender,nonce:e.nonce,initCode:h,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:d};return{domain:{chainId:Number(a),verifyingContract:u},types:v,messageValue:p}}static getUserOperationEip712Hash_V7(e,t,a={}){const n=Se.getUserOperationEip712Data_V7(e,t,a);return h.hash(n.domain,n.types,n.messageValue)}static formatEip712SingleSignatureToUseroperationSignature(e,t={}){var a,n;const r=null!=(a=t.validAfter)?a:0n,i=null!=(n=t.validUntil)?n:0n;if(r<0n)throw RangeError("validAfter can't be negative");if(i<0n)throw RangeError("validUntil can't be negative");return c(["uint48","uint48","bytes"],[r,i,e])}async sendUserOperation(e,t){const a=new te(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 RangeError("There should be at least one owner");const f=Se.createBaseInitializerCallData(e,null!=(r=t.threshold)?r:1,a,n,null!=(i=t.multisendContractAddress)?i:Se.DEFAULT_MULTISEND_CONTRACT_ADDRESS,null!=(s=t.webAuthnSharedSigner)?s:Se.DEFAULT_WEB_AUTHN_SHARED_SIGNER,null!=(o=t.eip7212WebAuthnPrecompileVerifierForSharedSigner)?o:Se.DEFAULT_WEB_AUTHN_PRECOMPILE,null!=(l=t.eip7212WebAuthnContractVerifierForSharedSigner)?l:Se.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER);let h;h=null!=t.safeAccountFactoryAddress?new ye(t.safeAccountFactoryAddress):new ye;const A=null!=(c=t.safeAccountSingleton)?c:b,p=this.createProxyAddress(f,{c2Nonce:null!=(d=t.c2Nonce)?d:0n,safeFactoryAddress:h.address,singletonInitHash:A.singletonInitHash}),m=[A.singletonAddress,f,null!=(u=t.c2Nonce)?u:0n],y=h.getFactoryGeneratorFunctionCallData(m);return[p,h.address,y]}static createBaseInitializerCallData(e,t,a,n,r=Se.DEFAULT_MULTISEND_CONTRACT_ADDRESS,i=Se.DEFAULT_WEB_AUTHN_SHARED_SIGNER,s=Se.DEFAULT_WEB_AUTHN_PRECOMPILE,o=Se.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER){if(e.length<1)throw RangeError("There should be at least one owner");if(t<1)throw RangeError("threshold should be at least one");if(t>e.length)throw RangeError("threshold can't be larger than number of owners");const l=C("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:x.Delegate});const u=[];let f=0;for(const t of e)if("string"!=typeof t){if(f>0)throw RangeError("Only one WebAuthn owner can be set during initialization");const e=C("0x0dd9692f",["uint256","uint256","uint176"],[t.x,t.y,"0x"+s.slice(-4)+o.slice(2)]);d.push({to:i,value:0n,data:e,operation:x.Delegate}),u.push(i),f++}else u.push(t);c=[u,t,r,C("0x8d80ff0a",["bytes"],[pe(d)]),a,y,0,y]}else c=[u,t,n,l,a,y,0,y];return C(Se.initializerFunctionSelector,Se.initializerFunctionInputAbi,c)}static createFactoryAddressAndData(e,t={},a,n){var r,i,s,o,l,c,d,u;if(e.length<1)throw RangeError("There should be at least one owner");const f=null!=(r=t.threshold)?r:1,h=null!=(i=t.c2Nonce)?i:0;if(f<1)throw RangeError("threshold should be at least one");if(f>e.length)throw RangeError("threshold can't be larger than number of owners");if(h<0n)throw RangeError("c2Nonce can't be negative");const A=Se.createBaseInitializerCallData(e,null!=(s=t.threshold)?s:1,a,n,null!=(o=t.multisendContractAddress)?o:Se.DEFAULT_MULTISEND_CONTRACT_ADDRESS,null!=(l=t.webAuthnSharedSigner)?l:Se.DEFAULT_WEB_AUTHN_SHARED_SIGNER,null!=(c=t.eip7212WebAuthnPrecompileVerifierForSharedSigner)?c:Se.DEFAULT_WEB_AUTHN_PRECOMPILE,null!=(d=t.eip7212WebAuthnContractVerifierForSharedSigner)?d:Se.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER);let p;p=null!=t.safeAccountFactoryAddress?new ye(t.safeAccountFactoryAddress):new ye;const m=null!=(u=t.safeAccountSingleton)?u:b,y=p.getFactoryGeneratorFunctionCallData([m.singletonAddress,A,h]);return[p.address,y]}prependTokenPaymasterApproveToCallData(e,t,a,n,r={}){var i;const s=null!=(i=r.multisendContractAddress)?i:Se.DEFAULT_MULTISEND_CONTRACT_ADDRESS;return Se.prependTokenPaymasterApproveToCallDataStatic(e,t,a,n,{multisendContractAddress:s})}async estimateUserOperationGas(e,t,a={}){const n=0xffffffffffffn,r=0xffffffffffffn;if(null!=a.dummySignerSignaturePairs){if(null!=a.expectedSigners)throw RangeError("Can't use both dummySignerSignaturePairs and expectedSigners overrides.");if(a.dummySignerSignaturePairs.length<1)throw RangeError("Number of dummy signers signature pairs can't be less than 1");e.signature=Se.formatSignaturesToUseroperationSignature(a.dummySignerSignaturePairs,{validAfter:n,validUntil:r})}else if(null!=a.expectedSigners){let t;t="initCode"in e?e.initCode:e.factory;const i=Se.createDummySignerSignaturePairForExpectedSigners(a.expectedSigners,{isInit:null!=t&&"0x"!=t,webAuthnSharedSigner:a.webAuthnSharedSigner,eip7212WebAuthnPrecompileVerifier:a.eip7212WebAuthnPrecompileVerifier,eip7212WebAuthnContractVerifier:a.eip7212WebAuthnContractVerifier,webAuthnSignerFactory:a.webAuthnSignerFactory,webAuthnSignerSingleton:a.webAuthnSignerSingleton,validAfter:n,validUntil:r});e.signature=Se.formatSignaturesToUseroperationSignature(i,{validAfter:n,validUntil:r})}else e.signature.length<3&&(e.signature=Se.formatSignaturesToUseroperationSignature([he],{validAfter:n,validUntil:r}));const i=new te(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,h,A,p,y,g,E,D,S,b;if(e.length<1)throw RangeError("There should be at least one transaction");const w=null!=(i=r.webAuthnSharedSigner)?i:Se.DEFAULT_WEB_AUTHN_SHARED_SIGNER,v=null!=(s=r.safeModuleExecutorFunctionSelector)?s:Se.DEFAULT_EXECUTOR_FUCNTION_SELECTOR,T=null!=(o=r.multisendContractAddress)?o:Se.DEFAULT_MULTISEND_CONTRACT_ADDRESS;let x=null,F=null;if(null==r.nonce){if(null==a)throw new G("BAD_DATA","providerRpc cant't be null if nonce is not overriden");F=M(a,this.entrypointAddress,this.accountAddress)}else x=r.nonce;if("bigint"==typeof r.maxFeePerGas&&r.maxFeePerGas<0n)throw RangeError("maxFeePerGas overrid can't be negative");if("bigint"==typeof r.maxPriorityFeePerGas&&r.maxPriorityFeePerGas<0n)throw RangeError("maxPriorityFeePerGas overrid can't be negative");let R=_.maxFeePerGas,P=_.maxPriorityFeePerGas,L=null;null!=r.maxFeePerGas&&null!=r.maxPriorityFeePerGas||(L=z(a,r.polygonGasStation,r.gasLevel)),null!=L&&null!=F?await Promise.all([F,L]).then(e=>{x=e[0],[R,P]=e[1]}):null!=L?[R,P]=await L:null!=F&&(x=await F),R=null!=(l=r.maxFeePerGas)?l:R*BigInt(Math.floor(((null!=(c=r.maxFeePerGasPercentageMultiplier)?c:0)+100)/100)),P=null!=(d=r.maxPriorityFeePerGas)?d:P*BigInt(Math.floor(((null!=(u=r.maxPriorityFeePerGasPercentageMultiplier)?u:0)+100)/100));const U=null!=(f=r.eip7212WebAuthnPrecompileVerifier)?f:Se.DEFAULT_WEB_AUTHN_PRECOMPILE,I=null!=(h=r.eip7212WebAuthnContractVerifier)?h:Se.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER,O=null!=(A=r.webAuthnSignerFactory)?A:Se.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,V=null!=(p=r.webAuthnSignerSingleton)?p:Se.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON;let B=this.factoryAddress,N=this.factoryData;if(null==x)throw RangeError("failed to determine nonce");if(x<0n)throw RangeError("nonce can't be negative");if(x>0n)B=null,N=null;else if(this.isInitWebAuthn){if(null==this.x||null==this.y)throw RangeError("Invalide account initialization with Webauthnn signer.Webauthnn signer publickey can be null!!");const t=Se.createDeployWebAuthnVerifierMetaTransaction(this.x,this.y,{eip7212WebAuthnPrecompileVerifier:U,eip7212WebAuthnContractVerifier:I,webAuthnSignerFactory:O}),a=C("0xe318b52b",["address","address","address"],["0x0000000000000000000000000000000000000001",w,Se.createWebAuthnSignerVerifierAddress(this.x,this.y,{eip7212WebAuthnPrecompileVerifier:U,eip7212WebAuthnContractVerifier:I,webAuthnSignerFactory:O,webAuthnSignerSingleton:V})]);e=[t,{to:this.accountAddress,value:0n,data:a}].concat(e)}let W="0x";W=null==r.callData?1==e.length?Se.createAccountCallDataSingleTransaction(e[0],{safeModuleExecutorFunctionSelector:v}):Se.createAccountCallDataBatchTransactions(e,{safeModuleExecutorFunctionSelector:v,multisendContractAddress:T}):r.callData,null!=this.onChainIdentifier&&(W+=this.onChainIdentifier);const k=m({},_,{sender:this.accountAddress,nonce:x,callData:W,maxFeePerGas:R,maxPriorityFeePerGas:P});let H=_.preVerificationGas,Y=_.verificationGasLimit,j=_.callGasLimit;if(null==r.preVerificationGas||null==r.verificationGasLimit||null==r.callGasLimit){if(null==n)throw new G("BAD_DATA","bundlerRpc cant't be null if preVerificationGas,verificationGasLimit and callGasLimit are not overriden");{k.callGasLimit=0n,k.verificationGasLimit=0n,k.preVerificationGas=0n;const e=k.maxFeePerGas,a=k.maxPriorityFeePerGas;let i;if(k.maxFeePerGas=0n,k.maxPriorityFeePerGas=0n,t){let e="0x";null!=B&&(e=B,null!=N&&(e+=N.slice(2))),i=m({},k,{initCode:e,paymasterAndData:"0x"})}else i=m({},k,{factory:B,factoryData:N,paymaster:null,paymasterVerificationGasLimit:null,paymasterPostOpGasLimit:null,paymasterData:null});const s=0xffffffffffffn,o=0xffffffffffffn;let l;if(null!=r.dummySignerSignaturePairs){if(null!=r.expectedSigners)throw RangeError("Can't use both dummySignerSignaturePairs and expectedSigners overrides.");if(r.dummySignerSignaturePairs.length<1)throw RangeError("Number of dummySignerSignaturePairs can't be less than 1");l=r.dummySignerSignaturePairs}else l=null==r.expectedSigners?[he]:Se.createDummySignerSignaturePairForExpectedSigners(r.expectedSigners,{isInit:null!=B&&"0x"!=B,webAuthnSharedSigner:w,eip7212WebAuthnPrecompileVerifier:U,eip7212WebAuthnContractVerifier:I,webAuthnSignerFactory:O,webAuthnSignerSingleton:V,validAfter:s,validUntil:o});k.signature=Se.formatSignaturesToUseroperationSignature(l,{validAfter:s,validUntil:o,webAuthnSharedSigner:w}),[H,Y,j]=await this.estimateUserOperationGas(i,n,{stateOverrideSet:r.state_override_set}),Y+=55000n*BigInt(l.length),k.maxFeePerGas=e,k.maxPriorityFeePerGas=a}}if("bigint"==typeof r.preVerificationGas&&r.preVerificationGas<0n)throw RangeError("preVerificationGas overrid can't be negative");if("bigint"==typeof r.verificationGasLimit&&r.verificationGasLimit<0n)throw RangeError("verificationGasLimit overrid can't be negative");if("bigint"==typeof r.callGasLimit&&r.callGasLimit<0n)throw RangeError("callGasLimit overrid can't be negative");return k.preVerificationGas=null!=(y=r.preVerificationGas)?y:H*BigInt(Math.floor(((null!=(g=r.preVerificationGasPercentageMultiplier)?g:0)+100)/100)),k.verificationGasLimit=null!=(E=r.verificationGasLimit)?E:Y*BigInt(Math.floor(((null!=(D=r.verificationGasLimitPercentageMultiplier)?D:0)+100)/100)),k.callGasLimit=null!=(S=r.callGasLimit)?S:j*BigInt(Math.floor(((null!=(b=r.callGasLimitPercentageMultiplier)?b:0)+100)/100)),[k,B,N]}signUserOperation(e,t,a,n={}){var r,i;const o=null!=(r=n.validAfter)?r:0n,l=null!=(i=n.validUntil)?i:0n;if(t.length<1)throw RangeError("There should be at least one privateKey");if(a<0n)throw RangeError("chainId can't be negative");if(o<0n)throw RangeError("validAfter can't be negative");if(l<0n)throw RangeError("validUntil can't be negative");const c=Se.getUserOperationEip712Hash(e,a,{validAfter:o,validUntil:l,entrypointAddress:this.entrypointAddress,safe4337ModuleAddress:this.safe4337ModuleAddress}),d=[],u=[];for(const e of t){const t=new s(e),a=t.signingKey.sign(c).serialized;d.push(t.address),u.push(a)}return Se.formatEip712SignaturesToUseroperationSignature(d,u,{validAfter:o,validUntil:l})}static createWebAuthnSignerVerifierAddress(e,t,n={}){var r,i,s,o;const l=null!=(r=n.eip7212WebAuthnPrecompileVerifier)?r:Se.DEFAULT_WEB_AUTHN_PRECOMPILE,d=null!=(i=n.eip7212WebAuthnContractVerifier)?i:Se.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER,f=null!=(s=n.webAuthnSignerFactory)?s:Se.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,h=null!=(o=n.webAuthnSignerSingleton)?o:Se.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON;if(42!=l.length||l.slice(0,38)!=y.slice(0,38))throw RangeError("Invalide precompile address. It should have the format 0x000000000000000000000000000000000000____");const A=a(c(["bytes","uint256","uint256","uint256","uint256"],[Se.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE,h,e,t,"0x"+l.slice(-4)+d.slice(2)]));return"0x"+u(["bytes1","address","bytes32","bytes32"],["0xff",f,"0x0000000000000000000000000000000000000000000000000000000000000000",A]).slice(-40)}static formatSignaturesToUseroperationSignature(e,t={}){var a,n;const r=null!=(a=t.validAfter)?a:0n,i=null!=(n=t.validUntil)?n:0n,s=this.buildSignaturesFromSingerSignaturePairs(e,t);return c(["uint48","uint48","bytes"],[r,i,s])}static getSignerLowerCaseAddress(e,t={}){if("string"==typeof e)return e.toLowerCase();{var a,n,r,i;const s=null!=(a=t.eip7212WebAuthnPrecompileVerifier)?a:Se.DEFAULT_WEB_AUTHN_PRECOMPILE,o=null!=(n=t.eip7212WebAuthnContractVerifier)?n:Se.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER,l=null!=(r=t.webAuthnSignerFactory)?r:Se.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,c=null!=(i=t.webAuthnSignerSingleton)?i:Se.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON;return Se.createWebAuthnSignerVerifierAddress(e.x,e.y,{eip7212WebAuthnPrecompileVerifier:s,eip7212WebAuthnContractVerifier:o,webAuthnSignerFactory:l,webAuthnSignerSingleton:c}).toLowerCase()}}static sortSignatures(e,t={}){e.sort((e,a)=>Se.getSignerLowerCaseAddress(e.signer,t).localeCompare(Se.getSignerLowerCaseAddress(a.signer,t)))}static buildSignaturesFromSingerSignaturePairs(e,t={}){Se.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 RangeError("Must define isInit parameter when using WebAuthn");if(t.isInit){var o;r=null!=(o=t.webAuthnSharedSigner)?o:Se.DEFAULT_WEB_AUTHN_SHARED_SIGNER}else{var l,c,d,u;const e=null!=(l=t.eip7212WebAuthnPrecompileVerifier)?l:Se.DEFAULT_WEB_AUTHN_PRECOMPILE,a=null!=(c=t.eip7212WebAuthnContractVerifier)?c:Se.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER,n=null!=(d=t.webAuthnSignerFactory)?d:Se.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,i=null!=(u=t.webAuthnSignerSingleton)?u:Se.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON;r=Se.createWebAuthnSignerVerifierAddress(r.x,r.y,{eip7212WebAuthnPrecompileVerifier:e,eip7212WebAuthnContractVerifier:a,webAuthnSignerFactory:n,webAuthnSignerSingleton:i})}}return{segments:[...e,A.solidityPacked(["uint256","uint256","uint8"],[r,a+n,0])],offset:n+32+A.dataLength(i)}}return{segments:[...e,A.solidityPacked(["bytes"],[i])],offset:n}},{segments:[],offset:0});return A.concat([...n,...e.map(({signer:e,signature:t,isContractSignature:a})=>(a=a||"string"!=typeof e)?A.solidityPacked(["uint256","bytes"],[A.dataLength(t),t]):"0x")])}static createWebAuthnSignature(e){return A.AbiCoder.defaultAbiCoder().encode(["bytes","bytes","uint256[2]"],[new Uint8Array(e.authenticatorData),e.clientDataFields,e.rs])}async createSwapOwnerMetaTransactions(e,t,a,n={}){let r,i,s=null;"string"!=typeof t?(r=Se.createWebAuthnSignerVerifierAddress(t.x,t.y,{eip7212WebAuthnPrecompileVerifier:n.eip7212WebAuthnPrecompileVerifier,eip7212WebAuthnContractVerifier:n.eip7212WebAuthnContractVerifier,webAuthnSignerFactory:n.webAuthnSignerFactory,webAuthnSignerSingleton:n.webAuthnSignerSingleton}),(await H(e,r,"latest")).length<3&&(s=Se.createDeployWebAuthnVerifierMetaTransaction(t.x,t.y,{eip7212WebAuthnPrecompileVerifier:n.eip7212WebAuthnPrecompileVerifier,eip7212WebAuthnContractVerifier:n.eip7212WebAuthnContractVerifier,webAuthnSignerFactory:n.webAuthnSignerFactory}))):r=t,i="string"!=typeof a?Se.createWebAuthnSignerVerifierAddress(a.x,a.y,{eip7212WebAuthnPrecompileVerifier:n.eip7212WebAuthnPrecompileVerifier,eip7212WebAuthnContractVerifier:n.eip7212WebAuthnContractVerifier,webAuthnSignerFactory:n.webAuthnSignerFactory,webAuthnSignerSingleton:n.webAuthnSignerSingleton}):a;let o=n.prevOwner;if(null==o){const t=await this.getOwners(e),a=t.indexOf(i);if(-1==a)throw RangeError("oldOwner is not a current owner.");if(0==a)o="0x0000000000000000000000000000000000000001";else{if(!(a>0))throw RangeError("Invalid owner index");o=t[a-1]}}const l=this.createStandardSwapOwnerMetaTransaction(r,i,o);return null==s?[l]:[s,l]}async createRemoveOwnerMetaTransaction(e,t,a,n={}){let r;r="string"!=typeof t?Se.createWebAuthnSignerVerifierAddress(t.x,t.y,{eip7212WebAuthnPrecompileVerifier:n.eip7212WebAuthnPrecompileVerifier,eip7212WebAuthnContractVerifier:n.eip7212WebAuthnContractVerifier,webAuthnSignerFactory:n.webAuthnSignerFactory,webAuthnSignerSingleton:n.webAuthnSignerSingleton}):t;let i=n.prevOwner;if(null==i){const t=await this.getOwners(e),a=t.indexOf(r);if(-1==a)throw RangeError("ownerToDelete is not a current owner.");if(0==a)i="0x0000000000000000000000000000000000000001";else{if(!(a>0))throw RangeError("Invalid owner index");i=t[a-1]}}return this.createStandardRemoveOwnerMetaTransaction(r,a,i)}async createAddOwnerWithThresholdMetaTransactions(e,t,a={}){let n,r=null;if("string"!=typeof e){if(n=Se.createWebAuthnSignerVerifierAddress(e.x,e.y,{eip7212WebAuthnPrecompileVerifier:a.eip7212WebAuthnPrecompileVerifier,eip7212WebAuthnContractVerifier:a.eip7212WebAuthnContractVerifier,webAuthnSignerFactory:a.webAuthnSignerFactory,webAuthnSignerSingleton:a.webAuthnSignerSingleton}),null==a.nodeRpcUrl)throw RangeError("overrides.nodeRpcUrl can't be null if adding a webauthn owner");(await H(a.nodeRpcUrl,n,"latest")).length<3&&(r=Se.createDeployWebAuthnVerifierMetaTransaction(e.x,e.y,{eip7212WebAuthnPrecompileVerifier:a.eip7212WebAuthnPrecompileVerifier,eip7212WebAuthnContractVerifier:a.eip7212WebAuthnContractVerifier,webAuthnSignerFactory:a.webAuthnSignerFactory}))}else n=e;const i=this.createStandardAddOwnerWithThresholdMetaTransaction(n,t);return null==r?[i]:[r,i]}createStandardAddOwnerWithThresholdMetaTransaction(e,t){const a=C("0x0d582f13",["address","uint256"],[e,t]);return{to:this.accountAddress,data:a,value:0n}}createStandardSwapOwnerMetaTransaction(e,t,a){const n=C("0xe318b52b",["address","address","address"],[a,t,e]);return{to:this.accountAddress,data:n,value:0n}}createStandardRemoveOwnerMetaTransaction(e,t,a){const n=C("0xf8dc5dd9",["address","address","uint256"],[a,e,t]);return{to:this.accountAddress,data:n,value:0n}}createChangeThresholdMetaTransaction(e){if(e<1)throw RangeError("threshold can't be less than 1.");const t=C("0x694e80c3",["uint256"],[e]);return{to:this.accountAddress,data:t,value:0n}}createApproveHashMetaTransaction(e){const t=C("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:Se.DEFAULT_WEB_AUTHN_PRECOMPILE,o=null!=(r=a.eip7212WebAuthnContractVerifier)?r:Se.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER;return{to:null!=(i=a.webAuthnSignerFactory)?i:Se.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,value:0n,data:C("0x0d2f0489",["uint256","uint256","uint176"],[e,t,"0x"+s.slice(-4)+o.slice(2)])}}async getOwners(e){const a=C(O("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=C("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=C("0xcc2f8452",["address","uint256"],[n,r]),s={to:this.accountAddress,data:i},o=await k(e,s,"latest");if("0x"==o)throw new G("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=L(e);throw new G("BAD_DATA","getModules failed",{cause:t})}}async isModuleEnabled(e,a){const n=C(O("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=he;else{if(null==t.isInit)throw RangeError("Must define isInit parameter when using WebAuthn");if(a=Ae,t.isInit){var r;const e=null!=(r=t.webAuthnSharedSigner)?r:Se.DEFAULT_WEB_AUTHN_SHARED_SIGNER;a.signer=e}else{var i,s,o,l;const n=null!=(i=t.eip7212WebAuthnPrecompileVerifier)?i:Se.DEFAULT_WEB_AUTHN_PRECOMPILE,r=null!=(s=t.eip7212WebAuthnContractVerifier)?s:Se.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER,c=null!=(o=t.webAuthnSignerFactory)?o:Se.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,d=null!=(l=t.webAuthnSignerSingleton)?l:Se.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON;a.signer=Se.createWebAuthnSignerVerifierAddress(e.x,e.y,{eip7212WebAuthnPrecompileVerifier:n,eip7212WebAuthnContractVerifier:r,webAuthnSignerFactory:c,webAuthnSignerSingleton:d})}}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 RangeError("Invalide messageHash ,must be a 0x prefixed keccak256 hash.");const c=null!=(s=i.eip7212WebAuthnPrecompileVerifier)?s:Se.DEFAULT_WEB_AUTHN_PRECOMPILE,d=null!=(o=i.eip7212WebAuthnContractVerifier)?o:Se.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER,u=null!=(l=i.webAuthnSignerSingleton)?l:Se.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON;if(42!=c.length||c.slice(0,38)!=y.slice(0,38))throw RangeError("Invalide precompile address. It should have the format 0x000000000000000000000000000000000000____");const f="0x1111111111111111111111111111111111111111",h={to:f,data:C("0x1626ba7e",["bytes32","bytes"],[n,r])},A=Se.createSafeWebAuthnSignerProxyDeployedByteCode(a,c,d,u),p=await k(e,h,"latest",{[f]:{code:A}});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:C("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 RangeError("moduleToDisable "+t+" is not an enabled module.");if(0==s)r="0x0000000000000000000000000000000000000001";else{if(!(s>0))throw RangeError("Invalid module index for "+t);r=a[s-1]}}return Se.createStandardDisableModuleMetaTransaction(t,r,a)}catch(e){const t=L(e);throw new G("BAD_DATA","createDisableModuleMetaTransaction failed",{cause:t})}}static createStandardDisableModuleMetaTransaction(e,t,a){return{to:a,data:C("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 RangeError("nodeRpcUrl and overrides.isInit can't both be null");c=null==o.isInit?0n==await M(n,this.entrypointAddress,this.accountAddress):o.isInit;let d="0x";return d=null==o.callData?1==i.length?Se.createAccountCallDataSingleTransaction(i[0],{safeModuleExecutorFunctionSelector:o.safeModuleExecutorFunctionSelector}):Se.createAccountCallDataBatchTransactions(i,{safeModuleExecutorFunctionSelector:o.safeModuleExecutorFunctionSelector,multisendContractAddress:o.multisendContractAddress}):o.callData,null==(l=o.createShareLink)||l?await ce(e,t,a,r,this.entrypointAddress,this.accountAddress,d,c?this.factoryAddress:null,c?this.factoryData:null,s):{simulation:await de(e,t,a,r,this.entrypointAddress,this.accountAddress,d,c?this.factoryAddress:null,c?this.factoryData:null,s)}}getSafeMessageEip712Data(e,t){return De(this.accountAddress,e,t)}}Se.DEFAULT_WEB_AUTHN_SHARED_SIGNER="0xfD90FAd33ee8b58f32c00aceEad1358e4AFC23f9",Se.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON="0x270D7E4a57E6322f336261f3EaE2BADe72E68d72",Se.DEFAULT_WEB_AUTHN_SIGNER_FACTORY="0xF7488fFbe67327ac9f37D5F722d83Fc900852Fbf",Se.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER="0x445a0683e494ea0c5AF3E83c5159fBE47Cf9e765",Se.DEFAULT_WEB_AUTHN_PRECOMPILE="0x0000000000000000000000000000000000000000",Se.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE="0x61010060405234801561001157600080fd5b506040516101ee3803806101ee83398101604081905261003091610058565b6001600160a01b0390931660805260a09190915260c0526001600160b01b031660e0526100bc565b6000806000806080858703121561006e57600080fd5b84516001600160a01b038116811461008557600080fd5b60208601516040870151606088015192965090945092506001600160b01b03811681146100b157600080fd5b939692955090935050565b60805160a05160c05160e05160ff6100ef60003960006008015260006031015260006059015260006080015260ff6000f3fe608060408190527f00000000000000000000000000000000000000000000000000000000000000003660b681018290527f000000000000000000000000000000000000000000000000000000000000000060a082018190527f00000000000000000000000000000000000000000000000000000000000000008285018190527f00000000000000000000000000000000000000000000000000000000000000009490939192600082376000806056360183885af490503d6000803e8060c3573d6000fd5b503d6000f3fea2646970667358221220ddd9bb059ba7a6497d560ca97aadf4dbf0476f578378554a50d41c6bb654beae64736f6c63430008180033",Se.DEFAULT_MULTISEND_CONTRACT_ADDRESS="0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526",Se.initializerFunctionSelector="0xb63e800d",Se.initializerFunctionInputAbi=["address[]","uint256","address","bytes","address","address","uint256","address"],Se.DEFAULT_EXECUTOR_FUCNTION_SELECTOR=fe.executeUserOpWithErrorString,Se.executorFunctionInputAbi=["address","uint256","bytes","uint8"];class be{constructor(e){this.moduleAddress=void 0,this.abiCoder=void 0,this.moduleAddress=e,this.abiCoder=t.defaultAbiCoder()}createEnableModuleMetaTransaction(e){return Se.createEnableModuleMetaTransaction(this.moduleAddress,e)}checkForEmptyResultAndRevert(e,t){if("0x"==e)throw new G("BAD_DATA",t+" returned 0x, module contract "+this.moduleAddress+" is probably not deployed")}}var _e;!function(e){e.After3Minutes="0x949d01d424bE050D09C16025dd007CB59b3A8c66",e.After3Days="0x38275826E1933303E508433dD5f289315Da2541c",e.After7Days="0x088f6cfD8BB1dDb1BB069CCb3fc1A98927D233f2",e.After14Days="0x9BacD92F4687Db306D7ded5d4513a51EA05df25b"}(_e||(_e={}));class we extends be{constructor(e=we.DEFAULT_SOCIAL_RECOVERY_ADDRESS){super(e)}createConfirmRecoveryMetaTransaction(e,t,a,n){const r=C("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=C("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=C("0xb1f85f69",["address","address[]","uint256"],[e,t,a]);return{to:this.moduleAddress,data:n,value:0n}}createFinalizeRecoveryMetaTransaction(e){const t=C("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=C("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 RangeError(a+" is not a current guardian for account : "+t);if(0==r)i="0x0000000000000000000000000000000000000001";else{if(!(r>0))throw RangeError("Invalid guardian index");i=n[r-1]}}return this.createStandardRevokeGuardianWithThresholdMetaTransaction(i,a,n)}createStandardRevokeGuardianWithThresholdMetaTransaction(e,t,a){const n=C("0x936f7d86",["address","address","uint256"],[e,t,a]);return{to:this.moduleAddress,data:n,value:0n}}createChangeThresholdMetaTransaction(e){const t=C("0x694e80c3",["uint256"],[e]);return{to:this.moduleAddress,data:t,value:0n}}async getRecoveryHash(e,t,a,n,r){const i=C("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=C("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=C("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=C("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=C("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=C("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=C("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=C("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=C("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 we(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:Te,messageValue:o}}}we.DEFAULT_SOCIAL_RECOVERY_ADDRESS=_e.After3Days;const ve="ExecuteRecovery",Te={ExecuteRecovery:[{type:"address",name:"wallet"},{type:"address[]",name:"newOwners"},{type:"uint256",name:"newThreshold"},{type:"uint256",name:"nonce"}]};class xe extends be{constructor(e=xe.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=C("0xbeaeb388",["address","address","uint96","uint16","uint32"],[e,t,a,n,r]);return{to:this.moduleAddress,data:i,value:0n}}createRenewAllowanceMetaTransaction(e,t){const a=C("0xc19bf50e",["address","address"],[e,t]);return{to:this.moduleAddress,data:a,value:0n}}createDeleteAllowanceMetaTransaction(e,t){const a=C("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 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=C("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=C("0xe71bdf41",["address"],[e]);return{to:this.moduleAddress,data:t,value:0n}}createRemoveDelegateMetaTransaction(e,t){const a=C("0xdd43a79f",["address","bool"],[e,t]);return{to:this.moduleAddress,data:a,value:0n}}async getTokens(e,t,a){const n=C("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=C("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=C("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])}}}xe.DEFAULT_ALLOWANCE_MODULE_ADDRESS="0xAA46724893dedD72658219405185Fb0Fc91e091C";class Fe extends Se{constructor(e,t={}){var a,n;super(e,null!=(a=t.safe4337ModuleAddress)?a:Fe.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(n=t.entrypointAddress)?n:Fe.DEFAULT_ENTRYPOINT_ADDRESS,{onChainIdentifierParams:t.onChainIdentifierParams,onChainIdentifier:t.onChainIdentifier,safeAccountSingleton:t.safeAccountSingleton})}static createAccountAddress(e,t={}){var a,n;const[r,,]=Se.createAccountAddressAndFactoryAddressAndData(e,t,null!=(a=t.safe4337ModuleAddress)?a:Fe.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(n=t.safeModuleSetupddress)?n:Fe.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 RangeError("Only one Webauthn signer is allowed during initialization");if(0!=e.indexOf(t))throw 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]=Se.createAccountAddressAndFactoryAddressAndData(e,t,null!=(a=t.safe4337ModuleAddress)?a:Fe.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(n=t.safeModuleSetupddress)?n:Fe.DEFAULT_SAFE_MODULE_SETUP_ADDRESS),d=new Fe(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:Fe.DEFAULT_ENTRYPOINT_ADDRESS,d=null!=(s=a.safe4337ModuleAddress)?s:Fe.DEFAULT_SAFE_4337_MODULE_ADDRESS;return Se.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:Fe.DEFAULT_ENTRYPOINT_ADDRESS,d=null!=(s=a.safe4337ModuleAddress)?s:Fe.DEFAULT_SAFE_4337_MODULE_ADDRESS;return Se.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:Fe.DEFAULT_SAFE_4337_MODULE_ADDRESS,s=null!=(r=a.safeModuleSetupddress)?r:Fe.DEFAULT_SAFE_MODULE_SETUP_ADDRESS;return Se.createBaseInitializerCallData(e,t,i,s,a.multisendContractAddress,a.webAuthnSharedSigner,a.eip7212WebAuthnPrecompileVerifierForSharedSigner,a.eip7212WebAuthnContractVerifierForSharedSigner)}static createFactoryAddressAndData(e,t={}){var a,n;return Se.createFactoryAddressAndData(e,t,null!=(a=t.safe4337ModuleAddress)?a:Fe.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(n=t.safeModuleSetupddress)?n:Fe.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})}}Fe.DEFAULT_ENTRYPOINT_ADDRESS=E,Fe.DEFAULT_SAFE_4337_MODULE_ADDRESS="0x75cf11467937ce3F2f357CE24ffc3DBF8fD5c226",Fe.DEFAULT_SAFE_MODULE_SETUP_ADDRESS="0x2dd68b007B46fBe91B9A7c3EDa5A7a1063cB5b47";class Re extends Se{constructor(e,t={}){var a,n;super(e,null!=(a=t.safe4337ModuleAddress)?a:Re.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(n=t.entrypointAddress)?n:Re.DEFAULT_ENTRYPOINT_ADDRESS,{onChainIdentifierParams:t.onChainIdentifierParams,onChainIdentifier:t.onChainIdentifier})}static createAccountAddress(e,t={}){var a,n;const[r,,]=Se.createAccountAddressAndFactoryAddressAndData(e,t,null!=(a=t.safe4337ModuleAddress)?a:Re.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(n=t.safeModuleSetupddress)?n:Re.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 RangeError("Only one Webauthn signer is allowed during initialization");if(0!=e.indexOf(t))throw 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]=Re.createAccountAddressAndFactoryAddressAndData(e,t,null!=(a=t.safe4337ModuleAddress)?a:Re.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(n=t.safeModuleSetupddress)?n:Re.DEFAULT_SAFE_MODULE_SETUP_ADDRESS),d=new Re(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:Re.DEFAULT_ENTRYPOINT_ADDRESS,d=null!=(s=a.safe4337ModuleAddress)?s:Re.DEFAULT_SAFE_4337_MODULE_ADDRESS;return Se.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:Re.DEFAULT_ENTRYPOINT_ADDRESS,d=null!=(s=a.safe4337ModuleAddress)?s:Re.DEFAULT_SAFE_4337_MODULE_ADDRESS;return Se.getUserOperationEip712Data(e,t,{validAfter:o,validUntil:l,entrypointAddress:c,safe4337ModuleAddress:d})}static createAccountAddressAndInitCode(e,t={}){var a,n;const[r,i,s]=Se.createAccountAddressAndFactoryAddressAndData(e,t,null!=(a=t.safe4337ModuleAddress)?a:Re.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(n=t.safeModuleSetupddress)?n:Re.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:Re.DEFAULT_SAFE_4337_MODULE_ADDRESS,s=null!=(r=a.safeModuleSetupddress)?r:Re.DEFAULT_SAFE_MODULE_SETUP_ADDRESS;return Se.createBaseInitializerCallData(e,t,i,s,a.multisendContractAddress,a.webAuthnSharedSigner,a.eip7212WebAuthnPrecompileVerifierForSharedSigner,a.eip7212WebAuthnContractVerifierForSharedSigner)}static createInitCode(e,t={}){var a,n;const[r,i]=Se.createFactoryAddressAndData(e,t,null!=(a=t.safe4337ModuleAddress)?a:Re.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(n=t.safeModuleSetupddress)?n:Re.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:Re.DEFAULT_SAFE_4337_MODULE_ADDRESS,i=null!=(n=t.safeV07ModuleAddress)?n:Fe.DEFAULT_SAFE_4337_MODULE_ADDRESS,s=await this.createDisableModuleMetaTransaction(e,r,this.accountAddress,{prevModuleAddress:t.safeV06ModuleAddress,modulesPageSize:t.pageSize,modulesStart:t.modulesStart}),o=Se.createEnableModuleMetaTransaction(i,this.accountAddress),l=C("0xf08a0323",["address"],[i]);return[s,o,{to:this.accountAddress,value:0n,data:l}]}}Re.DEFAULT_ENTRYPOINT_ADDRESS=D,Re.DEFAULT_SAFE_4337_MODULE_ADDRESS="0xa581c4A4DB7175302464fF3C06380BC3270b4037",Re.DEFAULT_SAFE_MODULE_SETUP_ADDRESS="0x8EcD4ec46D4D2a6B64fE960B3D64e8B94B2234eb";class Pe extends Fe{constructor(e,t={}){super(e,{onChainIdentifierParams:t.onChainIdentifierParams,onChainIdentifier:t.onChainIdentifier,safeAccountSingleton:S})}static createProxyAddress(e,t={}){var a;const n=t;return n.singletonInitHash=null!=(a=t.singletonInitHash)?a:S.singletonInitHash,Fe.createProxyAddress(e,n)}static initializeNewAccount(e,t={}){var a;return t.safeAccountSingleton=null!=(a=t.safeAccountSingleton)?a:S,Fe.initializeNewAccount(e,t)}static createAccountAddress(e,t={}){var a;const n=t;return n.safeAccountSingleton=null!=(a=t.safeAccountSingleton)?a:S,Fe.createAccountAddress(e,n)}static createFactoryAddressAndData(e,t={}){var a;return t.safeAccountSingleton=null!=(a=t.safeAccountSingleton)?a:S,Fe.createFactoryAddressAndData(e,t)}}class Ge{}class Le extends Ge{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 I(this.rpcUrl,"pm_clientVersion",[]);if(e.startsWith("Candide/v3"))this.version="v3";else{if(!e.startsWith("Candide/v2"))throw RangeError("Invalid paymaster version received from paymaster rpc");this.version="v2"}const t=await this.getSupportedEntrypointsLive();if(t.some(e=>e.toLowerCase()===g.toLowerCase())){const e=await this.getSupportedERC20TokensAndPaymasterMetadata(g);this.entrypointDataV8=null!=e?e:null}if(t.some(e=>e.toLowerCase()===E.toLowerCase())){const e=await this.getSupportedERC20TokensAndPaymasterMetadata(E);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 RangeError("Invalid data received during initialization.");return this.initialized=!0,null}catch(e){const t=L(e);throw new G("PAYMASTER_ERROR","failed initializing the paymaster",{cause:t})}}async getSupportedERC20TokensAndPaymasterMetadata(e){if(this.initialized){var t,a,n;if(e==g)return null!=(t=this.entrypointDataV8)?t:null;if(e==E)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 I(this.rpcUrl,"pm_supportedERC20Tokens",[e]):await I(this.rpcUrl,"pm_supportedERC20Tokens",[]),e==g)return{tokens:t.tokens.map(e=>({name:e.name,symbol:e.symbol,address:e.address,decimals:Number(e.decimals)})),paymasterMetadata:t.paymasterMetadata};if(e==E)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 RangeError("unsupported entrypoint.")}catch(e){const t=L(e);throw new G("PAYMASTER_ERROR","getSupportedERC20TokensAndPaymasterMetadata failed",{cause:t})}return null}async getSupportedEntrypointsLive(){try{return"v3"==this.version?await I(this.rpcUrl,"pm_supportedEntryPoints",[]):[await I(this.rpcUrl,"pm_supportedEntryPoint",[])]}catch(e){const t=L(e);throw new G("PAYMASTER_ERROR","getSupportedEntrypoint failed",{cause:t})}}async getSupportedEntrypoints(){this.initialized||await this.initialize();const e=[];return null!=this.entrypointDataV8&&e.push(g),null!=this.entrypointDataV7&&e.push(E),null!=this.entrypointDataV6&&e.push(D),e}async getPaymasterMetaData(e){if(this.initialized||await this.initialize(),e==g&&null!=this.entrypointDataV8)return this.entrypointDataV8.paymasterMetadata;if(e==E&&null!=this.entrypointDataV7)return this.entrypointDataV7.paymasterMetadata;if(e==D&&null!=this.entrypointDataV6)return this.entrypointDataV6.paymasterMetadata;throw RangeError("unsupported entrypoint.")}async isSupportedERC20Token(e,t=E){return!!this.getSupportedERC20TokenData(e,t)}async getSupportedERC20TokenData(e,t=E){let a;if(this.initialized||await this.initialize(),t==g&&null!=this.entrypointDataV8)a=this.entrypointDataV8.tokens;else if(t==E&&null!=this.entrypointDataV7)a=this.entrypointDataV7.tokens;else{if(t!=D||null==this.entrypointDataV6)throw 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 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 RangeError("UserOperation v0.08 is not supported");n=g;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 RangeError("UserOperation v0.07 is not supported");n=E;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,h,A,p,y;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 G("BAD_DATA","bundlerRpc can't be null if preVerificationGas,verificationGasLimit and callGasLimit are not overridden");{const o=new te(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 RangeError("preVerificationGas override can't be negative");if("bigint"==typeof i.verificationGasLimit&&i.verificationGasLimit<0n)throw RangeError("verificationGasLimit override can't be negative");if("bigint"==typeof i.callGasLimit&&i.callGasLimit<0n)throw RangeError("callGasLimit override can't be negative");e.preVerificationGas=null!=(u=i.preVerificationGas)?u:a*BigInt(null!=(f=i.preVerificationGasPercentageMultiplier)?f:100)/100n,e.verificationGasLimit=null!=(h=i.verificationGasLimit)?h:r*BigInt(null!=(A=i.verificationGasLimitPercentageMultiplier)?A:100)/100n,e.callGasLimit=null!=(p=i.callGasLimit)?p:s*BigInt(null!=(y=i.callGasLimitPercentageMultiplier)?y:100)/100n,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 RangeError("you can't use any gas overrides for paymaster v3, as it will estimate gas and override any provided values.");const m=await I(this.rpcUrl,"pm_sponsorUserOperation",[e,n,a]),S=m,b={callGasLimit:null==S.callGasLimit?void 0:BigInt(S.callGasLimit),preVerificationGas:null==S.preVerificationGas?void 0:BigInt(S.preVerificationGas),verificationGasLimit:null==S.verificationGasLimit?void 0:BigInt(S.verificationGasLimit),maxFeePerGas:null==S.maxFeePerGas?void 0:BigInt(S.maxFeePerGas),maxPriorityFeePerGas:null==S.maxPriorityFeePerGas?void 0:BigInt(S.maxPriorityFeePerGas),sponsorMetadata:null==S.sponsorMetadata?void 0:S.sponsorMetadata};if(e.callGasLimit=null!=(s=b.callGasLimit)?s:e.callGasLimit,e.preVerificationGas=null!=(o=b.preVerificationGas)?o:e.preVerificationGas,e.verificationGasLimit=null!=(l=b.verificationGasLimit)?l:e.verificationGasLimit,e.maxFeePerGas=null!=(c=b.maxFeePerGas)?c:e.maxFeePerGas,e.maxPriorityFeePerGas=null!=(d=b.maxPriorityFeePerGas)?d:e.maxPriorityFeePerGas,r=b.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=L(e);throw new G("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{this.initialized||await this.initialize();const i=r||{};null==(null==i?void 0:i.callGasLimitPercentageMultiplier)&&(i.callGasLimitPercentageMultiplier=105);let s=null==r?void 0:r.entrypoint;null==s&&(s="initCode"in t?D:"eip7702Auth"in t?g:E);const o=2n*await this.calculateUserOperationErc20TokenMaxGasCost(t,a),l=await this.getPaymasterMetaData(s);if(null==l)throw RangeError("unsupported entrypoint.");const c=e.prependTokenPaymasterApproveToCallData(t.callData,a,l.address,o);if(t.callData=c,"initCode"in t){const[e]=await this.createPaymasterUserOperation(t,n,{token:a},i);return e}if("eip7702Auth"in t){const[e]=await this.createPaymasterUserOperation(t,n,{token:a},i);return e}{const[e]=await this.createPaymasterUserOperation(t,n,{token:a},i);return e}}catch(e){const t=L(e);throw new G("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?g:E),await this.fetchTokenPaymasterExchangeRate(t,n)*B(e)/BigInt(10**18)}catch(e){const t=L(e);throw new G("PAYMASTER_ERROR","calculateUserOperationErc20TokenMaxGasCost failed",{cause:t})}}async fetchTokenPaymasterExchangeRate(e,t=E){try{let a;this.initialized||await this.initialize(),a="v3"==this.version?await I(this.rpcUrl,"pm_supportedERC20Tokens",[t]):await I(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 G("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=L(e);throw new G("PAYMASTER_ERROR","fetchTokenPaymasterExchangeRate failed",{cause:t})}}async fetchSupportedERC20TokensAndPaymasterMetadata(e=E){try{let t;if(this.initialized||await this.initialize(),t="v3"==this.version?await I(this.rpcUrl,"pm_supportedERC20Tokens",[e]):await I(this.rpcUrl,"pm_supportedERC20Tokens",[]),e==g||e==E)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 RangeError("unsupported entrypoint.")}catch(e){const t=L(e);throw new G("PAYMASTER_ERROR","fetchSupportedERC20TokensAndPaymasterMetadata failed",{cause:t})}}}class Ue extends Ge{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 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?g:E);let u=e.preVerificationGas,f=e.verificationGasLimit,h=e.callGasLimit;e.preVerificationGas=0n;const A=new te(a),p=await A.estimateUserOperationGas(e,d,s.state_override_set);return u<p.preVerificationGas&&(u=p.preVerificationGas),f<p.verificationGasLimit&&(f=p.verificationGasLimit),h<p.callGasLimit&&(h=p.callGasLimit),e.preVerificationGas=u,e.verificationGasLimit=f,e.callGasLimit=h,e}}function Ce(e,t,n){return a(c(["address","uint256","uint256"],[e,t,n]))}var Ie={__proto__:null,SmartAccount:p,Simple7702Account:ne,SocialRecoveryModule:we,get SocialRecoveryModuleGracePeriodSelector(){return _e},EXECUTE_RECOVERY_PRIMARY_TYPE:ve,EIP712_RECOVERY_MODULE_TYPE:Te,AllowanceModule:xe,SafeAccountV0_2_0:Re,SafeAccountV0_3_0:Fe,SafeAccountV1_5_0_M_0_3_0:Pe,SendUseroperationResponse:ae,SmartAccountFactory:me,SafeAccountFactory:ye,Bundler:te,CandidePaymaster:Le,WorldIdPermissionlessPaymaster:Ue,createWorldIdSignal:Ce,createUserOperationHash:U,createCallData:C,getFunctionSelector:O,fetchAccountNonce:M,calculateUserOperationMaxGasCost:B,sendJsonRpcRequest:I,fetchGasPrice:V,getDepositInfo:W,getBalanceOf:N,shareTenderlySimulationAndCreateLink:re,simulateUserOperationWithTenderlyAndCreateShareLink:ie,simulateUserOperationWithTenderly:se,simulateUserOperationCallDataWithTenderly:le,simulateSenderCallDataWithTenderlyAndCreateShareLink:ce,simulateUserOperationCallDataWithTenderlyAndCreateShareLink:oe,simulateSenderCallDataWithTenderly:de,callTenderlySimulateBundle:ue,createAndSignLegacyRawTransaction:j,createAndSignEip7702RawTransaction:q,createEip7702TransactionHash:$,createAndSignEip7702DelegationAuthorization:J,createEip7702DelegationAuthorizationHash:X,signHash:K,get SafeModuleExecutorFunctionSelector(){return fe},EOADummySignerSignaturePair:he,WebauthnDummySignerSignaturePair:Ae,get Operation(){return x},get GasOption(){return F},get PolygonChain(){return R},ZeroAddress:y,BaseUserOperationDummyValues:_,EIP712_SAFE_OPERATION_V7_TYPE:v,EIP712_SAFE_OPERATION_V6_TYPE:w,DEFAULT_SECP256R1_PRECOMPILE_ADDRESS:T,AbstractionKitError:G,SAFE_MESSAGE_PRIMARY_TYPE:ge,SAFE_MESSAGE_MODULE_TYPE:Ee,getSafeMessageEip712Data:De};export{G as AbstractionKitError,xe as AllowanceModule,_ as BaseUserOperationDummyValues,te as Bundler,Le as CandidePaymaster,T as DEFAULT_SECP256R1_PRECOMPILE_ADDRESS,Te as EIP712_RECOVERY_MODULE_TYPE,w as EIP712_SAFE_OPERATION_V6_TYPE,v as EIP712_SAFE_OPERATION_V7_TYPE,he as EOADummySignerSignaturePair,ve as EXECUTE_RECOVERY_PRIMARY_TYPE,F as GasOption,x as Operation,R as PolygonChain,Ee as SAFE_MESSAGE_MODULE_TYPE,ge as SAFE_MESSAGE_PRIMARY_TYPE,ye as SafeAccountFactory,Re as SafeAccountV0_2_0,Fe as SafeAccountV0_3_0,Pe as SafeAccountV1_5_0_M_0_3_0,fe as SafeModuleExecutorFunctionSelector,ae as SendUseroperationResponse,ne as Simple7702Account,p as SmartAccount,me as SmartAccountFactory,we as SocialRecoveryModule,_e as SocialRecoveryModuleGracePeriodSelector,Ae as WebauthnDummySignerSignaturePair,Ue as WorldIdPermissionlessPaymaster,y as ZeroAddress,Ie as abstractionkit,B as calculateUserOperationMaxGasCost,ue as callTenderlySimulateBundle,J as createAndSignEip7702DelegationAuthorization,q as createAndSignEip7702RawTransaction,j as createAndSignLegacyRawTransaction,C as createCallData,X as createEip7702DelegationAuthorizationHash,$ as createEip7702TransactionHash,U as createUserOperationHash,Ce as createWorldIdSignal,M as fetchAccountNonce,V as fetchGasPrice,N as getBalanceOf,W as getDepositInfo,O as getFunctionSelector,De as getSafeMessageEip712Data,I as sendJsonRpcRequest,re as shareTenderlySimulationAndCreateLink,K as signHash,de as simulateSenderCallDataWithTenderly,ce as simulateSenderCallDataWithTenderlyAndCreateShareLink,le as simulateUserOperationCallDataWithTenderly,oe as simulateUserOperationCallDataWithTenderlyAndCreateShareLink,se as simulateUserOperationWithTenderly,ie as simulateUserOperationWithTenderlyAndCreateShareLink};
|
|
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 h,ethers as A}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",S="0x0000000071727De22E5E9d8BAf0edAc6f37da032",D="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"},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"}]},v={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"}]},F={MerkleTreeRoot:[{type:"bytes32",name:"merkleTreeRoot"}]},x="0x0000000000000000000000000000000000000100";var U,R,L;!function(e){e[e.Call=0]="Call",e[e.Delegate=1]="Delegate"}(U||(U={})),function(e){e[e.Slow=1]="Slow",e[e.Medium=1.2]="Medium",e[e.Fast=1.5]="Fast"}(R||(R={})),function(e){e.Mainnet="v2",e.ZkMainnet="zkevm",e.Amoy="amoy",e.Cardona="cardona"}(L||(L={}));const P={"-32602":"INVALID_FIELDS","-32500":"SIMULATE_VALIDATION","-32501":"SIMULATE_PAYMASTER_VALIDATION","-32502":"OPCODE_VALIDATION","-32503":"EXPIRE_SHORTLY","-32504":"REPUTATION","-32505":"INSUFFICIENT_STAKE","-32506":"UNSUPPORTED_SIGNATURE_AGGREGATOR","-32507":"INVALID_SIGNATURE","-32601":"INVALID_USEROPERATION_HASH","-32521":"EXECUTION_REVERTED"};class C 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 O(e,n){const r=t.defaultAbiCoder().encode(["(bytes32,bytes32,bytes32,uint256,address)"],[["0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f","0x364da28a5c92bcc87fe97c8813a6c6b8a3a049b0ea0a328fcb0b4f0e00337586","0xc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6",e,n]]);return a(r)}function I(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()==E.toLowerCase()){i=a(function(e){return V(e,!1)}(e));const t=O(r,E);o=a("0x1901"+t.slice(2)+i.slice(2))}else{i=a(function(e){return V(e,!0)}(e));const t=O(r,g);o=a("0x1901"+t.slice(2)+i.slice(2))}return o}function M(e){const t="22e325a297439656",n=e.split(t);return a(n.length>1?i(["bytes","bytes"],[n[0],"0x"+t]):e)}function V(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?M(l):a(l)];return r.encode(["bytes32","address","uint256","bytes32","bytes32","bytes32","uint256","bytes32","bytes32"],c)}function B(e,a,n){return e+t.defaultAbiCoder().encode(a,n).slice(2)}async function N(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 C(a in P?P[a]:"UNKNOWN_ERROR",e.message,{errno:e.code,context:{url:t,requestOptions:JSON.stringify(o)}})}}function W(e){return n(e).slice(0,10)}async function k(e,t,a,n=0){const r=[{from:"0x0000000000000000000000000000000000000000",to:t,data:B(W("getNonce(address,uint192)"),["address","uint192"],[a,n])},"latest"];try{const t=await N(e,"eth_call",r);if("string"!=typeof t)throw new C("BAD_DATA","getNonce returned ill formed data",{context:JSON.stringify(t)});try{return BigInt(t)}catch(e){const t=G(e);throw new C("BAD_DATA","getNonce returned ill formed data",{cause:t})}}catch(e){const t=G(e);throw new C("BAD_DATA","getNonce failed",{cause:t})}}async function H(e,t=R.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 C("BAD_DATA","fetching gas prices from node failed.",{cause:t})}}function z(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 Y(e,t,a){return(await j(e,t,a)).deposit}async function j(e,a,n){const r={from:"0x0000000000000000000000000000000000000000",to:n,data:B("0x5287ce12",["address"],[a])};try{const a=await J(e,r,"latest"),n=t.defaultAbiCoder().decode(["uint256","bool","uint112","uint32","uint48"],a);if(5!==n.length)throw new C("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 C("BAD_DATA","getDepositInfo returned ill formed data",{cause:t})}}catch(e){const t=G(e);throw new C("BAD_DATA","getDepositInfo failed",{cause:t})}}async function J(e,t,a,n){let r=[];r=null==n?[t,a]:[t,a,n];try{const t=await N(e,"eth_call",r);if("string"!=typeof t)throw new C("BAD_DATA","eth_call returned ill formed data",{context:JSON.stringify(t)});try{return t}catch(e){const t=G(e);throw new C("BAD_DATA","eth_call returned ill formed data",{cause:t})}}catch(e){const t=G(e);throw new C("BAD_DATA","eth_call failed",{cause:t})}}async function K(e,t,a){const n=[t,a];try{const t=await N(e,"eth_getCode",n);if("string"!=typeof t)throw new C("BAD_DATA","eth_getCode returned ill formed data",{context:JSON.stringify(t)});try{return t}catch(e){const t=G(e);throw new C("BAD_DATA","eth_getCode returned ill formed data",{cause:t})}}catch(e){const t=G(e);throw new C("BAD_DATA","eth_getCode failed",{cause:t})}}async function X(e,t,a=R.Medium){let n,r;if(null!=t)[n,r]=await async function(e,t=R.Medium){const a="https://gasstation.polygon.technology/"+e;try{const e=await fetch(a),n=await e.json();let r;r=t==R.Slow?n.safeLow:t==R.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 C("BAD_DATA","fetching gas prices from "+a+" failed.",{cause:t})}}(t,a);else{if(null==e)throw new C("BAD_DATA","providerRpc cant't be null if maxFeePerGas and maxPriorityFeePerGas are not overriden");[n,r]=await H(e,a)}return[n,r]}const q="0x04";function $(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=[re(t),re(n),re(r),i,re(c),d,re(e),re(0n),re(0n)];const h=a(s(f)),A=new o(u).signingKey.sign(h);return f=[re(t),re(n),re(r),i,re(c),d,re(BigInt(A.yParity+2*Number(e)+35)),l(A.r),l(A.s)],s(f)}function Z(e,t,a,n){const r=ee(Q(e,t,a),n);return{chainId:ie(e),address:t,nonce:ie(a),yParity:ie(BigInt(r.yParity)),r:ie(r.r),s:ie(r.s)}}function Q(e,t,n){const r=[re(e),t,re(n)],i=s(r);return a("0x05"+i.slice(2))}function ee(e,t){const a=new o(t).signingKey.sign(e);return{yParity:a.yParity,r:BigInt(a.r),s:BigInt(a.s)}}function te(e,t,a,n,r,i,o,l,c,d,u){const f=ae(e,t,a,n,r,i,o,l,c,d),h=ne(e,t,a,n,r,i,o,l,c,d),A=ee(f,u),p=h.concat([re(BigInt(A.yParity)),re(A.r),re(A.s)]),m=s(p);return q+m.slice(2)}function ae(e,t,n,r,i,o,l,c,d,u){const f=ne(e,t,n,r,i,o,l,c,d,u);return a(q+s(f).slice(2))}function ne(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=[re(a.chainId),a.address,re(a.nonce),re(BigInt(a.yParity)),re(a.r),re(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[re(e),re(t),re(a),re(n),re(r),i,re(s),o,f,u]}function re(e){return l(c(e))}function ie(e){let t=e.toString(16);return t.length%2?"0x0"+t:"0x"+t}class se{constructor(e){this.rpcUrl=void 0,this.rpcUrl=e}async chainId(){try{const e=await N(this.rpcUrl,"eth_chainId",[]);if("string"==typeof e)return e;throw new C("BAD_DATA","bundler eth_chainId rpc call failed")}catch(e){const t=G(e);throw new C("BUNDLER_ERROR","bundler eth_chainId rpc call failed",{cause:t})}}async supportedEntryPoints(){try{return await N(this.rpcUrl,"eth_supportedEntryPoints",[])}catch(e){const t=G(e);throw new C("BUNDLER_ERROR","bundler eth_supportedEntryPoints rpc call failed",{cause:t})}}async estimateUserOperationGas(e,t,a){try{let n={};n=void 0===a?await N(this.rpcUrl,"eth_estimateUserOperationGas",[e,t]):await N(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 C("BUNDLER_ERROR","bundler eth_estimateUserOperationGas rpc call failed",{cause:t})}}async sendUserOperation(e,t){try{return await N(this.rpcUrl,"eth_sendUserOperation",[e,t])}catch(e){const t=G(e);throw new C("BUNDLER_ERROR","bundler eth_sendUserOperation rpc call failed",{cause:t})}}async getUserOperationReceipt(e){try{const t=await N(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 C("BUNDLER_ERROR","bundler eth_getUserOperationReceipt rpc call failed",{cause:a,context:{useroperationhash:e}})}}async getUserOperationByHash(e){try{const t=await N(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 C("BUNDLER_ERROR","bundler eth_getUserOperationByHash rpc call failed",{cause:a,context:{useroperationhash:e}})}}}class oe{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++}throw new C("TIMEOUT","can't find useroperation",{context:this.userOperationHash})}}class le 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 B(le.executorFunctionSelector,le.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 le.createAccountCallData(e.to,n,r)}static createAccountCallDataBatchTransactions(e){const t=[e.map(e=>[e.to,e.value,e.data])];return B(le.batchExecutorFunctionSelector,le.batchExecutorFunctionInputAbi,t)}async baseCreateUserOperation(e,t,a,n={}){var r,i,s,o,l,c,d,u,f,h;if(e.length<1)throw new RangeError("There should be at least one transaction");let A=null,p=null;if(null==n.nonce){if(null==t)throw new C("BAD_DATA","providerRpc cant't be null if nonce is not overriden");p=k(t,this.entrypointAddress,this.accountAddress)}else A=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,g=w.maxPriorityFeePerGas,E=null;null!=n.maxFeePerGas&&null!=n.maxPriorityFeePerGas||(E=X(t,n.polygonGasStation,n.gasLevel));let S=null,D=null,b=null;var _,T;if(null!=n.eip7702Auth&&(S=n.eip7702Auth.chainId,D=null!=(_=n.eip7702Auth.address)?_:this.delegateeAddress,b=null!=(T=n.eip7702Auth.nonce)?T:null),null!=n.eip7702Auth&&null==b){let e;if(null==t)throw new C("BAD_DATA","providerRpc cant't be null if eoaDelegatorNonce is not overriden");e=N(t,"eth_getTransactionCount",[this.accountAddress,"latest"]),null!=E&&null!=p?await Promise.all([e,p,E]).then(e=>{b=BigInt(e[0]),A=e[1],[y,g]=e[2]}):null!=E?await Promise.all([e,E]).then(e=>{b=BigInt(e[0]),[y,g]=e[1]}):null!=p?await Promise.all([e,p]).then(e=>{b=BigInt(e[0]),A=e[1]}):b=BigInt(await e)}else null!=E&&null!=p?await Promise.all([p,E]).then(e=>{A=e[0],[y,g]=e[1]}):null!=E?[y,g]=await E:null!=p&&(A=await p);if(y=null!=(r=n.maxFeePerGas)?r:y*BigInt(Math.floor(((null!=(i=n.maxFeePerGasPercentageMultiplier)?i:0)+100)/100)),g=null!=(s=n.maxPriorityFeePerGas)?s:g*BigInt(Math.floor(((null!=(o=n.maxPriorityFeePerGasPercentageMultiplier)?o:0)+100)/100)),null==A)throw new RangeError("failed to determine nonce");if(A<0n)throw new RangeError("nonce can't be negative");let v,F="0x";if(F=null==n.callData?1==e.length?le.createAccountCallDataSingleTransaction(e[0]):le.createAccountCallDataBatchTransactions(e):n.callData,null!=n.eip7702Auth){var x,U,R;const e=null!=(x=n.eip7702Auth.yParity)?x:"0x0";if("0x0"!=e&&"0x00"!=e&&"0x1"!=e&&"0x01"!=e)throw new C("BAD_DATA","invalide yParity value for eoaDelegatorSignature. must be '0x0' or '0x1'");const t={chainId:ie(S),address:D,nonce:ie(b),yParity:e,r:null!=(U=n.eip7702Auth.r)?U:"0x4277ba564d2c138823415df0ec8e8f97f30825056d54ec5128a8b29ec2dd81b2",s:null!=(R=n.eip7702Auth.s)?R:"0x1075a1bec7f59848cca899ece93075199cd2aabceb0654b9ae00b881a30044cd"};v=m({},w,{sender:this.accountAddress,nonce:A,callData:F,maxFeePerGas:y,maxPriorityFeePerGas:g,factory:"0x7702",factoryData:null,paymaster:null,paymasterVerificationGasLimit:null,paymasterPostOpGasLimit:null,paymasterData:null,eip7702Auth:t})}else v=m({},w,{sender:this.accountAddress,nonce:A,callData:F,maxFeePerGas:y,maxPriorityFeePerGas:g,factory:null,factoryData:null,paymaster:null,paymasterVerificationGasLimit:null,paymasterPostOpGasLimit:null,paymasterData:null,eip7702Auth:null});let L=w.preVerificationGas,P=w.verificationGasLimit,G=w.callGasLimit;if(null==n.preVerificationGas||null==n.verificationGasLimit||null==n.callGasLimit){if(null==a)throw new C("BAD_DATA","bundlerRpc cant't be null if preVerificationGas,verificationGasLimit and callGasLimit are not overriden");{var O;v.callGasLimit=0n,v.verificationGasLimit=0n,v.preVerificationGas=0n;const e=v.maxFeePerGas,t=v.maxPriorityFeePerGas;let r;v.maxFeePerGas=0n,v.maxPriorityFeePerGas=0n,r=m({},v),v.signature=null!=(O=n.dummySignature)?O:le.dummySignature,[L,P,G]=await this.baseEstimateUserOperationGas(r,a,{stateOverrideSet:n.state_override_set}),P+=55000n,v.maxFeePerGas=e,v.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 v.preVerificationGas=null!=(l=n.preVerificationGas)?l:L*BigInt(Math.floor(((null!=(c=n.preVerificationGasPercentageMultiplier)?c:0)+100)/100)),v.verificationGasLimit=null!=(d=n.verificationGasLimit)?d:P*BigInt(Math.floor(((null!=(u=n.verificationGasLimitPercentageMultiplier)?u:0)+100)/100)),v.callGasLimit=null!=(f=n.callGasLimit)?f:G*BigInt(Math.floor(((null!=(h=n.callGasLimitPercentageMultiplier)?h:0)+100)/100)),v}async baseEstimateUserOperationGas(e,t,a={}){var n;e.signature=null!=(n=a.dummySignature)?n:le.dummySignature;const r=new se(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=I(e,this.entrypointAddress,a);return new o(t).signingKey.sign(n).serialized}async baseSendUserOperation(e,t){const a=new se(t),n=await a.sendUserOperation(e,this.entrypointAddress);return new oe(n,a,this.entrypointAddress)}prependTokenPaymasterApproveToCallData(e,t,a,n){return le.prependTokenPaymasterApproveToCallDataStatic(e,t,a,n)}static prependTokenPaymasterApproveToCallDataStatic(e,a,n,r){const i={to:a,value:0n,data:B(W("approve(address,uint256)"),["address","uint256"],[n,r])},s=t.defaultAbiCoder();let o;if(e.startsWith(le.batchExecutorFunctionSelector))o=s.decode(le.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(le.executorFunctionSelector))throw new C("BAD_DATA","Invalid calldata, should start with "+le.batchExecutorFunctionSelector+" or "+le.executorFunctionSelector,{context:{callData:e}});{const t=s.decode(le.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),le.createAccountCallDataBatchTransactions(o)}}le.executorFunctionSelector="0xb61d27f6",le.executorFunctionInputAbi=["address","uint256","bytes"],le.batchExecutorFunctionSelector="0x34fcd5be",le.batchExecutorFunctionInputAbi=["(address,uint256,bytes)[]"],le.dummySignature="0xd2614025fc173b86704caf37b2fb447f7618101a0d31f5f304c777024cef38a060a29ee43fcf0c46f9107d4f670b8a85c2c017a1fe9e4af891f24f0be6ba5d671c";class ce extends le{constructor(e,t={}){var a,n;super(e,null!=(a=t.entrypointAddress)?a:E,null!=(n=t.delegateeAddress)?n:"0xe6Cae83BdE06E4c305530e199D7217f42808555B")}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)}}class de extends le{constructor(e,t={}){var a,n;super(e,null!=(a=t.entrypointAddress)?a:g,null!=(n=t.delegateeAddress)?n:"0xa46cc63eBF4Bd77888AA327837d20b23A63a56B5")}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 ue(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 C("BAD_DATA","tenderly share simulation failed.",{context:{tenderlyAccountSlug:t,tenderlyProjectSlug:a,tenderlyAccessKey:n,tenderlySimulationId:r,status:l}})}async function fe(e,t,a,n,r,i,s=null,o){const l=await he(e,t,a,n,r,i,s,o);return await ue(e,t,a,l.simulation.id),{simulation:l,simulationShareLink:"https://dashboard.tenderly.co/shared/simulation/"+l.simulation.id}}async function he(e,a,n,r,i,s,o=null,l){const c=i.toLowerCase();let d=null;const u=t.defaultAbiCoder();if("initCode"in s&&"0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789"==c)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)throw new RangeError("Invalid entrypoint.");d="0x765e827f"+r.slice(2)}return(await ge(e,a,n,[{chainId:r,blockNumber:o,from:"0x1000000000000000000000000000000000000000",to:i,data:d,stateOverrides:l}]))[0]}async function Ae(e,t,a,n,r,i,s=null,o){const l=await pe(e,t,a,n,r,i,s,o),c=l.map(e=>e.simulation.id);c.map(n=>ue(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 C("BAD_DATA","invalid number of simulations retuned",{context:JSON.stringify(l,(e,t)=>"bigint"==typeof t?"0x"+t.toString(16):t)})}async function pe(e,t,a,n,r,i,s=null,o){let l=null,c=null;return"initCode"in i?null!=i.initCode&&i.initCode.length>2&&(l=i.initCode.slice(0,22),c=i.initCode.slice(22)):(l=i.factory,c=i.factoryData),await ye(e,t,a,n,r,i.sender,i.callData,l,c,s,o)}async function me(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);f.map(n=>ue(e,t,a,n));const h=f.map(e=>"https://dashboard.tenderly.co/shared/simulation/"+e);if(1==h.length)return{simulation:u,callDataSimulationShareLink:h[0]};if(2==h.length)return{simulation:u,accountDeploymentSimulationShareLink:h[0],callDataSimulationShareLink:h[1]};throw new C("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 h;if("0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789"==f)h="0x7fc98430eaedbb6070b35b39d798725049088348";else if("0x0000000071727de22e5e9d8baf0edac6f37da032"==f)h="0xefc2c1444ebcc4db75e7613d20c6a62ff67a167c";else{if("0x4337084d9e255ff0702461cf8895ce9e3b5ff108"!=f)throw new RangeError(`Invalid entrypoint: ${r}`);h="0x449ed7c3e6fee6a97311d4b55475df59c44add33"}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:h,to:o,data:l,stateOverrides:d}),u.push({chainId:n,blockNumber:c,from:r,to:i,data:s,stateOverrides:d});const A=await ge(e,t,a,u);for(const e of A)if(""==e.simulation.id)throw new C("TENDERLY_SIMULATION_ERROR","tenderly simulation failed",{context:JSON.stringify(A,(e,t)=>"bigint"==typeof t?"0x"+t.toString(16):t)});return A}async function ge(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&&"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 N(r,"tenderly_simulateBundle",i,s,"simulations")}var Ee;!function(e){e.executeUserOpWithErrorString="0x541d63c8",e.executeUserOp="0x7bb37428"}(Ee||(Ee={}));const Se={signer:"0xfD90FAd33ee8b58f32c00aceEad1358e4AFC23f9",signature:"0x47003599ffa7e9198f321afa774e34a12a959844efd6363b88896e9c24ed33cf4e1be876ef123a3c4467e7d451511434039539699f2baa2f44955fa3d1c1c6d81c",isContractSignature:!1},De={signer:"0xfD90FAd33ee8b58f32c00aceEad1358e4AFC23f9",signature:"0x000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e06c92f0ac5c4ef9e74721c23d80a9fc12f259ca84afb160f0890483539b9e6080d824c0e6c795157ad5d1ee5eff1ceeb3031009a595f9360919b83dd411c5a78d0000000000000000000000000000000000000000000000000000000000000025a24f744b28d73f066bf3203d145765a7bc735e6328168c8b03e476da3ad0d8fe0400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001e226f726967696e223a2268747470733a2f2f736166652e676c6f62616c220000",isContractSignature:!0};function be(e){return"0x"+e.map(e=>function(e){var t;const a=null!=(t=e.operation)?t:U.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 _e{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 B(this.generatorFunctionSelector,this.generatorFunctionInputAbi,e)}}class we extends _e{constructor(e=we.DEFAULT_FACTORY_ADDRESS){super(e,"0x1688f0b9",["address","bytes","uint256"])}}we.DEFAULT_FACTORY_ADDRESS="0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67";const Te="SafeMessage",ve={SafeMessage:[{type:"bytes",name:"message"}]};function Fe(e,t,a){const n={message:d(a)};return{domain:{chainId:Number(t),verifyingContract:e},types:ve,messageValue:n}}class xe 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.30"){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,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:we.DEFAULT_FACTORY_ADDRESS,c=null!=(s=t.singletonInitHash)?s:_.singletonInitHash,d=a(i(["bytes32","uint256"],[a(e),o])),h=u(["bytes1","address","bytes32","bytes32"],["0xff",l,d,c]).slice(-40);return f("0x"+h)}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:U.Call,c=null!=(i=t.safeModuleExecutorFunctionSelector)?i:xe.DEFAULT_EXECUTOR_FUCNTION_SELECTOR;return xe.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:xe.DEFAULT_EXECUTOR_FUCNTION_SELECTOR,i=null!=(n=t.multisendContractAddress)?n:xe.DEFAULT_MULTISEND_CONTRACT_ADDRESS,s=B("0x8d80ff0a",["bytes"],[be(e)]);return xe.createAccountCallData(i,0n,s,U.Delegate,{safeModuleExecutorFunctionSelector:r})}static createAccountCallData(e,t,a,n,r={}){var i;return B(null!=(i=r.safeModuleExecutorFunctionSelector)?i:xe.DEFAULT_EXECUTOR_FUCNTION_SELECTOR,xe.executorFunctionInputAbi,[e,t,a,n])}static decodeAccountCallData(e){let a=null;if(e.startsWith(Ee.executeUserOpWithErrorString)?a=Ee.executeUserOpWithErrorString:e.startsWith(Ee.executeUserOp)&&(a=Ee.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 C("BAD_DATA","Invalid calldata, should start with "+Ee.executeUserOpWithErrorString+" or "+Ee.executeUserOp,{context:{callData:e}})}static prependTokenPaymasterApproveToCallDataStatic(e,a,n,r,i={}){var s;const o=null!=(s=i.multisendContractAddress)?s:xe.DEFAULT_MULTISEND_CONTRACT_ADDRESS,[l,c]=xe.decodeAccountCallData(e),d=be([{to:a,value:0n,data:B(W("approve(address,uint256)"),["address","uint256"],[n,r]),operation:U.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=be([l])+d.slice(2);const h=B(f,["bytes"],[u]);return xe.createAccountCallData(o,0n,h,U.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]})}),xe.formatSignaturesToUseroperationSignature(n,a)}static getUserOperationEip712Hash(e,t,a={}){return"initCode"in e?xe.getUserOperationEip712Hash_V6(e,t,a):a.entrypointAddress&&a.entrypointAddress.toLowerCase()===g.toLowerCase()?xe.getUserOperationEip712Hash_V9(e,t,a):xe.getUserOperationEip712Hash_V7(e,t,a)}static getUserOperationEip712Data(e,t,a){if("initCode"in e){const n=xe.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()?xe.getUserOperationEip712Data_V9(e,t,a):xe.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:T,messageValue:u}}static getUserOperationEip712Hash_V6(e,t,a={}){const n=xe.getUserOperationEip712Data_V6(e,t,a);return h.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 h="0x";if(null!=e.paymaster&&(h=e.paymaster,null!=e.paymasterVerificationGasLimit&&(h+=u.encode(["uint128"],[e.paymasterVerificationGasLimit]).slice(34)),null!=e.paymasterPostOpGasLimit&&(h+=u.encode(["uint128"],[e.paymasterPostOpGasLimit]).slice(34)),null!=e.paymasterData)){const t="22e325a297439656";r.is_v9&&e.paymasterData.endsWith(t)?h+=t:h+=e.paymasterData.slice(2)}const A={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:h,validAfter:l,validUntil:c,entryPoint:n};return{domain:{chainId:Number(a),verifyingContract:d},types:v,messageValue:A}}static getUserOperationEip712Data_V7(e,t,a={}){var n;return xe.baseGetUserOperationEip712DataV7V8V9(e,t,null!=(n=a.entrypointAddress)?n:S,a)}static getUserOperationEip712Hash_V7(e,t,a={}){const n=xe.getUserOperationEip712Data_V7(e,t,a);return h.hash(n.domain,n.types,n.messageValue)}static getUserOperationEip712Data_V9(e,t,a={}){var n,r;const i=null!=(n=a.safe4337ModuleAddress)?n:"0xf998536d89f3e483087da37eabb016faa694b641";return xe.baseGetUserOperationEip712DataV7V8V9(e,t,null!=(r=a.entrypointAddress)?r:g,m({},a,{safe4337ModuleAddress:i,is_v9:!0}))}static getUserOperationEip712Hash_V9(e,t,a={}){const n=xe.getUserOperationEip712Data_V9(e,t,a);return h.hash(n.domain,n.types,n.messageValue)}static formatEip712SingleSignatureToUseroperationSignature(e,t={}){return xe.formatSignaturesToUseroperationSignature([{signer:"0x0000000000000000000000000000000000000000",signature:e}],t)}async sendUserOperation(e,t){const a=new se(t),n=await a.sendUserOperation(e,this.entrypointAddress);return new oe(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=xe.createBaseInitializerCallData(e,null!=(r=t.threshold)?r:1,a,n,null!=(i=t.multisendContractAddress)?i:xe.DEFAULT_MULTISEND_CONTRACT_ADDRESS,null!=(s=t.webAuthnSharedSigner)?s:xe.DEFAULT_WEB_AUTHN_SHARED_SIGNER,null!=(o=t.eip7212WebAuthnPrecompileVerifierForSharedSigner)?o:xe.DEFAULT_WEB_AUTHN_PRECOMPILE,null!=(l=t.eip7212WebAuthnContractVerifierForSharedSigner)?l:xe.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER);let h;h=null!=t.safeAccountFactoryAddress?new we(t.safeAccountFactoryAddress):new we;const A=null!=(c=t.safeAccountSingleton)?c:_,p=this.createProxyAddress(f,{c2Nonce:null!=(d=t.c2Nonce)?d:0n,safeFactoryAddress:h.address,singletonInitHash:A.singletonInitHash}),m=[A.singletonAddress,f,null!=(u=t.c2Nonce)?u:0n],y=h.getFactoryGeneratorFunctionCallData(m);return[p,h.address,y]}static createBaseInitializerCallData(e,t,a,n,r=xe.DEFAULT_MULTISEND_CONTRACT_ADDRESS,i=xe.DEFAULT_WEB_AUTHN_SHARED_SIGNER,s=xe.DEFAULT_WEB_AUTHN_PRECOMPILE,o=xe.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=B("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:U.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=B("0x0dd9692f",["uint256","uint256","uint176"],[t.x,t.y,"0x"+s.slice(-4)+o.slice(2)]);d.push({to:i,value:0n,data:e,operation:U.Delegate}),u.push(i),f++}else u.push(t);c=[u,t,r,B("0x8d80ff0a",["bytes"],[be(d)]),a,y,0,y]}else c=[u,t,n,l,a,y,0,y];return B(xe.initializerFunctionSelector,xe.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,h=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(h<0n)throw new RangeError("c2Nonce can't be negative");const A=xe.createBaseInitializerCallData(e,null!=(s=t.threshold)?s:1,a,n,null!=(o=t.multisendContractAddress)?o:xe.DEFAULT_MULTISEND_CONTRACT_ADDRESS,null!=(l=t.webAuthnSharedSigner)?l:xe.DEFAULT_WEB_AUTHN_SHARED_SIGNER,null!=(c=t.eip7212WebAuthnPrecompileVerifierForSharedSigner)?c:xe.DEFAULT_WEB_AUTHN_PRECOMPILE,null!=(d=t.eip7212WebAuthnContractVerifierForSharedSigner)?d:xe.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER);let p;p=null!=t.safeAccountFactoryAddress?new we(t.safeAccountFactoryAddress):new we;const m=null!=(u=t.safeAccountSingleton)?u:_,y=p.getFactoryGeneratorFunctionCallData([m.singletonAddress,A,h]);return[p.address,y]}prependTokenPaymasterApproveToCallData(e,t,a,n,r={}){var i;const s=null!=(i=r.multisendContractAddress)?i:xe.DEFAULT_MULTISEND_CONTRACT_ADDRESS;return xe.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=xe.formatSignaturesToUseroperationSignature(a.dummySignerSignaturePairs,{validAfter:n,validUntil:r,isCrossChainSignature:a.isCrossChainSignature})}else if(null!=a.expectedSigners){let t;t="initCode"in e?e.initCode:e.factory;const i=xe.createDummySignerSignaturePairForExpectedSigners(a.expectedSigners,{isInit:null!=t&&"0x"!=t,webAuthnSharedSigner:a.webAuthnSharedSigner,eip7212WebAuthnPrecompileVerifier:a.eip7212WebAuthnPrecompileVerifier,eip7212WebAuthnContractVerifier:a.eip7212WebAuthnContractVerifier,webAuthnSignerFactory:a.webAuthnSignerFactory,webAuthnSignerSingleton:a.webAuthnSignerSingleton,validAfter:n,validUntil:r});e.signature=xe.formatSignaturesToUseroperationSignature(i,{validAfter:n,validUntil:r,isCrossChainSignature:a.isCrossChainSignature})}else e.signature.length<3&&(e.signature=xe.formatSignaturesToUseroperationSignature([Se],{validAfter:n,validUntil:r,isCrossChainSignature:a.isCrossChainSignature}));const i=new se(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,h,A,p,y,g,E,S,D,b;if(e.length<1)throw new RangeError("There should be at least one transaction");const _=null!=(i=r.webAuthnSharedSigner)?i:xe.DEFAULT_WEB_AUTHN_SHARED_SIGNER,T=null!=(s=r.safeModuleExecutorFunctionSelector)?s:xe.DEFAULT_EXECUTOR_FUCNTION_SELECTOR,v=null!=(o=r.multisendContractAddress)?o:xe.DEFAULT_MULTISEND_CONTRACT_ADDRESS;let F=null,x=null;if(null==r.nonce){if(null==a)throw new C("BAD_DATA","providerRpc cant't be null if nonce is not overriden");x=k(a,this.entrypointAddress,this.accountAddress)}else F=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 U=w.maxFeePerGas,R=w.maxPriorityFeePerGas,L=null;null!=r.maxFeePerGas&&null!=r.maxPriorityFeePerGas||(L=X(a,r.polygonGasStation,r.gasLevel)),null!=L&&null!=x?await Promise.all([x,L]).then(e=>{F=e[0],[U,R]=e[1]}):null!=L?[U,R]=await L:null!=x&&(F=await x),U=null!=(l=r.maxFeePerGas)?l:U*BigInt(Math.floor(((null!=(c=r.maxFeePerGasPercentageMultiplier)?c:0)+100)/100)),R=null!=(d=r.maxPriorityFeePerGas)?d:R*BigInt(Math.floor(((null!=(u=r.maxPriorityFeePerGasPercentageMultiplier)?u:0)+100)/100));const P=null!=(f=r.eip7212WebAuthnPrecompileVerifier)?f:xe.DEFAULT_WEB_AUTHN_PRECOMPILE,G=null!=(h=r.eip7212WebAuthnContractVerifier)?h:xe.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER,O=null!=(A=r.webAuthnSignerFactory)?A:xe.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,I=null!=(p=r.webAuthnSignerSingleton)?p:xe.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON;let M=this.factoryAddress,V=this.factoryData;if(null==F)throw new RangeError("failed to determine nonce");if(F<0n)throw new RangeError("nonce can't be negative");if(F>0n)M=null,V=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=xe.createDeployWebAuthnVerifierMetaTransaction(this.x,this.y,{eip7212WebAuthnPrecompileVerifier:P,eip7212WebAuthnContractVerifier:G,webAuthnSignerFactory:O}),a=B("0xe318b52b",["address","address","address"],["0x0000000000000000000000000000000000000001",_,xe.createWebAuthnSignerVerifierAddress(this.x,this.y,{eip7212WebAuthnPrecompileVerifier:P,eip7212WebAuthnContractVerifier:G,webAuthnSignerFactory:O,webAuthnSignerSingleton:I})]);e=[t,{to:this.accountAddress,value:0n,data:a}].concat(e)}let N="0x";N=null==r.callData?1==e.length?xe.createAccountCallDataSingleTransaction(e[0],{safeModuleExecutorFunctionSelector:T}):xe.createAccountCallDataBatchTransactions(e,{safeModuleExecutorFunctionSelector:T,multisendContractAddress:v}):r.callData,null!=this.onChainIdentifier&&(N+=this.onChainIdentifier);const W=m({},w,{sender:this.accountAddress,nonce:F,callData:N,maxFeePerGas:U,maxPriorityFeePerGas:R});let H=w.preVerificationGas,z=w.verificationGasLimit,Y=w.callGasLimit;if(null==r.preVerificationGas||null==r.verificationGasLimit||null==r.callGasLimit){if(null==n)throw new C("BAD_DATA","bundlerRpc cant't be null if preVerificationGas,verificationGasLimit and callGasLimit are not overriden");{W.callGasLimit=0n,W.verificationGasLimit=0n,W.preVerificationGas=0n;const e=W.maxFeePerGas,a=W.maxPriorityFeePerGas;let i;if(W.maxFeePerGas=0n,W.maxPriorityFeePerGas=0n,t){let e="0x";null!=M&&(e=M,null!=V&&(e+=V.slice(2))),i=m({},W,{initCode:e,paymasterAndData:"0x"})}else{var j,J,K,q;i=m({},W,{factory:M,factoryData:V,paymaster:null!=(j=r.paymaster)?j:null,paymasterVerificationGasLimit:null!=(J=r.paymasterVerificationGasLimit)?J:null,paymasterPostOpGasLimit:null!=(K=r.paymasterPostOpGasLimit)?K:null,paymasterData:null!=(q=r.paymasterData)?q:null})}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?[Se]:xe.createDummySignerSignaturePairForExpectedSigners(r.expectedSigners,{isInit:null!=M&&"0x"!=M,webAuthnSharedSigner:_,eip7212WebAuthnPrecompileVerifier:P,eip7212WebAuthnContractVerifier:G,webAuthnSignerFactory:O,webAuthnSignerSingleton:I,validAfter:s,validUntil:o});W.signature=xe.formatSignaturesToUseroperationSignature(l,{validAfter:s,validUntil:o,webAuthnSharedSigner:_,isCrossChainSignature:r.isCrossChainSignature}),[H,z,Y]=await this.baseEstimateUserOperationGas(i,n,{stateOverrideSet:r.state_override_set,isCrossChainSignature:r.isCrossChainSignature}),z+=55000n*BigInt(l.length),W.maxFeePerGas=e,W.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 W.preVerificationGas=null!=(y=r.preVerificationGas)?y:H*BigInt(Math.floor(((null!=(g=r.preVerificationGasPercentageMultiplier)?g:0)+100)/100)),W.verificationGasLimit=null!=(E=r.verificationGasLimit)?E:z*BigInt(Math.floor(((null!=(S=r.verificationGasLimitPercentageMultiplier)?S:0)+100)/100)),W.callGasLimit=null!=(D=r.callGasLimit)?D:Y*BigInt(Math.floor(((null!=(b=r.callGasLimitPercentageMultiplier)?b:0)+100)/100)),[W,M,V]}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=xe.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 xe.formatSignaturesToUseroperationSignature(f,{validAfter:c,validUntil:d,isCrossChainSignature:i.isCrossChainSignature})}static createWebAuthnSignerVerifierAddress(e,t,n={}){var r,s,o,l;const c=null!=(r=n.eip7212WebAuthnPrecompileVerifier)?r:xe.DEFAULT_WEB_AUTHN_PRECOMPILE,d=null!=(s=n.eip7212WebAuthnContractVerifier)?s:xe.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER,f=null!=(o=n.webAuthnSignerFactory)?o:xe.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,h=null!=(l=n.webAuthnSignerSingleton)?l:xe.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=a(i(["bytes","uint256","uint256","uint256","uint256"],[xe.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE,h,e,t,"0x"+c.slice(-4)+d.slice(2)]));return"0x"+u(["bytes1","address","bytes32","bytes32"],["0xff",f,"0x0000000000000000000000000000000000000000000000000000000000000000",A]).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.isCrossChainSignature){if(null!=t.crossChainMerkleProof){const e=t.crossChainMerkleProof.slice(2).length;if(e<128||e%64!=0)throw new RangeError("invalid crossChainMerkleProof 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.crossChainMerkleProof+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;const s=null!=(a=t.eip7212WebAuthnPrecompileVerifier)?a:xe.DEFAULT_WEB_AUTHN_PRECOMPILE,o=null!=(n=t.eip7212WebAuthnContractVerifier)?n:xe.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER,l=null!=(r=t.webAuthnSignerFactory)?r:xe.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,c=null!=(i=t.webAuthnSignerSingleton)?i:xe.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON;return xe.createWebAuthnSignerVerifierAddress(e.x,e.y,{eip7212WebAuthnPrecompileVerifier:s,eip7212WebAuthnContractVerifier:o,webAuthnSignerFactory:l,webAuthnSignerSingleton:c}).toLowerCase()}}static sortSignatures(e,t={}){e.sort((e,a)=>xe.getSignerLowerCaseAddress(e.signer,t).localeCompare(xe.getSignerLowerCaseAddress(a.signer,t)))}static buildSignaturesFromSingerSignaturePairs(e,t={}){xe.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:xe.DEFAULT_WEB_AUTHN_SHARED_SIGNER}else{var l,c,d,u;const e=null!=(l=t.eip7212WebAuthnPrecompileVerifier)?l:xe.DEFAULT_WEB_AUTHN_PRECOMPILE,a=null!=(c=t.eip7212WebAuthnContractVerifier)?c:xe.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER,n=null!=(d=t.webAuthnSignerFactory)?d:xe.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,i=null!=(u=t.webAuthnSignerSingleton)?u:xe.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON;r=xe.createWebAuthnSignerVerifierAddress(r.x,r.y,{eip7212WebAuthnPrecompileVerifier:e,eip7212WebAuthnContractVerifier:a,webAuthnSignerFactory:n,webAuthnSignerSingleton:i})}}return{segments:[...e,A.solidityPacked(["uint256","uint256","uint8"],[r,a+n,0])],offset:n+32+A.dataLength(i)}}return{segments:[...e,A.solidityPacked(["bytes"],[i])],offset:n}},{segments:[],offset:0});return A.concat([...n,...e.map(({signer:e,signature:t,isContractSignature:a})=>(a=a||"string"!=typeof e)?A.solidityPacked(["uint256","bytes"],[A.dataLength(t),t]):"0x")])}static createWebAuthnSignature(e){return A.AbiCoder.defaultAbiCoder().encode(["bytes","bytes","uint256[2]"],[new Uint8Array(e.authenticatorData),e.clientDataFields,e.rs])}async createSwapOwnerMetaTransactions(e,t,a,n={}){let r,i,s=null;"string"!=typeof t?(r=xe.createWebAuthnSignerVerifierAddress(t.x,t.y,{eip7212WebAuthnPrecompileVerifier:n.eip7212WebAuthnPrecompileVerifier,eip7212WebAuthnContractVerifier:n.eip7212WebAuthnContractVerifier,webAuthnSignerFactory:n.webAuthnSignerFactory,webAuthnSignerSingleton:n.webAuthnSignerSingleton}),(await K(e,r,"latest")).length<3&&(s=xe.createDeployWebAuthnVerifierMetaTransaction(t.x,t.y,{eip7212WebAuthnPrecompileVerifier:n.eip7212WebAuthnPrecompileVerifier,eip7212WebAuthnContractVerifier:n.eip7212WebAuthnContractVerifier,webAuthnSignerFactory:n.webAuthnSignerFactory}))):r=t,i="string"!=typeof a?xe.createWebAuthnSignerVerifierAddress(a.x,a.y,{eip7212WebAuthnPrecompileVerifier:n.eip7212WebAuthnPrecompileVerifier,eip7212WebAuthnContractVerifier:n.eip7212WebAuthnContractVerifier,webAuthnSignerFactory:n.webAuthnSignerFactory,webAuthnSignerSingleton:n.webAuthnSignerSingleton}):a;let o=n.prevOwner;if(null==o){const t=await this.getOwners(e),a=t.indexOf(i);if(-1==a)throw new RangeError("oldOwner is not a current owner.");o=0==a?"0x0000000000000000000000000000000000000001":t[a-1]}const l=this.createStandardSwapOwnerMetaTransaction(r,i,o);return null==s?[l]:[s,l]}async createRemoveOwnerMetaTransaction(e,t,a,n={}){let r;r="string"!=typeof t?xe.createWebAuthnSignerVerifierAddress(t.x,t.y,{eip7212WebAuthnPrecompileVerifier:n.eip7212WebAuthnPrecompileVerifier,eip7212WebAuthnContractVerifier:n.eip7212WebAuthnContractVerifier,webAuthnSignerFactory:n.webAuthnSignerFactory,webAuthnSignerSingleton:n.webAuthnSignerSingleton}):t;let i=n.prevOwner;if(null==i){const t=await this.getOwners(e),a=t.indexOf(r);if(-1==a)throw new RangeError("ownerToDelete is not a current owner.");i=0==a?"0x0000000000000000000000000000000000000001":t[a-1]}return this.createStandardRemoveOwnerMetaTransaction(r,a,i)}async createAddOwnerWithThresholdMetaTransactions(e,t,a={}){let n,r=null;if("string"!=typeof e){if(n=xe.createWebAuthnSignerVerifierAddress(e.x,e.y,{eip7212WebAuthnPrecompileVerifier:a.eip7212WebAuthnPrecompileVerifier,eip7212WebAuthnContractVerifier:a.eip7212WebAuthnContractVerifier,webAuthnSignerFactory:a.webAuthnSignerFactory,webAuthnSignerSingleton:a.webAuthnSignerSingleton}),null==a.nodeRpcUrl)throw new RangeError("overrides.nodeRpcUrl can't be null if adding a webauthn owner");(await K(a.nodeRpcUrl,n,"latest")).length<3&&(r=xe.createDeployWebAuthnVerifierMetaTransaction(e.x,e.y,{eip7212WebAuthnPrecompileVerifier:a.eip7212WebAuthnPrecompileVerifier,eip7212WebAuthnContractVerifier:a.eip7212WebAuthnContractVerifier,webAuthnSignerFactory:a.webAuthnSignerFactory}))}else n=e;const i=this.createStandardAddOwnerWithThresholdMetaTransaction(n,t);return null==r?[i]:[r,i]}createStandardAddOwnerWithThresholdMetaTransaction(e,t){const a=B("0x0d582f13",["address","uint256"],[e,t]);return{to:this.accountAddress,data:a,value:0n}}createStandardSwapOwnerMetaTransaction(e,t,a){const n=B("0xe318b52b",["address","address","address"],[a,t,e]);return{to:this.accountAddress,data:n,value:0n}}createStandardRemoveOwnerMetaTransaction(e,t,a){const n=B("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=B("0x694e80c3",["uint256"],[e]);return{to:this.accountAddress,data:t,value:0n}}createApproveHashMetaTransaction(e){const t=B("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:xe.DEFAULT_WEB_AUTHN_PRECOMPILE,o=null!=(r=a.eip7212WebAuthnContractVerifier)?r:xe.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER;return{to:null!=(i=a.webAuthnSignerFactory)?i:xe.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,value:0n,data:B("0x0d2f0489",["uint256","uint256","uint176"],[e,t,"0x"+s.slice(-4)+o.slice(2)])}}async getOwners(e){const a=B(W("getOwners()"),[],[]),n={to:this.accountAddress,data:a},r=await J(e,n,"latest");return t.defaultAbiCoder().decode(["address[]"],r)[0]}async getThreshold(e){const a=B("0xe75235b8",[],[]),n={to:this.accountAddress,data:a},r=await J(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=B("0xcc2f8452",["address","uint256"],[n,r]),s={to:this.accountAddress,data:i},o=await J(e,s,"latest");if("0x"==o)throw new C("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 C("BAD_DATA","getModules failed",{cause:t})}}async isModuleEnabled(e,a){const n=B(W("isModuleEnabled(address)"),["address"],[a]),r={to:this.accountAddress,data:n},i=await J(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=Se;else{if(null==t.isInit)throw new RangeError("Must define isInit parameter when using WebAuthn");if(a=De,t.isInit){var r;const e=null!=(r=t.webAuthnSharedSigner)?r:xe.DEFAULT_WEB_AUTHN_SHARED_SIGNER;a.signer=e}else{var i,s,o,l;const n=null!=(i=t.eip7212WebAuthnPrecompileVerifier)?i:xe.DEFAULT_WEB_AUTHN_PRECOMPILE,r=null!=(s=t.eip7212WebAuthnContractVerifier)?s:xe.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER,c=null!=(o=t.webAuthnSignerFactory)?o:xe.DEFAULT_WEB_AUTHN_SIGNER_FACTORY,d=null!=(l=t.webAuthnSignerSingleton)?l:xe.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON;a.signer=xe.createWebAuthnSignerVerifierAddress(e.x,e.y,{eip7212WebAuthnPrecompileVerifier:n,eip7212WebAuthnContractVerifier:r,webAuthnSignerFactory:c,webAuthnSignerSingleton:d})}}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:xe.DEFAULT_WEB_AUTHN_PRECOMPILE,d=null!=(o=i.eip7212WebAuthnContractVerifier)?o:xe.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER,u=null!=(l=i.webAuthnSignerSingleton)?l:xe.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 f="0x1111111111111111111111111111111111111111",h={to:f,data:B("0x1626ba7e",["bytes32","bytes"],[n,r])},A=xe.createSafeWebAuthnSignerProxyDeployedByteCode(a,c,d,u),p=await J(e,h,"latest",{[f]:{code:A}});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:B("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 xe.createStandardDisableModuleMetaTransaction(t,r,a)}catch(e){const t=G(e);throw new C("BAD_DATA","createDisableModuleMetaTransaction failed",{cause:t})}}static createStandardDisableModuleMetaTransaction(e,t,a){return{to:a,data:B("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?xe.createAccountCallDataSingleTransaction(i[0],{safeModuleExecutorFunctionSelector:o.safeModuleExecutorFunctionSelector}):xe.createAccountCallDataBatchTransactions(i,{safeModuleExecutorFunctionSelector:o.safeModuleExecutorFunctionSelector,multisendContractAddress:o.multisendContractAddress}):o.callData,null==(l=o.createShareLink)||l?await me(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 Fe(this.accountAddress,e,t)}}function Ue(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.forEach(e=>{i+=e.slice(2)}),i});return[o,l]}xe.DEFAULT_WEB_AUTHN_SHARED_SIGNER="0xfD90FAd33ee8b58f32c00aceEad1358e4AFC23f9",xe.DEFAULT_WEB_AUTHN_SIGNER_SINGLETON="0x270D7E4a57E6322f336261f3EaE2BADe72E68d72",xe.DEFAULT_WEB_AUTHN_SIGNER_FACTORY="0xF7488fFbe67327ac9f37D5F722d83Fc900852Fbf",xe.DEFAULT_WEB_AUTHN_FCLP256_VERIFIER="0x445a0683e494ea0c5AF3E83c5159fBE47Cf9e765",xe.DEFAULT_WEB_AUTHN_PRECOMPILE="0x0000000000000000000000000000000000000000",xe.DEFAULT_WEB_AUTHN_SIGNER_PROXY_CREATION_CODE="0x61010060405234801561001157600080fd5b506040516101ee3803806101ee83398101604081905261003091610058565b6001600160a01b0390931660805260a09190915260c0526001600160b01b031660e0526100bc565b6000806000806080858703121561006e57600080fd5b84516001600160a01b038116811461008557600080fd5b60208601516040870151606088015192965090945092506001600160b01b03811681146100b157600080fd5b939692955090935050565b60805160a05160c05160e05160ff6100ef60003960006008015260006031015260006059015260006080015260ff6000f3fe608060408190527f00000000000000000000000000000000000000000000000000000000000000003660b681018290527f000000000000000000000000000000000000000000000000000000000000000060a082018190527f00000000000000000000000000000000000000000000000000000000000000008285018190527f00000000000000000000000000000000000000000000000000000000000000009490939192600082376000806056360183885af490503d6000803e8060c3573d6000fd5b503d6000f3fea2646970667358221220ddd9bb059ba7a6497d560ca97aadf4dbf0476f578378554a50d41c6bb654beae64736f6c63430008180033",xe.DEFAULT_MULTISEND_CONTRACT_ADDRESS="0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526",xe.initializerFunctionSelector="0xb63e800d",xe.initializerFunctionInputAbi=["address[]","uint256","address","bytes","address","address","uint256","address"],xe.DEFAULT_EXECUTOR_FUCNTION_SELECTOR=Ee.executeUserOpWithErrorString,xe.executorFunctionInputAbi=["address","uint256","bytes","uint8"];class Re extends xe{constructor(e,t={}){var a,n;super(e,null!=(a=t.safe4337ModuleAddress)?a:Re.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(n=t.entrypointAddress)?n:Re.DEFAULT_ENTRYPOINT_ADDRESS,{onChainIdentifierParams:t.onChainIdentifierParams,onChainIdentifier:t.onChainIdentifier,safeAccountSingleton:t.safeAccountSingleton})}static createAccountAddress(e,t={}){var a,n;const[r,,]=xe.createAccountAddressAndFactoryAddressAndData(e,t,null!=(a=t.safe4337ModuleAddress)?a:Re.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(n=t.safeModuleSetupAddress)?n:Re.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]=xe.createAccountAddressAndFactoryAddressAndData(e,t,null!=(a=t.safe4337ModuleAddress)?a:Re.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(n=t.safeModuleSetupAddress)?n:Re.DEFAULT_SAFE_MODULE_SETUP_ADDRESS),d=new Re(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:Re.DEFAULT_ENTRYPOINT_ADDRESS,d=null!=(s=a.safe4337ModuleAddress)?s:Re.DEFAULT_SAFE_4337_MODULE_ADDRESS;return xe.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:Re.DEFAULT_ENTRYPOINT_ADDRESS,d=null!=(s=a.safe4337ModuleAddress)?s:Re.DEFAULT_SAFE_4337_MODULE_ADDRESS;return xe.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:Re.DEFAULT_SAFE_4337_MODULE_ADDRESS,s=null!=(r=a.safeModuleSetupAddress)?r:Re.DEFAULT_SAFE_MODULE_SETUP_ADDRESS;return xe.createBaseInitializerCallData(e,t,i,s,a.multisendContractAddress,a.webAuthnSharedSigner,a.eip7212WebAuthnPrecompileVerifierForSharedSigner,a.eip7212WebAuthnContractVerifierForSharedSigner)}static createFactoryAddressAndData(e,t={}){var a,n;return xe.createFactoryAddressAndData(e,t,null!=(a=t.safe4337ModuleAddress)?a:Re.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(n=t.safeModuleSetupAddress)?n:Re.DEFAULT_SAFE_MODULE_SETUP_ADDRESS)}async createUserOperation(e,t,a,n={}){var r,i,s,o;const[l,c,d]=await this.createBaseUserOperationAndFactoryAddressAndFactoryData(e,!1,t,a,m({},n,{isCrossChainSignature:!0}));return m({},l,{factory:c,factoryData:d,paymaster:null!=(r=n.paymaster)?r:null,paymasterVerificationGasLimit:null!=(i=n.paymasterVerificationGasLimit)?i:null,paymasterPostOpGasLimit:null!=(s=n.paymasterPostOpGasLimit)?s:null,paymasterData:null!=(o=n.paymasterData)?o:null,eip7702Auth:null})}signUserOperation(e,t,a,n={}){return xe.baseSignSingleUserOperation(e,t,a,this.entrypointAddress,this.safe4337ModuleAddress,m({},n,{isCrossChainSignature:!0}))}signUserOperations(e,t){if(e.length<1)throw new RangeError("There should be at least one userOperationsToSigns");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=xe.getUserOperationEip712Hash_V9(e.userOperation,e.chainId);a.push(n)});const[n,r]=Ue(a),i=h.hash({verifyingContract:this.safe4337ModuleAddress},F,{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(xe.formatSignaturesToUseroperationSignature(s,{validAfter:e.validAfter,validUntil:e.validUntil,isCrossChainSignature:!0,crossChainMerkleProof:r[t]}))}),l}return[this.signUserOperation(e[0].userOperation,t,e[0].chainId,{validUntil:e[0].validUntil,validAfter:e[0].validAfter})]}static getCrossChainSingleSignatureUserOperationsEip712Hash(e,t={}){const a=Re.getCrossChainSingleSignatureUserOperationsEip712Data(e,t);return h.hash(a.domain,a.types,a.messageValue)}static getCrossChainSingleSignatureUserOperationsEip712Data(e,t={}){var a;const n=null!=(a=t.safe4337ModuleAddress)?a:Re.DEFAULT_SAFE_4337_MODULE_ADDRESS,r=[];e.forEach((e,t)=>{const a=xe.getUserOperationEip712Hash_V9(e.userOperation,e.chainId);r.push(a)});const[i,s]=Ue(r);return{domain:{verifyingContract:n},types:F,messageValue:{merkleTreeRoot:i}}}static formatSignaturesToUseroperationsSignatures(e,t,a={}){const n=[];e.forEach((e,t)=>{const a=xe.getUserOperationEip712Hash_V9(e.userOperation,e.chainId);n.push(a)});const[r,i]=Ue(n),s=[];return e.forEach((e,n)=>{s.push(xe.formatSignaturesToUseroperationSignature(t,{validAfter:a.validAfter,validUntil:a.validUntil,isCrossChainSignature:!0,crossChainMerkleProof:i[n]}))}),s}}Re.DEFAULT_ENTRYPOINT_ADDRESS=g,Re.DEFAULT_SAFE_4337_MODULE_ADDRESS="0xf998536d89f3e483087da37eabb016faa694b641",Re.DEFAULT_SAFE_MODULE_SETUP_ADDRESS="0x2dd68b007B46fBe91B9A7c3EDa5A7a1063cB5b47";class Le{constructor(e){this.moduleAddress=void 0,this.abiCoder=void 0,this.moduleAddress=e,this.abiCoder=t.defaultAbiCoder()}createEnableModuleMetaTransaction(e){return xe.createEnableModuleMetaTransaction(this.moduleAddress,e)}checkForEmptyResultAndRevert(e,t){if("0x"==e)throw new C("BAD_DATA",t+" returned 0x, module contract "+this.moduleAddress+" is probably not deployed")}}var Pe;!function(e){e.After3Minutes="0x949d01d424bE050D09C16025dd007CB59b3A8c66",e.After3Days="0x38275826E1933303E508433dD5f289315Da2541c",e.After7Days="0x088f6cfD8BB1dDb1BB069CCb3fc1A98927D233f2",e.After14Days="0x9BacD92F4687Db306D7ded5d4513a51EA05df25b"}(Pe||(Pe={}));class Ce extends Le{constructor(e=Ce.DEFAULT_SOCIAL_RECOVERY_ADDRESS){super(e)}createConfirmRecoveryMetaTransaction(e,t,a,n){const r=B("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=B("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=B("0xb1f85f69",["address","address[]","uint256"],[e,t,a]);return{to:this.moduleAddress,data:n,value:0n}}createFinalizeRecoveryMetaTransaction(e){const t=B("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=B("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=B("0x936f7d86",["address","address","uint256"],[e,t,a]);return{to:this.moduleAddress,data:n,value:0n}}createChangeThresholdMetaTransaction(e){const t=B("0x694e80c3",["uint256"],[e]);return{to:this.moduleAddress,data:t,value:0n}}async getRecoveryHash(e,t,a,n,r){const i=B("0x5f19df08",["address","address[]","uint256","uint256"],[t,a,n,r]),s={to:this.moduleAddress,data:i},o=await J(e,s,"latest");return this.checkForEmptyResultAndRevert(o,"getRecoveryHash"),this.abiCoder.decode(["bytes32"],o)[0]}async getRecoveryRequest(e,t){const a=B("0x4f9a28b9",["address"],[t]),n={to:this.moduleAddress,data:a},r=await J(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=B("0x6c6595ca",["address","address[]","uint256"],[t,a,n]),i={to:this.moduleAddress,data:r},s=await J(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=B("0x37d82c36",["address","address","address[]","uint256"],[t,a,n,r]),s={to:this.moduleAddress,data:i},o=await J(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=B("0xd4ee9734",["address","address"],[t,a]),r={to:this.moduleAddress,data:n},i=await J(e,r,"latest");this.checkForEmptyResultAndRevert(i,"isGuardian");const s=this.abiCoder.decode(["bool"],i);return Boolean(s[0])}async guardiansCount(e,t){const a=B("0xc026e7ee",["address"],[t]),n={to:this.moduleAddress,data:a},r=await J(e,n,"latest");this.checkForEmptyResultAndRevert(r,"guardiansCount");const i=this.abiCoder.decode(["uint256"],r);return BigInt(i[0])}async threshold(e,t){const a=B("0xc86ec2bf",["address"],[t]),n={to:this.moduleAddress,data:a},r=await J(e,n,"latest");this.checkForEmptyResultAndRevert(r,"threshold");const i=this.abiCoder.decode(["uint256"],r);return BigInt(i[0])}async getGuardians(e,t){const a=B("0xf18858ab",["address"],[t]),n={to:this.moduleAddress,data:a},r=await J(e,n,"latest");return this.checkForEmptyResultAndRevert(r,"threshold"),this.abiCoder.decode(["address[]"],r)[0]}async nonce(e,t){const a=B("0x70ae92d2",["address"],[t]),n={to:this.moduleAddress,data:a},r=await J(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 Ce(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:Oe,messageValue:o}}}Ce.DEFAULT_SOCIAL_RECOVERY_ADDRESS=Pe.After3Days;const Ge="ExecuteRecovery",Oe={ExecuteRecovery:[{type:"address",name:"wallet"},{type:"address[]",name:"newOwners"},{type:"uint256",name:"newThreshold"},{type:"uint256",name:"nonce"}]};class Ie extends Le{constructor(e=Ie.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=B("0xbeaeb388",["address","address","uint96","uint16","uint32"],[e,t,a,n,r]);return{to:this.moduleAddress,data:i,value:0n}}createRenewAllowanceMetaTransaction(e,t){const a=B("0xc19bf50e",["address","address"],[e,t]);return{to:this.moduleAddress,data:a,value:0n}}createDeleteAllowanceMetaTransaction(e,t){const a=B("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=B("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=B("0xe71bdf41",["address"],[e]);return{to:this.moduleAddress,data:t,value:0n}}createRemoveDelegateMetaTransaction(e,t){const a=B("0xdd43a79f",["address","bool"],[e,t]);return{to:this.moduleAddress,data:a,value:0n}}async getTokens(e,t,a){const n=B("0x8d0e8e1d",["address","address"],[t,a]),r={to:this.moduleAddress,data:n},i=await J(e,r,"latest");return this.checkForEmptyResultAndRevert(i,"getTokens"),this.abiCoder.decode(["address[]"],i)[0]}async getTokensAllowance(e,t,a,n){const r=B("0x94b31fbd",["address","address","address"],[t,a,n]),i={to:this.moduleAddress,data:r},s=await J(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=B("0xeb37abe0",["address","uint48","uint8"],[t,a,n]),i={to:this.moduleAddress,data:r},s=await J(e,i,"latest");this.checkForEmptyResultAndRevert(s,"getDelegates");const o=this.abiCoder.decode(["address[]","uint48"],s);return{results:o[0],next:BigInt(o[1])}}}Ie.DEFAULT_ALLOWANCE_MODULE_ADDRESS="0xAA46724893dedD72658219405185Fb0Fc91e091C";class Me extends xe{constructor(e,t={}){var a,n;super(e,null!=(a=t.safe4337ModuleAddress)?a:Me.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(n=t.entrypointAddress)?n:Me.DEFAULT_ENTRYPOINT_ADDRESS,{onChainIdentifierParams:t.onChainIdentifierParams,onChainIdentifier:t.onChainIdentifier,safeAccountSingleton:t.safeAccountSingleton})}static createAccountAddress(e,t={}){var a,n;const[r,,]=xe.createAccountAddressAndFactoryAddressAndData(e,t,null!=(a=t.safe4337ModuleAddress)?a:Me.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(n=t.safeModuleSetupAddress)?n:Me.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]=xe.createAccountAddressAndFactoryAddressAndData(e,t,null!=(a=t.safe4337ModuleAddress)?a:Me.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(n=t.safeModuleSetupAddress)?n:Me.DEFAULT_SAFE_MODULE_SETUP_ADDRESS),d=new Me(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:Me.DEFAULT_ENTRYPOINT_ADDRESS,d=null!=(s=a.safe4337ModuleAddress)?s:Me.DEFAULT_SAFE_4337_MODULE_ADDRESS;return xe.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:Me.DEFAULT_ENTRYPOINT_ADDRESS,d=null!=(s=a.safe4337ModuleAddress)?s:Me.DEFAULT_SAFE_4337_MODULE_ADDRESS;return xe.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:Me.DEFAULT_SAFE_4337_MODULE_ADDRESS,s=null!=(r=a.safeModuleSetupAddress)?r:Me.DEFAULT_SAFE_MODULE_SETUP_ADDRESS;return xe.createBaseInitializerCallData(e,t,i,s,a.multisendContractAddress,a.webAuthnSharedSigner,a.eip7212WebAuthnPrecompileVerifierForSharedSigner,a.eip7212WebAuthnContractVerifierForSharedSigner)}static createFactoryAddressAndData(e,t={}){var a,n;return xe.createFactoryAddressAndData(e,t,null!=(a=t.safe4337ModuleAddress)?a:Me.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(n=t.safeModuleSetupAddress)?n:Me.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 xe.baseSignSingleUserOperation(e,t,a,this.entrypointAddress,this.safe4337ModuleAddress,n)}}Me.DEFAULT_ENTRYPOINT_ADDRESS=S,Me.DEFAULT_SAFE_4337_MODULE_ADDRESS="0x75cf11467937ce3F2f357CE24ffc3DBF8fD5c226",Me.DEFAULT_SAFE_MODULE_SETUP_ADDRESS="0x2dd68b007B46fBe91B9A7c3EDa5A7a1063cB5b47";class Ve extends xe{constructor(e,t={}){var a,n;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})}static createAccountAddress(e,t={}){var a,n;const[r,,]=xe.createAccountAddressAndFactoryAddressAndData(e,t,null!=(a=t.safe4337ModuleAddress)?a:Ve.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(n=t.safeModuleSetupAddress)?n:Ve.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]=Ve.createAccountAddressAndFactoryAddressAndData(e,t,null!=(a=t.safe4337ModuleAddress)?a:Ve.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(n=t.safeModuleSetupAddress)?n:Ve.DEFAULT_SAFE_MODULE_SETUP_ADDRESS),d=new Ve(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:Ve.DEFAULT_ENTRYPOINT_ADDRESS,d=null!=(s=a.safe4337ModuleAddress)?s:Ve.DEFAULT_SAFE_4337_MODULE_ADDRESS;return xe.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 xe.getUserOperationEip712Data(e,t,{validAfter:o,validUntil:l,entrypointAddress:c,safe4337ModuleAddress:d})}static createAccountAddressAndInitCode(e,t={}){var a,n;const[r,i,s]=xe.createAccountAddressAndFactoryAddressAndData(e,t,null!=(a=t.safe4337ModuleAddress)?a:Ve.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(n=t.safeModuleSetupAddress)?n:Ve.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:Ve.DEFAULT_SAFE_4337_MODULE_ADDRESS,s=null!=(r=a.safeModuleSetupAddress)?r:Ve.DEFAULT_SAFE_MODULE_SETUP_ADDRESS;return xe.createBaseInitializerCallData(e,t,i,s,a.multisendContractAddress,a.webAuthnSharedSigner,a.eip7212WebAuthnPrecompileVerifierForSharedSigner,a.eip7212WebAuthnContractVerifierForSharedSigner)}static createInitCode(e,t={}){var a,n;const[r,i]=xe.createFactoryAddressAndData(e,t,null!=(a=t.safe4337ModuleAddress)?a:Ve.DEFAULT_SAFE_4337_MODULE_ADDRESS,null!=(n=t.safeModuleSetupAddress)?n:Ve.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:Ve.DEFAULT_SAFE_4337_MODULE_ADDRESS,i=null!=(n=t.safeV07ModuleAddress)?n:Me.DEFAULT_SAFE_4337_MODULE_ADDRESS,s=await this.createDisableModuleMetaTransaction(e,r,this.accountAddress,{prevModuleAddress:t.safeV06ModuleAddress,modulesPageSize:t.pageSize,modulesStart:t.modulesStart}),o=xe.createEnableModuleMetaTransaction(i,this.accountAddress),l=B("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 xe.baseSignSingleUserOperation(e,t,a,this.entrypointAddress,this.safe4337ModuleAddress,n)}}Ve.DEFAULT_ENTRYPOINT_ADDRESS=D,Ve.DEFAULT_SAFE_4337_MODULE_ADDRESS="0xa581c4A4DB7175302464fF3C06380BC3270b4037",Ve.DEFAULT_SAFE_MODULE_SETUP_ADDRESS="0x8EcD4ec46D4D2a6B64fE960B3D64e8B94B2234eb";class Be extends Me{constructor(e,t={}){super(e,{onChainIdentifierParams:t.onChainIdentifierParams,onChainIdentifier:t.onChainIdentifier,safeAccountSingleton:b})}static createProxyAddress(e,t={}){var a;const n=t;return n.singletonInitHash=null!=(a=t.singletonInitHash)?a:b.singletonInitHash,Me.createProxyAddress(e,n)}static initializeNewAccount(e,t={}){var a;return t.safeAccountSingleton=null!=(a=t.safeAccountSingleton)?a:b,Me.initializeNewAccount(e,t)}static createAccountAddress(e,t={}){var a;const n=t;return n.safeAccountSingleton=null!=(a=t.safeAccountSingleton)?a:b,Me.createAccountAddress(e,n)}static createFactoryAddressAndData(e,t={}){var a;return t.safeAccountSingleton=null!=(a=t.safeAccountSingleton)?a:b,Me.createFactoryAddressAndData(e,t)}}class Ne{}class We extends Ne{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 N(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()===E.toLowerCase())){const e=await this.getSupportedERC20TokensAndPaymasterMetadata(E);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 C("PAYMASTER_ERROR","failed initializing the paymaster",{cause:t})}}async getSupportedERC20TokensAndPaymasterMetadata(e){if(this.initialized){var t,a,n;if(e==E)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 N(this.rpcUrl,"pm_supportedERC20Tokens",[e]):await N(this.rpcUrl,"pm_supportedERC20Tokens",[]),e==E)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 C("PAYMASTER_ERROR","getSupportedERC20TokensAndPaymasterMetadata failed",{cause:t})}return null}async getSupportedEntrypointsLive(){try{return"v3"==this.version?await N(this.rpcUrl,"pm_supportedEntryPoints",[]):[await N(this.rpcUrl,"pm_supportedEntryPoint",[])]}catch(e){const t=G(e);throw new C("PAYMASTER_ERROR","getSupportedEntrypoint failed",{cause:t})}}async getSupportedEntrypoints(){this.initialized||await this.initialize();const e=[];return null!=this.entrypointDataV8&&e.push(E),null!=this.entrypointDataV7&&e.push(S),null!=this.entrypointDataV6&&e.push(D),e}async getPaymasterMetaData(e){if(this.initialized||await this.initialize(),e==E&&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==E&&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=E;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,h,A,p,y;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 C("BAD_DATA","bundlerRpc can't be null if preVerificationGas,verificationGasLimit and callGasLimit are not overridden");{const o=new se(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:a*BigInt(null!=(f=i.preVerificationGasPercentageMultiplier)?f:100)/100n,e.verificationGasLimit=null!=(h=i.verificationGasLimit)?h:r*BigInt(null!=(A=i.verificationGasLimitPercentageMultiplier)?A:100)/100n,e.callGasLimit=null!=(p=i.callGasLimit)?p:s*BigInt(null!=(y=i.callGasLimitPercentageMultiplier)?y:100)/100n,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 N(this.rpcUrl,"pm_sponsorUserOperation",[e,n,a]),g=m,b={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=b.callGasLimit)?s:e.callGasLimit,e.preVerificationGas=null!=(o=b.preVerificationGas)?o:e.preVerificationGas,e.verificationGasLimit=null!=(l=b.verificationGasLimit)?l:e.verificationGasLimit,e.maxFeePerGas=null!=(c=b.maxFeePerGas)?c:e.maxFeePerGas,e.maxPriorityFeePerGas=null!=(d=b.maxPriorityFeePerGas)?d:e.maxPriorityFeePerGas,r=b.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 C("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{this.initialized||await this.initialize();const i=r||{};null==(null==i?void 0:i.callGasLimitPercentageMultiplier)&&(i.callGasLimitPercentageMultiplier=105);let s=null==r?void 0:r.entrypoint;null==s&&(s="initCode"in t?D:"eip7702Auth"in t?E:S);const o=2n*await this.calculateUserOperationErc20TokenMaxGasCost(t,a),l=await this.getPaymasterMetaData(s);if(null==l)throw new RangeError("unsupported entrypoint.");const c=e.prependTokenPaymasterApproveToCallData(t.callData,a,l.address,o);if(t.callData=c,"initCode"in t){const[e]=await this.createPaymasterUserOperation(t,n,{token:a},i);return e}if("eip7702Auth"in t){const[e]=await this.createPaymasterUserOperation(t,n,{token:a},i);return e}{const[e]=await this.createPaymasterUserOperation(t,n,{token:a},i);return e}}catch(e){const t=G(e);throw new C("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?E:S),await this.fetchTokenPaymasterExchangeRate(t,n)*z(e)/BigInt(10**18)}catch(e){const t=G(e);throw new C("PAYMASTER_ERROR","calculateUserOperationErc20TokenMaxGasCost failed",{cause:t})}}async fetchTokenPaymasterExchangeRate(e,t=S){try{let a;this.initialized||await this.initialize(),a="v3"==this.version?await N(this.rpcUrl,"pm_supportedERC20Tokens",[t]):await N(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 C("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 C("PAYMASTER_ERROR","fetchTokenPaymasterExchangeRate failed",{cause:t})}}async fetchSupportedERC20TokensAndPaymasterMetadata(e=S){try{let t;if(this.initialized||await this.initialize(),t="v3"==this.version?await N(this.rpcUrl,"pm_supportedERC20Tokens",[e]):await N(this.rpcUrl,"pm_supportedERC20Tokens",[]),e==E||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 C("PAYMASTER_ERROR","fetchSupportedERC20TokensAndPaymasterMetadata failed",{cause:t})}}}class ke extends Ne{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 He extends Ne{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:S);let u=e.preVerificationGas,f=e.verificationGasLimit,h=e.callGasLimit;e.preVerificationGas=0n;const A=new se(a),p=await A.estimateUserOperationGas(e,d,s.state_override_set);return u<p.preVerificationGas&&(u=p.preVerificationGas),f<p.verificationGasLimit&&(f=p.verificationGasLimit),h<p.callGasLimit&&(h=p.callGasLimit),e.preVerificationGas=u,e.verificationGasLimit=f,e.callGasLimit=h,e}}function ze(e,t,n){return a(i(["address","uint256","uint256"],[e,t,n]))}var Ye={__proto__:null,SmartAccount:p,Simple7702Account:ce,Simple7702AccountV09:de,SafeMultiChainSigAccount:Re,SocialRecoveryModule:Ce,get SocialRecoveryModuleGracePeriodSelector(){return Pe},EXECUTE_RECOVERY_PRIMARY_TYPE:Ge,EIP712_RECOVERY_MODULE_TYPE:Oe,AllowanceModule:Ie,SafeAccountV0_2_0:Ve,SafeAccountV0_3_0:Me,SafeAccountV1_5_0_M_0_3_0:Be,SendUseroperationResponse:oe,SmartAccountFactory:_e,SafeAccountFactory:we,Bundler:se,CandidePaymaster:We,AllowAllPaymaster:ke,WorldIdPermissionlessPaymaster:He,createWorldIdSignal:ze,createUserOperationHash:I,createCallData:B,getFunctionSelector:W,fetchAccountNonce:k,calculateUserOperationMaxGasCost:z,sendJsonRpcRequest:N,fetchGasPrice:H,getDepositInfo:j,getBalanceOf:Y,shareTenderlySimulationAndCreateLink:ue,simulateUserOperationWithTenderlyAndCreateShareLink:fe,simulateUserOperationWithTenderly:he,simulateUserOperationCallDataWithTenderly:pe,simulateSenderCallDataWithTenderlyAndCreateShareLink:me,simulateUserOperationCallDataWithTenderlyAndCreateShareLink:Ae,simulateSenderCallDataWithTenderly:ye,callTenderlySimulateBundle:ge,createAndSignLegacyRawTransaction:$,createAndSignEip7702RawTransaction:te,createEip7702TransactionHash:ae,createAndSignEip7702DelegationAuthorization:Z,createEip7702DelegationAuthorizationHash:Q,signHash:ee,get SafeModuleExecutorFunctionSelector(){return Ee},EOADummySignerSignaturePair:Se,WebauthnDummySignerSignaturePair:De,get Operation(){return U},get GasOption(){return R},get PolygonChain(){return L},ZeroAddress:y,BaseUserOperationDummyValues:w,EIP712_SAFE_OPERATION_V7_TYPE:v,EIP712_SAFE_OPERATION_V6_TYPE:T,DEFAULT_SECP256R1_PRECOMPILE_ADDRESS:x,AbstractionKitError:C,SAFE_MESSAGE_PRIMARY_TYPE:Te,SAFE_MESSAGE_MODULE_TYPE:ve,getSafeMessageEip712Data:Fe};export{C as AbstractionKitError,ke as AllowAllPaymaster,Ie as AllowanceModule,w as BaseUserOperationDummyValues,se as Bundler,We as CandidePaymaster,x as DEFAULT_SECP256R1_PRECOMPILE_ADDRESS,Oe as EIP712_RECOVERY_MODULE_TYPE,T as EIP712_SAFE_OPERATION_V6_TYPE,v as EIP712_SAFE_OPERATION_V7_TYPE,Se as EOADummySignerSignaturePair,Ge as EXECUTE_RECOVERY_PRIMARY_TYPE,R as GasOption,U as Operation,L as PolygonChain,ve as SAFE_MESSAGE_MODULE_TYPE,Te as SAFE_MESSAGE_PRIMARY_TYPE,we as SafeAccountFactory,Ve as SafeAccountV0_2_0,Me as SafeAccountV0_3_0,Be as SafeAccountV1_5_0_M_0_3_0,Ee as SafeModuleExecutorFunctionSelector,Re as SafeMultiChainSigAccount,oe as SendUseroperationResponse,ce as Simple7702Account,de as Simple7702AccountV09,p as SmartAccount,_e as SmartAccountFactory,Ce as SocialRecoveryModule,Pe as SocialRecoveryModuleGracePeriodSelector,De as WebauthnDummySignerSignaturePair,He as WorldIdPermissionlessPaymaster,y as ZeroAddress,Ye as abstractionkit,z as calculateUserOperationMaxGasCost,ge as callTenderlySimulateBundle,Z as createAndSignEip7702DelegationAuthorization,te as createAndSignEip7702RawTransaction,$ as createAndSignLegacyRawTransaction,B as createCallData,Q as createEip7702DelegationAuthorizationHash,ae as createEip7702TransactionHash,I as createUserOperationHash,ze as createWorldIdSignal,k as fetchAccountNonce,H as fetchGasPrice,Y as getBalanceOf,j as getDepositInfo,W as getFunctionSelector,Fe as getSafeMessageEip712Data,N as sendJsonRpcRequest,ue as shareTenderlySimulationAndCreateLink,ee as signHash,ye as simulateSenderCallDataWithTenderly,me as simulateSenderCallDataWithTenderlyAndCreateShareLink,pe as simulateUserOperationCallDataWithTenderly,Ae as simulateUserOperationCallDataWithTenderlyAndCreateShareLink,he as simulateUserOperationWithTenderly,fe as simulateUserOperationWithTenderlyAndCreateShareLink};
|