"use strict";(self.webpackChunkaesirx_cmp=self.webpackChunkaesirx_cmp||[]).push([[316],{31316:(e,a,t)=>{t.d(a,{offchainLookup:()=>g,offchainLookupSignature:()=>m});var r=t(76782),s=t(18463),n=t(26329),o=t(61526);class c extends n.C{constructor({callbackSelector:e,cause:a,data:t,extraData:r,sender:s,urls:n}){super(a.shortMessage||"An error occurred while fetching for an offchain result.",{cause:a,metaMessages:[...a.metaMessages||[],a.metaMessages?.length?"":[],"Offchain Gateway Call:",n&&["  Gateway URL(s):",...n.map((e=>`    ${(0,o.ID)(e)}`))],`  Sender: ${s}`,`  Data: ${t}`,`  Callback selector: ${e}`,`  Extra data: ${r}`].flat()}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"OffchainLookupError"})}}class d extends n.C{constructor({result:e,url:a}){super("Offchain gateway response is malformed. Response data must be a hex value.",{metaMessages:[`Gateway URL: ${(0,o.ID)(a)}`,`Response: ${(0,s.A)(e)}`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"OffchainLookupResponseMalformedError"})}}class l extends n.C{constructor({sender:e,to:a}){super("Reverted sender address does not match target contract address (`to`).",{metaMessages:[`Contract address: ${a}`,`OffchainLookup sender address: ${e}`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"OffchainLookupSenderMismatchError"})}}var u=t(76595),i=t(15462),f=t(94531),h=t(14306),p=t(29873);var b=t(25419),w=t(46394);const m="0x556f1830",y={name:"OffchainLookup",type:"error",inputs:[{name:"sender",type:"address"},{name:"urls",type:"string[]"},{name:"callData",type:"bytes"},{name:"callbackFunction",type:"bytes4"},{name:"extraData",type:"bytes"}]};async function g(e,{blockNumber:a,blockTag:t,data:n,to:o}){const{args:m}=(0,i.W)({data:n,abi:[y]}),[g,k,x,C,O]=m;try{if(!function(e,a){if(!(0,p.P)(e))throw new h.M({address:e});if(!(0,p.P)(a))throw new h.M({address:a});return e.toLowerCase()===a.toLowerCase()}(o,g))throw new l({sender:g,to:o});const n=await async function({data:e,sender:a,urls:t}){let r=new Error("An unknown error occurred.");for(let n=0;n<t.length;n++){const o=t[n],c=o.includes("{data}")?"GET":"POST",l="POST"===c?{data:e,sender:a}:void 0;try{const t=await fetch(o.replace("{sender}",a).replace("{data}",e),{body:JSON.stringify(l),method:c});let n;if(n=t.headers.get("Content-Type")?.startsWith("application/json")?(await t.json()).data:await t.text(),!t.ok){r=new u.Ci({body:l,details:n?.error?(0,s.A)(n.error):t.statusText,headers:t.headers,status:t.status,url:o});continue}if(!(0,w.q)(n)){r=new d({result:n,url:o});continue}return n}catch(e){r=new u.Ci({body:l,details:e.message,url:o})}}throw r}({data:x,sender:g,urls:k}),{data:c}=await(0,r.T)(e,{blockNumber:a,blockTag:t,data:(0,b.xW)([C,(0,f.h)([{type:"bytes"},{type:"bytes"}],[n,O])]),to:o});return c}catch(e){throw new c({callbackSelector:C,cause:e,data:n,extraData:O,sender:g,urls:k})}}}}]);