import{m as d,n as o}from"./chunk-HLLU77MH.js";import"./chunk-5QSDSOWH.js";import{b as s,c as h,g as i,h as l}from"./chunk-2KLLAGCE.js";import{a as p}from"./chunk-CVKDPNYM.js";import{DEFAULT_ETHEREUM_RPC_URL as P}from"@rango-dev/wallets-shared";import{JsonRpcProvider as y,Transaction as f}from"ethers";import{SignerError as E,SignerErrorCode as R}from"rango-types";var u=class{static{p(this,"EthereumSigner")}async signMessage(r){try{let a=await i(),t=await new o(a).signPersonalMessage(s(),Buffer.from(r).toString("hex")),n=(t.v-27).toString(16);return n.length<2&&(n="0"+n),"0x"+t.r+t.s+n}catch(a){throw new E(R.SIGN_TX_ERROR,void 0,a)}}async signAndSendTx(r,a,c){try{let t=new y(P),n=await t.getTransactionCount(a),g={to:r.to,gasPrice:r.gasPrice,gasLimit:r.gasLimit,nonce:n,chainId:c,data:r.data,value:r.value,maxPriorityFeePerGas:r.maxPriorityFeePerGas,maxFeePerGas:r.maxFeePerGas},m=f.from(g).unsignedSerialized.substring(2),T=await d.resolveTransaction(m,{},{}),v=await i(),e=await new o(v).signTransaction(s(),m,T),w=f.from({...g,signature:{r:"0x"+e.r,s:"0x"+e.s,v:parseInt(e.v)}}).serialized;return{hash:(await t.broadcastTransaction(w)).hash}}catch(t){throw h(t)}finally{await l()}}};export{u as EthereumSigner};
//# sourceMappingURL=ethereum-V2WNWA6L.js.map
