Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../constants/chains.constants.cjs`),t=require(`../error-handling/error-codes.constants.cjs`),n=require(`../functions/utils/create-provider.cjs`),r=require(`../functions/web3/getContractMetadata.cjs`);let i=require(`ethers`);var a=class{signer;chainId;fetchProviders={};chainEventListener;constructor(){e.HINKAL_SUPPORTED_CHAINS.forEach(t=>{!e.isSolanaLike(t)&&!e.isTronLike(t)&&(this.fetchProviders[t]=n.createJsonRpcProvider(t))})}initConnector(){}initSigner(e){this.signer=e}async init(e){if(e&&(this.chainId=e),!this.chainId)throw Error(`No Chain Id In Provider Adapter`)}async disconnectFromConnector(){}async connectToConnector(){return 0}async waitForTransaction(e,n,r){if((await this.fetchProviders[e]?.waitForTransaction(n,r))?.status)return!0;throw Error(t.transactionErrorCodes.TRANSACTION_NOT_CONFIRMED)}async signMessage(e){if(!this.signer)throw Error(`IllegalState: no signer`);let n=await this.signer.signMessage(e);if(!n)throw Error(t.transactionErrorCodes.SIGNING_FAILED);if(n.includes(`error`))throw Error(t.transactionErrorCodes.SIGNATURE_UNSUPPORTED_PERSONAL_SIGN);return n}async signTypedData(e,t,n){return this.signer.signTypedData(e,t,n)}async switchNetwork(e){let t=this.fetchProviders[e.chainId];if(!t)throw Error(`switchNetwork illegal state: no provider`);this.signer=this.signer?.connect(t),this.chainEventListener?.onChainChanged(e.chainId)}async getAddress(){if(!this.signer)throw Error(`IllegalState: no signer`);let e=await this.signer.getAddress();if(!e)throw Error(`IllegalState`);return i.ethers.getAddress(e)}setChainEventListener(e){this.chainEventListener=e}onAccountChanged(){return this.init()}onChainChanged(e){return this.init(e)}release(){this.removeListeners()}removeListeners(){this.chainEventListener=void 0}getContract(e,t,n=void 0,i){return r.getContract(t,e,n,i)}getContractWithSigner(e,t,n=void 0){if(!this.signer)throw Error(`IllegalState: no signer`);return this.getContract(e,t,n,this.signer)}getContractWithFetcher(e,t,n=void 0){if(!this.fetchProviders[e])throw Error(`fetchProvider not initialized`);return this.getContract(e,t,n,this.fetchProviders[e])}async sendTransaction(e){if(!this.signer)throw Error(`IllegalState: no signer`);return await this.signer.sendTransaction(e)}async connectAndPatchProvider(){if(!this.signer)throw Error(`IllegalState: no signer`);let{chainId:e}=await this.signer.provider.getNetwork();return Number(e)}getChainId(){return this.chainId}isPermitterAvailable(){return!1}async getGasPrice(e){let t=(await this.fetchProviders[e]?.getFeeData())?.gasPrice;if(!t)throw Error(`Could not fetch gas price in getGasPrice`);return t}},o=new a,s=()=>new a;exports.EthersProviderAdapter=a,exports.default=s,exports.ethersProvierAdapter=o;