var u=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var y=(t,r)=>{for(var n in r)u(t,n,{get:r[n],enumerable:!0})},S=(t,r,n,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let e of v(r))!x.call(t,e)&&e!==n&&u(t,e,{get:()=>r[e],enumerable:!(o=h(r,e))||o.enumerable});return t};var k=t=>S(u({},"__esModule",{value:!0}),t);var R={};y(R,{useContract:()=>F});module.exports=k(R);var p=require("@web3-react/core"),C=require("react");var f=require("@ethersproject/address"),m=require("@ethersproject/constants"),l=require("@ethersproject/contracts");function w(t,r){return t.getSigner(r).connectUnchecked()}function E(t,r){return r?w(t,r):t}function g(t,r,n,o){if(!(0,f.isAddress)(t)||t===m.AddressZero)throw Error(`Invalid 'address' parameter '${t}'.`);return new l.Contract(t,r,E(n,o))}function F(t,r,n=!0){let{provider:o,account:e,chainId:c}=(0,p.useWeb3React)();return(0,C.useMemo)(()=>{if(!t||!r||!o||!c)return null;let i;if(typeof t=="string"?i=t:i=t[c],!i)return null;try{return g(i,r,o,n&&e?e:void 0)}catch(a){return console.error("Failed to get contract",a),null}},[t,r,o,c,n,e])}0&&(module.exports={useContract});
