"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./platform-CCG_jgOO.js"),p=require("./wallet-BMli0fbu.js");class d extends t.AbstractSigner{signer;#e;#s;constructor(e){super(e.provider),t.defineProperties(this,{signer:e}),this.#e=null,this.#s=0}async getAddress(){return this.signer.getAddress()}connect(e){return new d(this.signer.connect(e))}async getNonce(e){if(e==="pending"){this.#e==null&&(this.#e=super.getNonce("pending"));const s=this.#s;return await this.#e+s}return super.getNonce(e)}increment(){this.#s++}reset(){this.#s=0,this.#e=null}async sendTransaction(e){const s=this.getNonce("pending");return this.increment(),e=await this.signer.populateTransaction(e),e.nonce=await s,await this.signer.sendTransaction(e)}signTransaction(e){return this.signer.signTransaction(e)}signMessage(e){return this.signer.signMessage(e)}signTypedData(e,s,i){return this.signer.signTypedData(e,s,i)}}async function f(r,e,s){const i=typeof e=="string"?new p.Wallet(e,r):e,n=s?.chain??(await t.EvmPlatform.chainFromRpc(r))[1],o=new d(i);if(o.provider===null)try{o.connect(r)}catch(a){console.error("Cannot connect to network for signer",a)}return new P(n,await i.getAddress(),o,s)}class P extends t.PlatformNativeSigner{opts;constructor(e,s,i,n){super(e,s,i),this.opts=n}chain(){return this._chain}address(){return this._address}async sign(e){const s=this.chain(),i=[];let n=500000n,o=100000000000n,a=1500000000n,g=100000000n;if(this.opts?.overrides===void 0&&s!=="Celo"){const c=await this._signer.provider.getFeeData();o=c.gasPrice??o,a=c.maxFeePerGas??a,g=c.maxPriorityFeePerGas??g}this.opts?.gasLimit!==void 0&&(n=this.opts.gasLimit),this.opts?.maxGasLimit!==void 0&&(n=n>this.opts?.maxGasLimit?this.opts?.maxGasLimit:n);const h={gasLimit:n,maxFeePerGas:a,maxPriorityFeePerGas:g};for(const c of e){const{transaction:l,description:m}=c;this.opts?.debug&&console.log(`Signing: ${m} for ${this.address()}`);const u={...l,...h,from:this.address(),nonce:await this._signer.getNonce(),...this.opts?.overrides};i.push(await this._signer.signTransaction(u))}return i}}const v={Address:t.EvmAddress,Platform:t.EvmPlatform,getSigner:f,protocols:{WormholeCore:()=>Promise.resolve().then(()=>require("./index-EbSw7SbC.js")),TokenBridge:()=>Promise.resolve().then(()=>require("./index-BYuhx88C.js")),PorticoBridge:()=>Promise.resolve().then(()=>require("./index-CZHdN9pg.js")),CircleBridge:()=>Promise.resolve().then(()=>require("./index-cRi8si5A.js")),TBTCBridge:()=>Promise.resolve().then(()=>require("./index-qL4D-cpk.js"))},getChain:(r,e,s)=>new t.EvmChain(e,new t.EvmPlatform(r,t.applyChainsConfigConfigOverrides(r,t._platform,{[e]:s})))};exports.default=v;
