PageSourceSearch

https://rift-easonchai.vercel.app/_next/static/chunks/1066.e31144e2ec625b23.js

js rift-easonchai.vercel.app collected 2026-10-03 07:38:40 UTC 27,820 bytes, 5 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1066],{61066:function(t,e,a){a.d(e,{SmartWalletConnector:function(){return R}});var r=a(38569),i=a(6881),s=a(16441),n=a(38197),o=a(84243),c=a(2593),d=a(93901),h=a(48088),l=a(93684),u=a(64146),g=a(97013),p=a(9279),m=a(79911),f=a(19485),w=a(29251),y=a(61744),A=a(84257),P=a(97532),v=a(51364),T=a(83872),I=a(91765),O=a(57855),b=a(5710),x=a(88819),C=a(74501),G=a(22555);async function U(t){let e=await i.resolveProperties(t);return Object.keys(e).map(t=>{let a=e[t];return"string"==typeof a&&a.startsWith("0x")||(a=s.hexValue(a)),[t,a]}).reduce((t,e)=>{let[a,r]=e;return{...t,[a]:r}},{})}async function E(t,e,a){let r=await i.resolveProperties(t),s={sender:r.sender,nonce:r.nonce,initCodeHash:n.keccak256(r.initCode),callDataHash:n.keccak256(r.callData),callGasLimit:r.callGasLimit,verificationGasLimit:r.verificationGasLimit,preVerificationGas:r.preVerificationGas,maxFeePerGas:r.maxFeePerGas,maxPriorityFeePerGas:r.maxPriorityFeePerGas,paymasterAndDataHash:n.keccak256(r.paymasterAndData)},c=o.$.encode([{components:[{type:"address",name:"sender"},{type:"uint256",name:"nonce"},{type:"bytes32",name:"initCodeHash"},{type:"bytes32",name:"callDataHash"},{type:"uint256",name:"callGasLimit"},{type:"uint256",name:"verificationGasLimit"},{type:"uint256",name:"preVerificationGas"},{type:"uint256",name:"maxFeePerGas"},{type:"uint256",name:"maxPriorityFeePerGas"},{type:"bytes32",name:"paymasterAndDataHash"}],name:"hashedUserOp",type:"tuple"}],[{...s}]),d=n.keccak256(c),h=o.$.encode(["bytes32","address","uint256"],[d,e,a]);return n.keccak256(h)}a(54146);let _=()=>{let t=BigInt(Math.floor(4294967296*Math.random())),e=BigInt(Math.floor(4294967296*Math.random())),a=BigInt(Math.floor(4294967296*Math.random())),r=BigInt(Math.floor(4294967296*Math.random())),i=BigInt(Math.floor(4294967296*Math.random())),s=BigInt(Math.floor(4294967296*Math.random()));return t<<BigInt(160)|e<<BigInt(128)|a<<BigInt(96)|r<<BigInt(64)|i<<BigInt(32)|s},L=()=>{let t=_().toString(16);return t.length%2!=0&&(t="0"+t),t="0x"+t,c.O$.from(s.concat([t,"0x0000000000000000"]))};class k{}class ${constructor(t,e,a,r,i){this.bundlerUrl=t,this.entryPointAddress=e,this.chainId=a;let s={};if((0,A.i)(this.bundlerUrl)){let t="undefined"!=typeof globalThis&&"APP_BUNDLE_ID"in globalThis?globalThis.APP_BUNDLE_ID:void 0;i?s["x-secret-key"]=i:r&&(s["x-client-id"]=r,t&&(s["x-bundle-id"]=t)),"undefined"!=typeof globalThis&&"TW_AUTH_TOKEN"in globalThis&&"string"==typeof globalThis.TW_AUTH_TOKEN&&(s.authorization=`Bearer ${globalThis.TW_AUTH_TOKEN}`),"undefined"!=typeof globalThis&&"TW_CLI_AUTH_TOKEN"in globalThis&&"string"==typeof globalThis.TW_CLI_AUTH_TOKEN&&(s.authorization=`Bearer ${globalThis.TW_CLI_AUTH_TOKEN}`,s["x-authorize-wallet"]="true"),(0,P.s)(s)}this.userOpJsonRpcProvider=new d.c({url:this.bundlerUrl,headers:s},{name:"Connected bundler network",chainId:a}),this.initializing=this.validateChainId()}async validateChainId(){let t=parseInt(await this.userOpJsonRpcProvider.send("eth_chainId",[]));if(t!==this.chainId)throw Error(`bundler ${this.bundlerUrl} is on chainId ${t}, but provider is on chainId ${this.chainId}`)}async sendUserOpToBundler(t){await this.initializing;let e=await U(t),a=[e,this.entryPointAddress];return await this.printUserOperation("eth_sendUserOperation",a),await this.userOpJsonRpcProvider.send("eth_sendUserOperation",[e,this.entryPointAddress])}async estimateUserOpGas(t){await this.initializing;let e=await U(t),a=[e,this.entryPointAddress];return await this.printUserOperation("eth_estimateUserOperationGas",a),await this.userOpJsonRpcProvider.send("eth_estimateUserOperationGas",[e,this.entryPointAddress])}async getUserOperationReceipt(t){return await this.initializing,await this.userOpJsonRpcProvider.send("eth_getUserOperationReceipt",[t])}async printUserOperation(t,e){}}class N extends k{constructor(t,e,a,r){super(),this.paymasterUrl=t,this.entryPoint=e,this.clientId=a,this.secretKey=r}async getPaymasterAndData(t){let e={"Content-Type":"application/json"};if((0,A.i)(this.paymasterUrl)){if(this.secretKey&&this.clientId)throw Error("Cannot use both secret key and client ID. Please use secretKey for server-side applications and clientId for client-side applications.");if(this.secretKey)e["x-secret-key"]=this.secretKey;else if(this.clientId){e["x-client-id"]=this.clientId;let t="undefined"!=typeof globalThis&&"APP_BUNDLE_ID"in globalThis?globalThis.APP_BUNDLE_ID:void 0;t&&(e["x-bundle-id"]=t)}"undefined"!=typeof globalThis&&"TW_AUTH_TOKEN"in globalThis&&"string"==typeof globalThis.TW_AUTH_TOKEN&&(e.authorization=`Bearer ${globalThis.TW_AUTH_TOKEN}`),"undefined"!=typeof globalThis&&"TW_CLI_AUTH_TOKEN"in globalThis&&"string"==typeof globalThis.TW_CLI_AUTH_TOKEN&&(e.authorization=`Bearer ${globalThis.TW_CLI_AUTH_TOKEN}`,e["x-authorize-wallet"]="true"),(0,P.s)(e)}let a=await fetch(this.paymasterUrl,{method:"POST",headers:e,body:JSON.stringify({jsonrpc:"2.0",id:1,method:"pm_sponsorUserOperation",params:[await U(t),this.entryPoint]})}),r=await a.json();if(!a.ok){let t=r.error||a.statusText,e=r.code||"UNKNOWN";throw Error(`Paymaster error: ${t}
2Status: ${a.status}
3Code: ${e}`)}if(r.result)return"string"==typeof r.result?{paymasterAndData:r.result}:r.result;{let t=r.error?.message||r.error||a.statusText||"unknown error";throw Error(`Paymaster error from ${this.paymasterUrl}: ${t}`)}}}let D=(t,e,a,r)=>new N(t,e,a,r);class F{constructor(t,e,a,r,i,s,n){this.resolve=t,this.reject=e,this.entryPoint=a,this.sender=r,this.userOpHash=i,this.nonce=s,this.timeout=n,(0,T._)(this,"resolved",!1),this.boundLisener=this.listenerCallback.bind(this)}start(){let t=this.entryPoint.filters.UserOperationEvent(this.userOpHash);setTimeout(async()=>{let e=await this.entryPoint.queryFilter(t,-10);e.length>0?this.listenerCallback(e[0]):this.entryPoint.once(t,this.boundLisener)},100)}stop(){this.entryPoint.off("UserOperationEvent",this.boundLisener)}async listenerCallback(){for(var t=arguments.length,e=Array(t),a=0;a<t;a++)e[a]=arguments[a];let r=arguments[arguments.length-1];if(!r.args){console.error("got event without args",r);return}if(r.args.userOpHash!==this.userOpHash){console.log(`== event with wrong userOpHash: sender/nonce: event.${r.args.sender}@${r.args.nonce.toString()}!= userOp.${this.sender}@${parseInt(this.nonce?.toString())}`);return}let i=await r.getTransactionReceipt();r.args.success||await this.extractFailureReason(i),this.stop(),this.resolve(i),this.resolved=!0}async extractFailureReason(t){t.status=0;let e=await this.entryPoint.queryFilter(this.entryPoint.filters.UserOperationRevertReason(this.userOpHash,this.sender),t.blockHash);if(e[0]){let t=e[0].args.revertReason;t.startsWith("0x08c379a0")&&(t=o.$.decode(["string"],"0x"+t.substring(10)).toString()),this.reject(Error(`UserOp failed with reason: ${t}`))}}}class B extends h.Signer{constructor(t,e,a,r,s){super(),i.defineReadOnly(this,"provider",a),this.config=t,this.originalSigner=e,this.erc4337provider=a,this.httpRpcClient=r,this.smartAccountAPI=s,this.approving=!1}async sendTransaction(t,e){if(!this.approving){this.approving=!0;let t=await this.smartAccountAPI.createApproveTx();t&&await (await this.sendTransaction(t)).wait(),this.approving=!1}let a=await i.resolveProperties(t);await this.verifyAllNecessaryFields(a);let r=L(),s=await this.smartAccountAPI.createUnsignedUserOp(this.httpRpcClient,{target:a.to||"",data:a.data?.toString()||"0x",value:a.value,gasLimit:a.gasLimit,nonce:r,maxFeePerGas:a.maxFeePerGas,maxPriorityFeePerGas:a.maxPriorityFeePerGas},e),n=await this.smartAccountAPI.signUserOp(s),o=await this.erc4337provider.constructUserOpTransactionResponse(n);try{await this.httpRpcClient.sendUserOpToBundler(n)}catch(t){throw this.unwrapError(t)}return o}unwrapError(t){try{let e="Unknown Error";if(t.error)e=`The bundler has failed to include UserOperation in a batch: ${t.error}`;else if(t.body&&"string"==typeof t.body){let a=JSON.parse(t.body),r=t.status||"UNKNOWN",i=a?.code||"UNKNOWN",s=a?.error?.message||a?.error?.data||a?.error||t.reason;if(s?.includes("FailedOp")){let t="",a=s.match(/FailedOp\((.*)\)/);if(a){let e=a[1].split(",");t=`(paymaster address: ${e[1]})`,s=e[2]}e=`The bundler has failed to include UserOperation in a batch: ${s} ${t}`}else e=`RPC error: ${s}
4Status: ${r}
5Code: ${i}`}let a=Error(e);return a.stack=t.stack,a}catch(t){}return t}async verifyAllNecessaryFields(t){if(!t.to)throw Error("Missing call target");if(!t.data&&!t.value)throw Error("Missing call data or value")}connect(t){throw Error("changing providers is not supported")}async getAddress(){return this.address||(this.address=await this.erc4337provider.getSenderAccountAddress()),this.address}async signMessage(t){let e,a;
5if(await this.smartAccountAPI.checkAccountPhantom()){console.log("Account contract not deployed yet. Deploying account before signing message");let t=await this.sendTransaction({to:await this.getAddress(),data:"0x"});await t.wait()}let[r,i]=await Promise.all([this.getChainId(),this.getAddress()]),s=l.r(t),n=(0,x.m)(r,this.config.clientId),c={};if((0,A.i)(n)){let t="undefined"!=typeof globalThis&&"APP_BUNDLE_ID"in globalThis?globalThis.APP_BUNDLE_ID:void 0;this.config.secretKey?c["x-secret-key"]=this.config.secretKey:this.config.clientId&&(c["x-client-id"]=this.config.clientId,t&&(c["x-bundle-id"]=t)),"undefined"!=typeof globalThis&&"TW_AUTH_TOKEN"in globalThis&&"string"==typeof globalThis.TW_AUTH_TOKEN&&(c.authorization=`Bearer ${globalThis.TW_AUTH_TOKEN}`),"undefined"!=typeof globalThis&&"TW_CLI_AUTH_TOKEN"in globalThis&&"string"==typeof globalThis.TW_CLI_AUTH_TOKEN&&(c.authorization=`Bearer ${globalThis.TW_CLI_AUTH_TOKEN}`,c["x-authorize-wallet"]="true"),(0,P.s)(c)}try{let t=new d.c({url:(0,x.m)(r,this.config.clientId),headers:c},r),a=new u.CH(i,["function getMessageHash(bytes32 _hash) public view returns (bytes32)"],t);await a.getMessageHash(s),e=!0}catch{e=!1}if(a=e?(await (0,I.aM)(this,{name:"Account",version:"1",chainId:r,verifyingContract:i},{AccountMessage:[{name:"message",type:"bytes"}]},{message:o.$.encode(["bytes32"],[s])})).signature:await this.originalSigner.signMessage(t),await (0,C.c)(t,a,i,r,this.config.clientId,this.config.secretKey))return a;throw Error("Unable to verify signature on smart account, please make sure the smart account is deployed and the signature is valid.")}async signTransaction(t,e){let a=await i.resolveProperties(t);await this.verifyAllNecessaryFields(a);let r=L(),s=await this.smartAccountAPI.createUnsignedUserOp(this.httpRpcClient,{target:a.to||"",data:a.data?.toString()||"0x",value:a.value,gasLimit:a.gasLimit,nonce:r},e),n=await this.smartAccountAPI.signUserOp(s);return JSON.stringify(await U(n))}}class S extends g.Zk{constructor(t,e,a,r,i,s,n){super({name:"ERC-4337 Custom Network",chainId:t}),this.chainId=t,this.config=e,this.originalSigner=a,this.originalProvider=r,this.httpRpcClient=i,this.entryPoint=s,this.smartAccountAPI=n,this.signer=new B(e,a,this,i,n)}getSigner(){return this.signer}async perform(t,e){if("sendTransaction"===t||"getTransactionReceipt"===t)throw Error("Should not get here. Investigate.");return"estimateGas"===t?c.O$.from(5e5):await this.originalProvider.perform(t,e)}async getTransaction(t){return await super.getTransaction(t)}
5async getTransactionReceipt(t){let e=await t,a=await this.getSenderAccountAddress();return await new Promise((t,r)=>{new F(t,r,this.entryPoint,a,e).start()})}async getSenderAccountAddress(){return await this.smartAccountAPI.getAccountAddress()}async waitForTransaction(t,e,a){let r=await this.getSenderAccountAddress();return await new Promise((e,i)=>{new F(e,i,this.entryPoint,r,t,void 0,a).start()})}async constructUserOpTransactionResponse(t){let e=await i.resolveProperties(t),a=await this.smartAccountAPI.getUserOpHash(e);return{hash:a,confirmations:0,from:e.sender,nonce:0,gasLimit:c.O$.from(e.callGasLimit),value:c.O$.from(0),data:s.hexValue(e.callData),chainId:this.chainId,wait:async t=>{let r=await this.smartAccountAPI.getUserOpReceipt(this.httpRpcClient,a);return 0!==e.initCode.length&&await this.smartAccountAPI.checkAccountPhantom(),r}}}async detectNetwork(){return this.originalProvider.detectNetwork()}}class K{constructor(t){(0,T._)(this,"isPhantom",!0),this.provider=t.provider,this.entryPointAddress=t.entryPointAddress,this.accountAddress=t.accountAddress,this.paymasterAPI=t.paymasterAPI,this.gasless=t.gasless,this.erc20PaymasterAddress=t.erc20PaymasterAddress,this.erc20TokenAddress=t.erc20TokenAddress,this.entryPointView=v.EntryPoint__factory.connect(t.entryPointAddress,t.provider).connect(p.d)}async checkAccountPhantom(){return this.isPhantom&&(await this.provider.getCode(this.getAccountAddress())).length>2&&(this.isPhantom=!1),this.isPhantom}async getInitCode(){return await this.checkAccountPhantom()?await this.getAccountInitCode():"0x"}async getVerificationGasLimit(){return 1e5}async getUserOpHash(t){let e=await this.provider.getNetwork().then(t=>t.chainId);return E(t,this.entryPointAddress,e)}async getAccountAddress(){return this.senderAddress||(this.accountAddress?this.senderAddress=this.accountAddress:this.senderAddress=await this.getCounterFactualAddress()),this.senderAddress}async estimateCreationGas(t){if(!t||"0x"===t)return 0;let e=t.substring(0,42),a="0x"+t.substring(42);return await this.provider.estimateGas({to:e,data:a})}async createUnsignedUserOp(t,e,a){var r;let i=await this.getInitCode(),s=((r=e.value)&&""!==r?c.O$.from(r.toString()):null)??c.O$.from(0),n=a?.batchData?e.data:await this.prepareExecute(e.target,s,e.data).then(t=>t.encode()),{maxFeePerGas:o,maxPriorityFeePerGas:d}=e;if(!o||!d){let t=await (0,O.a)(this.provider);if(d||(d=t.maxPriorityFeePerGas??void 0),!o){o=t.maxFeePerGas??void 0;let e=(await this.provider.getNetwork()).chainId;(e===G.Lll.chainId||e===G.M8s.chainId||e===G.m3x.chainId)&&(d=o)}}if(!o||!d)throw Error("maxFeePerGas or maxPriorityFeePerGas could not be calculated, please pass them explicitely");let[h,l]=await Promise.all([this.getAccountAddress(),e.nonce?Promise.resolve(e.nonce):this.getNonce()]),u={sender:h,nonce:l,initCode:i,callData:n,maxFeePerGas:o,maxPriorityFeePerGas:d,callGasLimit:c.O$.from(1e6),verificationGasLimit:c.O$.from(1e6),preVerificationGas:c.O$.from(1e6),paymasterAndData:"0x",signature:"0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c"},g=a?.gasless!==void 0?a.gasless:this.gasless;if(this.erc20PaymasterAddress&&this.erc20TokenAddress&&await this.isAccountApproved()){let e;u.paymasterAndData=this.erc20PaymasterAddress;try{e=await t.estimateUserOpGas(u)}catch(t){throw this.unwrapBundlerError(t)}u.callGasLimit=c.O$.from(e.callGasLimit),u.verificationGasLimit=c.O$.from(e.verificationGasLimit),u.preVerificationGas=c.O$.from(e.preVerificationGas)}else if(g){let e=await this.paymasterAPI.getPaymasterAndData(u),a=e.paymasterAndData;if(a&&"0x"!==a&&(u.paymasterAndData=a),e.callGasLimit&&e.verificationGasLimit&&e.preVerificationGas)u.callGasLimit=c.O$.from(e.callGasLimit),u.verificationGasLimit=c.O$.from(e.verificationGasLimit),u.preVerificationGas=c.O$.from(e.preVerificationGas);else{let e;try{e=await t.estimateUserOpGas(u)}catch(t){throw this.unwrapBundlerError(t)}if(u.callGasLimit=c.O$.from(e.callGasLimit),u.verificationGasLimit=c.O$.from(e.verificationGasLimit),u.preVerificationGas=c.O$.from(e.preVerificationGas),a&&"0x"!==a){let t=await this.paymasterAPI.getPaymasterAndData(u);t.paymasterAndData&&"0x"!==t.paymasterAndData&&(u.paymasterAndData=t.paymasterAndData)}}}else{let e;try{e=await t.estimateUserOpGas(u)}catch(t){throw this.unwrapBundlerError(t)}u.callGasLimit=c.O$.from(e.callGasLimit),u.verificationGasLimit=c.O$.from(e.verificationGasLimit),u.preVerificationGas=c.O$.from(e.preVerificationGas)}return{...u,signature:""}}async signUserOp(t){let e=await this.getUserOpHash(t),a=await this.signUserOpHash(e);return{...t,signature:a}}async getUserOpReceipt(t,e){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:12e4,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1e3,i=Date.now()+a;for(;Date.now()<i;){let a=await t.getUserOperationReceipt(e);
5if(a)return await this.provider.waitForTransaction(a.receipt.transactionHash);await new Promise(t=>setTimeout(t,r))}throw Error("Timeout waiting for userOp to be mined")}unwrapBundlerError(t){return Error(t?.error?.message||t.error||t.message||t)}}class H extends K{constructor(t,e){super({...t,provider:e}),this.params=t,this.sdk=b.T.fromPrivateKey(b.L,t.chain,{clientId:t.clientId,secretKey:t.secretKey,supportedChains:"object"==typeof t.chain?[t.chain]:void 0})}async getChainId(){return await this.provider.getNetwork().then(t=>t.chainId)}async getAccountContract(){return this.accountContract||(this.params.accountInfo?.abi?this.accountContract=await this.sdk.getContract(await this.getAccountAddress(),this.params.accountInfo.abi):this.accountContract=await this.sdk.getContract(await this.getAccountAddress(),C.A)),this.accountContract}async getAccountInitCode(){let t=await this.getFactoryContract(),e=await this.params.localSigner.getAddress(),a=await this.params.factoryInfo.createAccount(t,e);return s.hexConcat([t.getAddress(),a.encode()])}async getFactoryContract(){return this.factoryContract||(this.params.factoryInfo?.abi?this.factoryContract=await this.sdk.getContract(this.params.factoryAddress,this.params.factoryInfo.abi):this.factoryContract=await this.sdk.getContract(this.params.factoryAddress)),this.factoryContract}async getCounterFactualAddress(){if(this.params.accountAddress)return this.params.accountAddress;let t=await this.getFactoryContract(),e=await this.params.localSigner.getAddress();return this.params.factoryInfo.getAccountAddress(t,e)}async getNonce(){if(await this.checkAccountPhantom())return c.O$.from(0);let t=await this.getAccountContract();return this.params.accountInfo.getNonce(t)}async prepareExecute(t,e,a){let r=await this.getAccountContract();return this.params.accountInfo.execute(r,t,e,a)}async prepareExecuteBatch(t,e,a){return(await this.getAccountContract()).prepare("executeBatch",[t,e,a])}async signUserOpHash(t){return await this.params.localSigner.signMessage(s.arrayify(t))}async isAcountDeployed(){return!await this.checkAccountPhantom()}async isAccountApproved(){if(!this.params.erc20PaymasterAddress||!this.params.erc20TokenAddress)return!0;let t=await this.getCounterFactualAddress(),e=(await Promise.resolve().then(a.t.bind(a,49242,19))).default,r=await this.sdk.getContract(this.params.erc20TokenAddress,e);return(await r.call("allowance",[t,this.params.erc20PaymasterAddress])).gte(c.O$.from(2).pow(96).sub(1))}async createApproveTx(){if(await this.isAccountApproved())return;let t=c.O$.from(2).pow(96).sub(1),e=new m.Wallet(b.L,this.provider),a=new u.CH(this.params.erc20TokenAddress,["function approve(address spender, uint256 amount) public returns (bool)"],e);return{to:this.params.erc20TokenAddress,from:await this.getAccountAddress(),value:0,data:a.interface.encodeFunctionData("approve",[this.params.erc20PaymasterAddress,t])}}}class R extends r.C{constructor(t){super(),this.config=t}async initialize(t){let e=this.config,a=(0,I.a_)(e.chain,{clientId:e.clientId,secretKey:e.secretKey});this.chainId=(await a.getNetwork()).chainId;let r=this.config.bundlerUrl||`https://${this.chainId}.bundler.thirdweb.com`,i=this.config.paymasterUrl||`https://${this.chainId}.bundler.thirdweb.com/v2`,s=e.entryPointAddress||C.E,n=await t.personalWallet.getSigner(),o={chain:e.chain,localSigner:n,entryPointAddress:s,bundlerUrl:r,paymasterAPI:this.config.paymasterAPI?this.config.paymasterAPI:D(i,s,this.config.clientId,this.config.secretKey),gasless:e.gasless,factoryAddress:e.factoryAddress,accountAddress:t.accountAddress,factoryInfo:{createAccount:e.factoryInfo?.createAccount||this.defaultFactoryInfo().createAccount,getAccountAddress:e.factoryInfo?.getAccountAddress||this.defaultFactoryInfo().getAccountAddress,abi:e.factoryInfo?.abi},accountInfo:{execute:e.accountInfo?.execute||this.defaultAccountInfo().execute,getNonce:e.accountInfo?.getNonce||this.defaultAccountInfo().getNonce,abi:e.accountInfo?.abi},clientId:e.clientId,secretKey:e.secretKey,erc20PaymasterAddress:e.erc20PaymasterAddress,erc20TokenAddress:e.erc20TokenAddress};this.personalWallet=t.personalWallet;let c=new H(o,a);this.aaProvider=function(t,e,a,r){let i=v.EntryPoint__factory.connect(t.entryPointAddress,a),s=new $(t.bundlerUrl,t.entryPointAddress,r,t.clientId,t.secretKey);return new S(r,t,t.localSigner,a,s,i,e)}(o,c,a,this.chainId),this.accountApi=c}async connect(t){return await this.initialize(t),await this.getAddress()}
5getProvider(){if(!this.aaProvider)throw Error("Personal wallet not connected");return Promise.resolve(this.aaProvider)}async getSigner(){if(!this.aaProvider)throw Error("Personal wallet not connected");return Promise.resolve(this.aaProvider.getSigner())}async getAddress(){return(await this.getSigner()).getAddress()}async isConnected(){try{return!!await this.getAddress()}catch(t){return!1}}async disconnect(){this.personalWallet=void 0,this.aaProvider=void 0}async switchChain(t){let e=await this.getProvider();if((await e.getNetwork()).chainId!==t)throw Error("Not supported.")}setupListeners(){return Promise.resolve()}updateChains(t){}async hasPermissionToExecute(t){let e=await this.getAccountContract(),a=await this.getSigner(),r=await a.getAddress(),i=(await e.account.getAllSigners()).filter(t=>f.getAddress(t.signer)===f.getAddress(r))[0]?.permissions;return!!i&&i.approvedCallTargets.includes(t.getTarget())}async send(t,e){return(await this.getSigner()).sendTransaction({to:t.getTarget(),data:t.encode(),value:await t.getValue()},e)}async execute(t,e){let a=await this.send(t,e);return{receipt:await a.wait()}}async sendBatch(t,e){if(!this.accountApi)throw Error("Personal wallet not connected");
5let a=await this.getSigner(),{tx:r,batchData:i}=await this.prepareBatchTx(t);return await a.sendTransaction({to:await a.getAddress(),data:r.encode(),value:0},{...e,batchData:i})}async executeBatch(t,e){let a=await this.sendBatch(t,e);return{receipt:await a.wait()}}async sendRaw(t,e){if(!this.accountApi)throw Error("Personal wallet not connected");return(await this.getSigner()).sendTransaction(t,e)}async executeRaw(t,e){let a=await this.sendRaw(t,e);return{receipt:await a.wait()}}async sendBatchRaw(t,e){if(!this.accountApi)throw Error("Personal wallet not connected");let a=await this.getSigner(),r=await this.prepareBatchRaw(t);return a.sendTransaction({to:await a.getAddress(),data:r.tx.encode(),value:0},{...e,batchData:r.batchData})}async executeBatchRaw(t,e){let a=await this.sendBatchRaw(t,e);return{receipt:await a.wait()}}async estimate(t,e){if(!this.accountApi)throw Error("Personal wallet not connected");return this.estimateTx({target:t.getTarget(),data:t.encode(),value:await t.getValue(),gasLimit:await t.getOverrides().gasLimit,maxFeePerGas:await t.getOverrides().maxFeePerGas,maxPriorityFeePerGas:await t.getOverrides().maxPriorityFeePerGas,nonce:await t.getOverrides().nonce},e)}async estimateRaw(t,e){if(!this.accountApi)throw Error("Personal wallet not connected");let a=await i.resolveProperties(t);return this.estimateTx({target:a.to||p.d,data:a.data?.toString()||"",value:a.value||c.O$.from(0),gasLimit:a.gasLimit,maxFeePerGas:a.maxFeePerGas,maxPriorityFeePerGas:a.maxPriorityFeePerGas,nonce:a.nonce},e)}async estimateBatch(t,e){if(!this.accountApi)throw Error("Personal wallet not connected");let{tx:a,batchData:r}=await this.prepareBatchTx(t);return this.estimateTx({target:a.getTarget(),data:a.encode(),value:await a.getValue(),gasLimit:await a.getOverrides().gasLimit,maxFeePerGas:await a.getOverrides().maxFeePerGas,maxPriorityFeePerGas:await a.getOverrides().maxPriorityFeePerGas,nonce:await a.getOverrides().nonce},{...e,batchData:r})}async estimateBatchRaw(t,e){if(!this.accountApi)throw Error("Personal wallet not connected");let{tx:a,batchData:r}=await this.prepareBatchRaw(t);return this.estimateTx({target:a.getTarget(),data:a.encode(),value:await a.getValue(),gasLimit:await a.getOverrides().gasLimit,maxFeePerGas:await a.getOverrides().maxFeePerGas,maxPriorityFeePerGas:await a.getOverrides().maxPriorityFeePerGas,nonce:await a.getOverrides().nonce},{...e,batchData:r})}async deploy(t){if(!this.accountApi)throw Error("Personal wallet not connected");
5let e=await this.getSigner(),a=await e.sendTransaction({to:await e.getAddress(),data:"0x"},{...t,batchData:{targets:[],data:[],values:[]}});return{receipt:await a.wait()}}async isDeployed(){if(!this.accountApi)throw Error("Personal wallet not connected");return await this.accountApi.isAcountDeployed()}async deployIfNeeded(t){await this.isDeployed()||await this.deploy(t)}async grantPermissions(t,e){return(await this.getAccountContract()).account.grantPermissions(t,e)}async revokePermissions(t){return(await this.getAccountContract()).account.revokeAccess(t)}async addAdmin(t){return(await this.getAccountContract()).account.grantAdminPermissions(t)}async removeAdmin(t){return(await this.getAccountContract()).account.revokeAdminPermissions(t)}async getAllActiveSigners(){if(await this.isDeployed())return(await this.getAccountContract()).account.getAllAdminsAndSigners();{let t=await this.personalWallet?.getSigner();if(!t)throw Error("Personal wallet not connected");return[{isAdmin:!0,signer:await t.getAddress(),permissions:{startDate:new Date(0),expirationDate:new Date(0),nativeTokenLimitPerTransaction:c.O$.from(0),approvedCallTargets:[]}}]}}
5async getAccountContract(){let t=b.T.fromSigner(await this.getSigner(),this.config.chain,{clientId:this.config.clientId,secretKey:this.config.secretKey});return this.config.accountInfo?.abi?t.getContract(await this.getAddress(),this.config.accountInfo.abi):t.getContract(await this.getAddress(),C.A)}async getFactoryContract(){let t=b.T.fromSigner(await this.getSigner(),this.config.chain,{clientId:this.config.clientId,secretKey:this.config.secretKey});return this.config.factoryInfo?.abi?t.getContract(this.config.factoryAddress,this.config.factoryInfo.abi):t.getContract(this.config.factoryAddress)}defaultFactoryInfo(){return{createAccount:async(t,e)=>t.prepare("createAccount",[e,w.Y0("")]),getAccountAddress:async(t,e)=>await t.call("getAddress",[e,w.Y0("")])}}defaultAccountInfo(){return{execute:async(t,e,a,r)=>t.prepare("execute",[e,a,r]),getNonce:async t=>t.call("getNonce",[])}}async estimateTx(t,e){if(!this.accountApi||!this.aaProvider)throw Error("Personal wallet not connected");let a=c.O$.from(0),[r,s]=await Promise.all([this.getProvider(),this.isDeployed()]);s||(a=await this.estimateDeploymentGasLimit());let[n,o]=await Promise.all([this.accountApi.createUnsignedUserOp(this.aaProvider.httpRpcClient,t,e),(0,O.b)(r)]),d=await i.resolveProperties(n),h=c.O$.from(d.callGasLimit),l=h.mul(o),u=a.mul(o),g=u.add(l);return{ether:y.formatEther(g),wei:g,details:{deployGasLimit:a,transactionGasLimit:h,gasPrice:o,transactionCost:l,deployCost:u,totalCost:g}}}async estimateDeploymentGasLimit(){if(!this.accountApi)throw Error("Personal wallet not connected");let t=await this.accountApi.getInitCode(),[e,a]=await Promise.all([this.accountApi.estimateCreationGas(t),this.accountApi.getVerificationGasLimit()]);return c.O$.from(a).add(e)}async prepareBatchRaw(t){if(!this.accountApi)throw Error("Personal wallet not connected");let e=await Promise.all(t.map(t=>i.resolveProperties(t))),a=e.map(t=>t.to||p.d),r=e.map(t=>t.data||"0x"),s=e.map(t=>t.value||c.O$.from(0));return{tx:await this.accountApi.prepareExecuteBatch(a,s,r),batchData:{targets:a,data:r,values:s}}}async prepareBatchTx(t){if(!this.accountApi)throw Error("Personal wallet not connected");let e=t.map(t=>t.getTarget()),a=t.map(t=>t.encode()),r=await Promise.all(t.map(t=>t.getValue()));return{tx:await this.accountApi.prepareExecuteBatch(e,r,a),batchData:{targets:e,data:a,values:r}}}}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.