@recoilpay/intent-widget 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@recoilpay/intent-widget",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "RecoilPay intents for any website: one script tag, a <recoilpay-intent> element, wallet connection included.",
5
5
  "keywords": [
6
6
  "recoilpay",
@@ -35,8 +35,8 @@
35
35
  "prepublishOnly": "npm run build"
36
36
  },
37
37
  "devDependencies": {
38
- "@recoilpay/intent-core": "^0.1.0",
39
- "@recoilpay/intent-react": "^0.1.0",
38
+ "@recoilpay/intent-core": "^0.3.0",
39
+ "@recoilpay/intent-react": "^0.3.0",
40
40
  "@testing-library/react": "^16.3.3",
41
41
  "@types/react": "^18.3.31",
42
42
  "@types/react-dom": "^18.3.7",
@@ -1 +0,0 @@
1
- import{c as u,i as b,j as k,l as y,w as S,y as C,z as t}from"./chunk-Z3OIWTR5.js";import{g as m,h as T,i as n,o as s,s as i,u as h}from"./chunk-JYRWMYZ2.js";var D=t({id:421614,name:"Arbitrum Sepolia",blockTime:250,nativeCurrency:{name:"Arbitrum Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia-rollup.arbitrum.io/rpc"]}},blockExplorers:{default:{name:"Arbiscan",url:"https://sepolia.arbiscan.io",apiUrl:"https://api-sepolia.arbiscan.io/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:81930}},testnet:!0});var v={gasPriceOracle:{address:"0x420000000000000000000000000000000000000F"},l1Block:{address:"0x4200000000000000000000000000000000000015"},l2CrossDomainMessenger:{address:"0x4200000000000000000000000000000000000007"},l2Erc721Bridge:{address:"0x4200000000000000000000000000000000000014"},l2StandardBridge:{address:"0x4200000000000000000000000000000000000010"},l2ToL1MessagePasser:{address:"0x4200000000000000000000000000000000000016"}};var g={block:y({format(o){return{transactions:o.transactions?.map(r=>{if(typeof r=="string")return r;let p=b(r);return p.typeHex==="0x7e"&&(p.isSystemTx=r.isSystemTx,p.mint=r.mint?m(r.mint):void 0,p.sourceHash=r.sourceHash,p.type="deposit"),p}),stateRoot:o.stateRoot}}}),transaction:k({format(o){let e={};return o.type==="0x7e"&&(e.isSystemTx=o.isSystemTx,e.mint=o.mint?m(o.mint):void 0,e.sourceHash=o.sourceHash,e.type="deposit"),e}}),transactionReceipt:S({format(o){return{...o.depositNonce?{depositNonce:m(o.depositNonce)}:{},...o.depositReceiptVersion?{depositReceiptVersion:T(o.depositReceiptVersion)}:{},l1GasPrice:o.l1GasPrice?m(o.l1GasPrice):null,l1GasUsed:o.l1GasUsed?m(o.l1GasUsed):null,l1Fee:o.l1Fee?m(o.l1Fee):null,l1FeeScalar:o.l1FeeScalar?Number(o.l1FeeScalar):null}}})};function N(o,e){return P(o)?F(o):C(o,e)}var z={transaction:N};function F(o){j(o);let{sourceHash:e,data:r,from:p,gas:l,isSystemTx:E,mint:c,to:M,value:d}=o,B=[e,p,M??"0x",c?n(c):"0x",d?n(d):"0x",l?n(l):"0x",E?"0x1":"0x",r??"0x"];return h(["0x7e",u(B)])}function P(o){return o.type==="deposit"||typeof o.sourceHash<"u"}function j(o){let{from:e,to:r}=o;if(e&&!i(e))throw new s({address:e});if(r&&!i(r))throw new s({address:r})}var a={blockTime:2e3,contracts:v,formatters:g,serializers:z};var f=11155111,w=t({...a,id:84532,network:"base-sepolia",name:"Base Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia.base.org"]}},blockExplorers:{default:{name:"Basescan",url:"https://sepolia.basescan.org",apiUrl:"https://api-sepolia.basescan.org/api"}},contracts:{...a.contracts,disputeGameFactory:{[f]:{address:"0xd6E6dBf4F7EA0ac412fD8b65ED297e64BB7a06E1"}},l2OutputOracle:{[f]:{address:"0x84457ca9D0163FbC4bbfe4Dfbb20ba46e48DF254"}},portal:{[f]:{address:"0x49f53e41452c74589e85ca1677426ba426459e85",blockCreated:4446677}},l1StandardBridge:{[f]:{address:"0xfd0Bf71F60660E2f608ed56e1659C450eB113120",blockCreated:4446677}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:1059647}},testnet:!0,sourceId:f}),H=t({...w,experimental_preconfirmationTime:200,rpcUrls:{default:{http:["https://sepolia-preconf.base.org"]}}});var x=11155111,A=t({...a,id:11155420,name:"OP Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia.optimism.io"]}},blockExplorers:{default:{name:"Blockscout",url:"https://optimism-sepolia.blockscout.com",apiUrl:"https://optimism-sepolia.blockscout.com/api"}},contracts:{...a.contracts,disputeGameFactory:{[x]:{address:"0x05F9613aDB30026FFd634f38e5C4dFd30a197Fa1"}},l2OutputOracle:{[x]:{address:"0x90E9c4f8a994a250F6aEfd61CAFb4F2e895D458F"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:1620204},portal:{[x]:{address:"0x16Fc5058F25648194471939df75CF27A2fdC48BC"}},l1StandardBridge:{[x]:{address:"0xFBb0621E0B23b5478B630BD55a5f21f67730B0F1"}}},testnet:!0,sourceId:x});var G=t({id:80002,name:"Polygon Amoy",nativeCurrency:{name:"POL",symbol:"POL",decimals:18},rpcUrls:{default:{http:["https://polygon-amoy.drpc.org"]}},blockExplorers:{default:{name:"PolygonScan",url:"https://amoy.polygonscan.com",apiUrl:"https://api.etherscan.io/v2/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:3127388}},testnet:!0});var L=t({id:11155111,name:"Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://11155111.rpc.thirdweb.com"]}},blockExplorers:{default:{name:"Etherscan",url:"https://sepolia.etherscan.io",apiUrl:"https://api-sepolia.etherscan.io/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:751532},ensUniversalResolver:{address:"0xeeeeeeee14d718c2b47d9923deab1335e144eeee",blockCreated:8928790}},testnet:!0});export{D as a,w as b,A as c,G as d,L as e};
@@ -1 +0,0 @@
1
- import{a as wr}from"./chunk-F7HZCPX2.js";import{$ as ze,Aa as me,B as se,Ba as Tr,C,D as mr,E as fr,F as ur,Fa as O,G as _,H as pr,Ia as fe,J as dr,K as lr,L as xr,Ma as vr,Na as Pr,Oa as oe,Q as S,Qa as Br,R as G,S as hr,T as yr,U as br,V as gr,W as k,X,Y as ae,Z as Re,_ as Fe,a as J,aa as Ue,b as R,ba as He,c as b,ca as q,d as er,da as Q,e as rr,ea as Le,f as Y,fa as Ge,g as Ae,ga as ee,h as F,ha as re,i as z,ia as ce,j as B,ja as Ne,k as h,ka as V,l as tr,la as De,m as U,ma as ke,n as or,na as Me,o as H,oa as _e,p as nr,pa as qe,q as Ce,qa as Ve,ra as Oe,s as L,sa as $e,ta as je,u as Z,ua as Ke,v as ir,va as We,w as sr,wa as Je,x as ar,xa as te,ya as Er,z as cr,za as Ir}from"./chunk-JYRWMYZ2.js";var ue=256,pe;function de(e=11){if(!pe||ue+e>256*2){pe="",ue=0;for(let r=0;r<256;r++)pe+=(256+Math.random()*256|0).toString(16).substring(1)}return pe.substring(ue,ue+++e)}function st(e){let{batch:r,chain:t,ccipRead:o,dataSuffix:n,key:i="base",name:s="Base Client",tokens:c,type:a="base"}=e,d=e.experimental_blockTag??(typeof t?.experimental_preconfirmationTime=="number"?"pending":void 0),f=t?.blockTime??12e3,l=Math.min(Math.max(Math.floor(f/2),500),4e3),u=e.pollingInterval??l,m=e.cacheTime??u,E=e.account?cr(e.account):void 0,{config:p,request:x,value:w}=e.transport({account:E,chain:t,pollingInterval:u}),v={...p,...w},y={account:E,batch:r,cacheTime:m,ccipRead:o,chain:t,dataSuffix:n,key:i,name:s,pollingInterval:u,request:x,tokens:c,transport:v,type:a,uid:de(),...d?{experimental_blockTag:d}:{}};function I(g){return T=>{let P=T(g);for(let N in y)delete P[N];let A={...g,...P};for(let N in P){let W=g[N],ie=P[N];Sr(W)&&Sr(ie)&&(A[N]={...W,...ie})}return Object.assign(A,{extend:I(A)})}}return Object.assign(y,{extend:I(y)})}function Sr(e){if(typeof e!="object"||e===null)return!1;let r=Object.getPrototypeOf(e);return r===Object.prototype||r===null}var le=new nr(8192);function Ar(e,{enabled:r=!0,id:t}){if(!r||!t)return e();if(le.get(t))return le.get(t);let o=e().finally(()=>le.delete(t));return le.set(t,o),o}async function xe(e,{signal:r}={}){return new Promise((t,o)=>{if(r?.aborted){o(S(r));return}let n=()=>r?.removeEventListener("abort",s),i=setTimeout(()=>{n(),t()},e),s=()=>{clearTimeout(i),n(),o(S(r))};r?.addEventListener("abort",s,{once:!0})})}function Cr(e,{delay:r=100,retryCount:t=2,shouldRetry:o=()=>!0,signal:n}={}){return new Promise((i,s)=>{let c=async({count:a=0}={})=>{if(n?.aborted){s(S(n));return}let d=async({error:f})=>{let l=typeof r=="function"?r({count:a,error:f}):r;if(l)try{await xe(l,{signal:n})}catch(u){s(u);return}return c({count:a+1})};try{let f=await e();i(f)}catch(f){if(n?.aborted){s(S(n));return}if(G(f)){s(f);return}if(a<t&&await o({count:a,error:f}))return d({error:f});s(f)}};c().catch(s)})}function Rr(e,r={}){return async(t,o={})=>{let{dedupe:n=!1,methods:i,retryDelay:s=150,retryCount:c=3,signal:a,uid:d}={...r,...o},{method:f}=t;if(i?.exclude?.includes(f))throw new re(new Error("method not supported"),{method:f});if(i?.include&&!i.include.includes(f))throw new re(new Error("method not supported"),{method:f});if(a?.aborted)throw S(a);let l=n?ct(`${d}.${C(t)}`):void 0;return Ar(()=>Cr(async()=>{try{return await e(t,a?{signal:a}:void 0)}catch(u){if(a?.aborted)throw S(a);if(G(u))throw u;let m=u;switch(m.code){case Fe.code:throw new Fe(m);case ze.code:throw new ze(m);case Ue.code:throw new Ue(m,{method:t.method});case He.code:throw new He(m);case q.code:throw new q(m);case Q.code:throw new Q(m);case Le.code:throw new Le(m);case Ge.code:throw new Ge(m);case ee.code:throw new ee(m);case re.code:throw new re(m,{method:t.method});case ce.code:throw new ce(m);case Ne.code:throw new Ne(m);case V.code:throw new V(m);case De.code:throw new De(m);case ke.code:throw new ke(m);case Me.code:throw new Me(m);case _e.code:throw new _e(m);case qe.code:throw new qe(m);case Ve.code:throw new Ve(m);case Oe.code:throw new Oe(m);case $e.code:throw new $e(m);case je.code:throw new je(m);case Ke.code:throw new Ke(m);case We.code:throw new We(m);case Je.code:throw new Je(m);case 5e3:throw new V(m);case te.code:throw new te(m);default:throw u instanceof b?u:new Er(m)}}},{delay:({count:u,error:m})=>{if(m&&m instanceof k){let E=m?.headers?.get("Retry-After");if(E?.match(/\d/))return Number.parseInt(E,10)*1e3}return~~(1<<u)*s},retryCount:c,signal:a,shouldRetry:({error:u})=>at(u)}),{enabled:n,id:l})}}function at(e){return G(e)?!1:"code"in e&&typeof e.code=="number"?e.code===-1||e.code===ce.code||e.code===q.code||e.code===429||e.code===-32007:e instanceof k&&e.status?e.status===403||e.status===408||e.status===413||e.status===429||e.status===500||e.status===502||e.status===503||e.status===504:!0}function ct(e,r=0){let t=3735928559^r,o=1103547991^r;for(let n=0;n<e.length;n++){let i=e.charCodeAt(n);t=Math.imul(t^i,2654435761),o=Math.imul(o^i,1597334677)}return t=Math.imul(t^t>>>16,2246822507),t^=Math.imul(o^o>>>16,3266489909),o=Math.imul(o^o>>>16,2246822507),o^=Math.imul(t^t>>>16,3266489909),(4294967296*(2097151&o)+(t>>>0)).toString(36)}function $({key:e,methods:r,name:t,request:o,retryCount:n=3,retryDelay:i=150,timeout:s,type:c},a){let d=de();return{config:{key:e,methods:r,name:t,request:o,retryCount:n,retryDelay:i,timeout:s,type:c},request:Rr(o,{methods:r,retryCount:n,retryDelay:i,uid:d}),value:a}}function mt(e,r={}){let{key:t="custom",methods:o,name:n="Custom Provider",retryDelay:i}=r;return({retryCount:s})=>$({key:t,methods:o,name:n,request:e.request.bind(e),retryCount:r.retryCount??s,retryDelay:i,type:"custom"})}function ft(e,r={}){let{key:t="fallback",name:o="Fallback",rank:n=!1,shouldThrow:i=Fr,retryCount:s,retryDelay:c}=r;return(({chain:a,pollingInterval:d=4e3,timeout:f,...l})=>{let u=e,m=()=>{},E=$({key:t,name:o,async request({method:p,params:x}){let w,v=async(y=0)=>{let I=u[y]({...l,chain:a,retryCount:0,timeout:f});try{let g=await I.request({method:p,params:x});return m({method:p,params:x,response:g,transport:I,status:"success"}),g}catch(g){if(m({error:g,method:p,params:x,transport:I,status:"error"}),i(g)||y===u.length-1||(w??(w=u.slice(y+1).some(T=>{let{include:P,exclude:A}=T({chain:a}).config.methods||{};return P?P.includes(p):A?!A.includes(p):!0})),!w))throw g;return v(y+1)}};return v()},retryCount:s,retryDelay:c,type:"fallback"},{onResponse:p=>m=p,transports:u.map(p=>p({chain:a,retryCount:0}))});if(n){let p=typeof n=="object"?n:{};ut({chain:a,interval:p.interval??d,onTransports:x=>u=x,ping:p.ping,sampleCount:p.sampleCount,timeout:p.timeout,transports:u,weights:p.weights})}return E})}function Fr(e){return!!("code"in e&&typeof e.code=="number"&&(e.code===ee.code||e.code===V.code||e.code===te.code||Ir.nodeMessage.test(e.message)||e.code===5e3))}function ut({chain:e,interval:r=4e3,onTransports:t,ping:o,sampleCount:n=10,timeout:i=1e3,transports:s,weights:c={}}){let{stability:a=.7,latency:d=.3}=c,f=[],l=async()=>{let u=await Promise.all(s.map(async p=>{let x=p({chain:e,retryCount:0,timeout:i}),w=Date.now(),v,y;try{await(o?o({transport:x}):x.request({method:"net_listening"})),y=1}catch{y=0}finally{v=Date.now()}return{latency:v-w,success:y}}));f.push(u),f.length>n&&f.shift();let m=Math.max(...f.map(p=>Math.max(...p.map(({latency:x})=>x)))),E=s.map((p,x)=>{let w=f.map(T=>T[x].latency),y=1-w.reduce((T,P)=>T+P,0)/w.length/m,I=f.map(T=>T[x].success),g=I.reduce((T,P)=>T+P,0)/I.length;return g===0?[0,x]:[d*y+a*g,x]}).sort((p,x)=>x[0]-p[0]);t(E.map(([,p])=>s[p])),await xe(r),l()};l()}var he=class extends b{constructor(){super("No URL was provided to the Transport. Please provide a valid RPC URL to the Transport.",{docsPath:"/docs/clients/intro",name:"UrlRequiredError"})}};function zr(e,{errorInstance:r=new Error("timed out"),timeout:t,signal:o}){return new Promise((n,i)=>{(async()=>{let s,c=new AbortController;try{t>0&&(s=setTimeout(()=>{o?c.abort():i(r)},t)),n(await e({signal:c?.signal||null}))}catch(a){if(c?.signal.aborted&&G(a)){i(r);return}i(a)}finally{clearTimeout(s)}})()})}function pt(){return{current:0,take(){return this.current++},reset(){this.current=0}}}var Ye=pt();var dt=10485760;function Ur(e,r={}){let{url:t,headers:o}=xt(e);return{async request(n){let{body:i,fetchFn:s=r.fetchFn??fetch,maxResponseBodySize:c=r.maxResponseBodySize??dt,onRequest:a=r.onRequest,onResponse:d=r.onResponse,timeout:f=r.timeout??1e4}=n,l={...r.fetchOptions??{},...n.fetchOptions??{}},{headers:u,method:m,signal:E}=l;try{let p=await zr(async({signal:v})=>{let y={...l,body:Array.isArray(i)?C(i.map(P=>({jsonrpc:"2.0",id:P.id??Ye.take(),...P}))):C({jsonrpc:"2.0",id:i.id??Ye.take(),...i}),headers:{...o,"Content-Type":"application/json",...u},method:m||"POST",signal:E||(f>0?v:null)},I=new Request(t,y),g=await a?.(I,y)??{...y,url:t};return await s(g.url??t,g)},{errorInstance:new Re({body:i,url:t}),timeout:f,signal:!0});d&&await d(p);let x,w=await lt(p,{maxResponseBodySize:c});if(p.headers.get("Content-Type")?.startsWith("application/json"))x=JSON.parse(w);else{x=w;try{x=JSON.parse(x||"{}")}catch(v){if(p.ok)throw v;x={error:x}}}if(!p.ok){if(typeof x.error?.code=="number"&&typeof x.error?.message=="string")return x;throw new k({body:i,details:C(x.error)||p.statusText,headers:p.headers,status:p.status,url:t})}return x}catch(p){throw E?.aborted?S(E):G(p)||p instanceof k||p instanceof X||p instanceof Re?p:new k({body:i,cause:p,url:t})}}}}async function lt(e,{maxResponseBodySize:r}){if(r===!1)return e.text();let t=e.headers.get("Content-Length");if(t){let c=Number(t);if(c>r)throw new X({maxSize:r,size:c})}if(!e.body){let c=await e.text(),a=new TextEncoder().encode(c).length;if(a>r)throw new X({maxSize:r,size:a});return c}let o=e.body.getReader(),n=new TextDecoder,i="",s=0;try{for(;;){let{done:c,value:a}=await o.read();if(c)break;if(s+=a.byteLength,s>r)throw await o.cancel(),new X({maxSize:r,size:s});i+=n.decode(a,{stream:!0})}return i+=n.decode(),i}finally{o.releaseLock()}}function xt(e){try{let r=new URL(e),t=(()=>{if(r.username){let o=`${decodeURIComponent(r.username)}:${decodeURIComponent(r.password)}`;return r.username="",r.password="",{url:r.toString(),headers:{Authorization:`Basic ${btoa(o)}`}}}})();return{url:r.toString(),...t}}catch{return{url:e}}}var ht=0,Hr=new WeakMap;function yt(e){if(!e)return"default";let r=Hr.get(e);if(r!==void 0)return r;let t=ht++;return Hr.set(e,t),t}function bt(e,r={}){let{batch:t,fetchFn:o,fetchOptions:n,key:i="http",maxResponseBodySize:s,methods:c,name:a="HTTP JSON-RPC",onFetchRequest:d,onFetchResponse:f,retryDelay:l,raw:u}=r;return({chain:m,retryCount:E,timeout:p})=>{let{batchSize:x=1e3,wait:w=0}=typeof t=="object"?t:{},v=r.retryCount??E,y=p??r.timeout??1e4,I=e||m?.rpcUrls.default.http[0];if(!I)throw new he;let g=Ur(I,{fetchFn:o,fetchOptions:n,maxResponseBodySize:s,onRequest:d,onResponse:f,timeout:y});return $({key:i,methods:c,name:a,async request({method:T,params:P},A){let N={method:T,params:P},W=A?.signal?{signal:A.signal}:void 0,{schedule:ie}=Br({id:`${I}.${yt(A?.signal)}`,wait:w,shouldSplitBatch(D){return D.length>x},fn:D=>g.request({body:D,fetchOptions:W}),sort:(D,it)=>D.id-it.id}),nt=async D=>t?ie(D):[await g.request({body:D,fetchOptions:W})],[{error:Se,result:Qe}]=await nt(N);if(u)return{error:Se,result:Qe};if(Se)throw new ae({body:N,error:Se,url:I});return Qe},retryCount:v,retryDelay:l,timeout:y,type:"http"},{fetchOptions:n,url:I})}}var gt=3;function Do(e,{abi:r,address:t,args:o,docsPath:n,functionName:i,sender:s}){let c=e instanceof gr?e:e instanceof b?e.walk(E=>"data"in E)||e.walk():{},{code:a,data:d,details:f,message:l,shortMessage:u}=c,m=e instanceof er?new br({functionName:i,cause:e}):[gt,q.code].includes(a)&&(d||f||l||u)||a===Q.code&&f==="execution reverted"&&d?new yr({abi:r,data:typeof d=="object"?d.data:d,functionName:i,message:c instanceof ae?f:u??l,cause:e}):e;return new hr(m,{abi:r,args:o,contractAddress:t,docsPath:n,functionName:i,sender:s})}function Lr(e){let r=or(`0x${e.substring(4)}`).substring(26);return Ce(`0x${r}`)}async function Nr({hash:e,signature:r}){let t=J(e)?e:z(e),{secp256k1:o}=await import("./secp256k1-ACZE2VHK.js");return`0x${(()=>{if(typeof r=="object"&&"r"in r&&"s"in r){let{r:d,s:f,v:l,yParity:u}=r,m=Number(u??l),E=Gr(m);return new o.Signature(Ae(d),Ae(f)).addRecoveryBit(E)}let s=J(r)?r:z(r);if(R(s)!==65)throw new Error("invalid signature length");let c=F(`0x${s.slice(130)}`),a=Gr(c);return o.Signature.fromCompact(s.substring(2,130)).addRecoveryBit(a)})().recoverPublicKey(t.substring(2)).toHex(!1)}`}function Gr(e){if(e===0||e===1)return e;if(e===27)return 0;if(e===28)return 1;throw new Error("Invalid yParityOrV value")}async function Yo({hash:e,signature:r}){return Lr(await Nr({hash:e,signature:r}))}function M(e,r="hex"){let t=Dr(e),o=se(new Uint8Array(t.length));return t.encode(o),r==="hex"?B(o.bytes):o.bytes}function Dr(e){return Array.isArray(e)?Et(e.map(r=>Dr(r))):wt(e)}function Et(e){let r=e.reduce((n,i)=>n+i.length,0),t=kr(r);return{length:r<=55?1+r:1+t+r,encode(n){r<=55?n.pushByte(192+r):(n.pushByte(247+t),t===1?n.pushUint8(r):t===2?n.pushUint16(r):t===3?n.pushUint24(r):n.pushUint32(r));for(let{encode:i}of e)i(n)}}}function wt(e){let r=typeof e=="string"?U(e):e,t=kr(r.length);return{length:r.length===1&&r[0]<128?1:r.length<=55?1+r.length:1+t+r.length,encode(n){r.length===1&&r[0]<128?n.pushBytes(r):r.length<=55?(n.pushByte(128+r.length),n.pushBytes(r)):(n.pushByte(183+t),t===1?n.pushUint8(r.length):t===2?n.pushUint16(r.length):t===3?n.pushUint24(r.length):n.pushUint32(r.length),n.pushBytes(r))}}}function kr(e){if(e<2**8)return 1;if(e<2**16)return 2;if(e<2**24)return 3;if(e<2**32)return 4;throw new b("Length is too large.")}var Mr=class extends b{constructor(r,{account:t,docsPath:o,chain:n,data:i,gas:s,gasPrice:c,maxFeePerGas:a,maxPriorityFeePerGas:d,nonce:f,to:l,value:u}){let m=pr({from:t?.address,to:l,value:typeof u<"u"&&`${ur(u)} ${n?.nativeCurrency?.symbol||"ETH"}`,data:i,gas:s,gasPrice:typeof c<"u"&&`${_(c)} gwei`,maxFeePerGas:typeof a<"u"&&`${_(a)} gwei`,maxPriorityFeePerGas:typeof d<"u"&&`${_(d)} gwei`,nonce:f});super(r.shortMessage,{cause:r,docsPath:o,metaMessages:[...r.metaMessages?[...r.metaMessages," "]:[],"Estimate Gas Arguments:",m].filter(Boolean),name:"EstimateGasExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=r}};var _r=class extends b{constructor(){super("`baseFeeMultiplier` must be greater than 1.",{name:"BaseFeeScalarError"})}},qr=class extends b{constructor(){super("Chain does not support EIP-1559 fees.",{name:"Eip1559FeesNotSupportedError"})}},Vr=class extends b{constructor({maxPriorityFeePerGas:r}){super(`\`maxFeePerGas\` cannot be less than the \`maxPriorityFeePerGas\` (${_(r)} gwei).`,{name:"MaxFeePerGasTooLowError"})}};var Or=class extends b{constructor({blockHash:r,blockNumber:t}){let o="Block";r&&(o=`Block at hash "${r}"`),t&&(o=`Block at number "${t}"`),super(`${o} could not be found.`,{name:"BlockNotFoundError"})}};var Ze={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function Xe(e,r){let t={...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,...e.blockTimestamp!=null&&{blockTimestamp:BigInt(e.blockTimestamp)},chainId:e.chainId?F(e.chainId):void 0,gas:e.gas?BigInt(e.gas):void 0,gasPrice:e.gasPrice?BigInt(e.gasPrice):void 0,maxFeePerBlobGas:e.maxFeePerBlobGas?BigInt(e.maxFeePerBlobGas):void 0,maxFeePerGas:e.maxFeePerGas?BigInt(e.maxFeePerGas):void 0,maxPriorityFeePerGas:e.maxPriorityFeePerGas?BigInt(e.maxPriorityFeePerGas):void 0,nonce:e.nonce?F(e.nonce):void 0,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,type:e.type?Ze[e.type]:void 0,typeHex:e.type?e.type:void 0,value:e.value?BigInt(e.value):void 0,v:e.v?BigInt(e.v):void 0};return e.authorizationList&&(t.authorizationList=It(e.authorizationList)),t.yParity=(()=>{if(e.yParity)return Number(e.yParity);if(typeof t.v=="bigint"){if(t.v===0n||t.v===27n)return 0;if(t.v===1n||t.v===28n)return 1;if(t.v>=35n)return t.v%2n===0n?1:0}})(),t.type==="legacy"&&(delete t.accessList,delete t.maxFeePerBlobGas,delete t.maxFeePerGas,delete t.maxPriorityFeePerGas,delete t.yParity),t.type==="eip2930"&&(delete t.maxFeePerBlobGas,delete t.maxFeePerGas,delete t.maxPriorityFeePerGas),t.type==="eip1559"&&delete t.maxFeePerBlobGas,t}var hn=O("transaction",Xe);function It(e){return e.map(r=>({address:r.address,chainId:Number(r.chainId),nonce:Number(r.nonce),r:r.r,s:r.s,yParity:Number(r.yParity)}))}function Tt(e,r){let t=(e.transactions??[]).map(o=>typeof o=="string"?o:Xe(o));return{...e,baseFeePerGas:e.baseFeePerGas?BigInt(e.baseFeePerGas):null,blobGasUsed:e.blobGasUsed?BigInt(e.blobGasUsed):void 0,difficulty:e.difficulty?BigInt(e.difficulty):void 0,excessBlobGas:e.excessBlobGas?BigInt(e.excessBlobGas):void 0,gasLimit:e.gasLimit?BigInt(e.gasLimit):void 0,gasUsed:e.gasUsed?BigInt(e.gasUsed):void 0,hash:e.hash?e.hash:null,logsBloom:e.logsBloom?e.logsBloom:null,nonce:e.nonce?e.nonce:null,number:e.number?BigInt(e.number):null,size:e.size?BigInt(e.size):void 0,timestamp:e.timestamp?BigInt(e.timestamp):void 0,transactions:t,totalDifficulty:e.totalDifficulty?BigInt(e.totalDifficulty):null}}var En=O("block",Tt);function ye(e){let{kzg:r}=e,t=e.to??(typeof e.blobs[0]=="string"?"hex":"bytes"),o=typeof e.blobs[0]=="string"?e.blobs.map(i=>U(i)):e.blobs,n=[];for(let i of o)n.push(Uint8Array.from(r.blobToKzgCommitment(i)));return t==="bytes"?n:n.map(i=>B(i))}function be(e){let{kzg:r}=e,t=e.to??(typeof e.blobs[0]=="string"?"hex":"bytes"),o=typeof e.blobs[0]=="string"?e.blobs.map(s=>U(s)):e.blobs,n=typeof e.commitments[0]=="string"?e.commitments.map(s=>U(s)):e.commitments,i=[];for(let s=0;s<o.length;s++){let c=o[s],a=n[s];i.push(Uint8Array.from(r.computeBlobKzgProof(c,a)))}return t==="bytes"?i:i.map(s=>B(s))}var $r=wr;function jr(e,r){let t=r||"hex",o=$r(J(e,{strict:!1})?tr(e):e);return t==="bytes"?o:z(o)}function Kr(e){let{commitment:r,version:t=1}=e,o=e.to??(typeof r=="string"?"hex":"bytes"),n=jr(r,"bytes");return n.set([t],0),o==="bytes"?n:B(n)}function Wr(e){let{commitments:r,version:t}=e,o=e.to??(typeof r[0]=="string"?"hex":"bytes"),n=[];for(let i of r)n.push(Kr({commitment:i,to:o,version:t}));return n}var ge=class extends b{constructor({maxSize:r,size:t}){super("Blob size is too large.",{metaMessages:[`Max: ${r} bytes`,`Given: ${t} bytes`],name:"BlobSizeTooLargeError"})}},j=class extends b{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}},Ee=class extends b{constructor({hash:r,size:t}){super(`Versioned hash "${r}" size is invalid.`,{metaMessages:["Expected: 32",`Received: ${t}`],name:"InvalidVersionedHashSizeError"})}},we=class extends b{constructor({hash:r,version:t}){super(`Versioned hash "${r}" version is invalid.`,{metaMessages:[`Expected: ${1}`,`Received: ${t}`],name:"InvalidVersionedHashVersionError"})}};function Jr(e){let r=e.to??(typeof e.data=="string"?"hex":"bytes"),t=typeof e.data=="string"?U(e.data):e.data,o=R(t);if(!o)throw new j;if(o>761855)throw new ge({maxSize:761855,size:o});let n=[],i=!0,s=0;for(;i;){let c=se(new Uint8Array(131072)),a=0;for(;a<4096;){let d=t.slice(s,s+31);if(c.pushByte(0),c.pushBytes(d),d.length<31){c.pushByte(128),i=!1;break}a++,s+=31}n.push(c)}return r==="bytes"?n.map(c=>c.bytes):n.map(c=>B(c.bytes))}function Yr(e){let{data:r,kzg:t,to:o}=e,n=e.blobs??Jr({data:r,to:o}),i=e.commitments??ye({blobs:n,kzg:t,to:o}),s=e.proofs??be({blobs:n,commitments:i,kzg:t,to:o}),c=[];for(let a=0;a<n.length;a++)c.push({blob:n[a],commitment:i[a],proof:s[a]});return c}function Zr(e){if(e.type)return e.type;if(typeof e.authorizationList<"u")return"eip7702";if(typeof e.blobs<"u"||typeof e.blobVersionedHashes<"u"||typeof e.maxFeePerBlobGas<"u"||typeof e.sidecars<"u")return"eip4844";if(typeof e.maxFeePerGas<"u"||typeof e.maxPriorityFeePerGas<"u")return"eip1559";if(typeof e.gasPrice<"u")return typeof e.accessList<"u"?"eip2930":"legacy";throw new lr({transaction:e})}function Xr(e,{args:r,eventName:t}={}){return{...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,blockTimestamp:e.blockTimestamp?BigInt(e.blockTimestamp):e.blockTimestamp===null?null:void 0,logIndex:e.logIndex?Number(e.logIndex):null,transactionHash:e.transactionHash?e.transactionHash:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,...t?{args:r,eventName:t}:{}}}var Bt=new Map,St=new Map;function At(e){let r=(n,i)=>({clear:()=>i.delete(n),get:()=>i.get(n),set:s=>i.set(n,s)}),t=r(e,Bt),o=r(e,St);return{clear:()=>{t.clear(),o.clear()},promise:t,response:o}}async function ai(e,{cacheKey:r,cacheTime:t=Number.POSITIVE_INFINITY}){let o=At(r),n=o.response.get();if(n&&t>0&&Date.now()-n.created.getTime()<t)return n.data;let i=o.promise.get();i||(i=e(),o.promise.set(i));try{let s=await i;return o.response.set({created:new Date,data:s}),s}finally{o.promise.clear()}}function fi({chain:e,currentChainId:r}){if(!e)throw new Pr;if(r!==e.id)throw new vr({chain:e,currentChainId:r})}var Ct={"0x0":"reverted","0x1":"success"};function Rt(e,r){let t={...e,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,contractAddress:e.contractAddress?e.contractAddress:null,cumulativeGasUsed:e.cumulativeGasUsed?BigInt(e.cumulativeGasUsed):null,effectiveGasPrice:e.effectiveGasPrice?BigInt(e.effectiveGasPrice):null,gasUsed:e.gasUsed?BigInt(e.gasUsed):null,logs:e.logs?e.logs.map(o=>Xr(o)):null,to:e.to?e.to:null,transactionIndex:e.transactionIndex?F(e.transactionIndex):null,status:e.status?Ct[e.status]:null,type:e.type?Ze[e.type]||e.type:null};return e.blobGasPrice&&(t.blobGasPrice=BigInt(e.blobGasPrice)),e.blobGasUsed&&(t.blobGasUsed=BigInt(e.blobGasUsed)),t}var hi=O("transactionReceipt",Rt);function Qr(e){let{authorizationList:r}=e;if(r)for(let t of r){let{chainId:o}=t,n=t.address;if(!L(n))throw new H({address:n});if(o<0)throw new oe({chainId:o})}Ie(e)}function et(e){let{blobVersionedHashes:r}=e;if(r){if(r.length===0)throw new j;for(let t of r){let o=R(t),n=F(ir(t,0,1));if(o!==32)throw new Ee({hash:t,size:o});if(n!==1)throw new we({hash:t,version:n})}}Ie(e)}function Ie(e){let{chainId:r,maxPriorityFeePerGas:t,maxFeePerGas:o,to:n}=e;if(r<=0)throw new oe({chainId:r});if(n&&!L(n))throw new H({address:n});if(o&&o>fe)throw new me({maxFeePerGas:o});if(t&&o&&t>o)throw new Tr({maxFeePerGas:o,maxPriorityFeePerGas:t})}function rt(e){let{chainId:r,maxPriorityFeePerGas:t,gasPrice:o,maxFeePerGas:n,to:i}=e;if(r<=0)throw new oe({chainId:r});if(i&&!L(i))throw new H({address:i});if(t||n)throw new b("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");if(o&&o>fe)throw new me({maxFeePerGas:o})}function tt(e){let{chainId:r,maxPriorityFeePerGas:t,gasPrice:o,maxFeePerGas:n,to:i}=e;if(i&&!L(i))throw new H({address:i});if(typeof r<"u"&&r<=0)throw new oe({chainId:r});if(t||n)throw new b("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");if(o&&o>fe)throw new me({maxFeePerGas:o})}function ne(e){if(!e||e.length===0)return[];let r=[];for(let t=0;t<e.length;t++){let{address:o,storageKeys:n}=e[t];for(let i=0;i<n.length;i++)if(n[i].length-2!==64)throw new xr({storageKey:n[i]});if(!L(o,{strict:!1}))throw new H({address:o});r.push([o,n])}return r}function ji(e,r){let t=Zr(e);return t==="eip1559"?Ut(e,r):t==="eip2930"?Ht(e,r):t==="eip4844"?zt(e,r):t==="eip7702"?Ft(e,r):Lt(e,r)}function Ft(e,r){let{authorizationList:t,chainId:o,gas:n,nonce:i,to:s,value:c,maxFeePerGas:a,maxPriorityFeePerGas:d,accessList:f,data:l}=e;Qr(e);let u=ne(f),m=ot(t);return Z(["0x04",M([h(o),i?h(i):"0x",d?h(d):"0x",a?h(a):"0x",n?h(n):"0x",s??"0x",c?h(c):"0x",l??"0x",u,m,...K(e,r)])])}function zt(e,r){let{chainId:t,gas:o,nonce:n,to:i,value:s,maxFeePerBlobGas:c,maxFeePerGas:a,maxPriorityFeePerGas:d,accessList:f,data:l}=e;et(e);let u=e.blobVersionedHashes,m=e.sidecars;if(e.blobs&&(typeof u>"u"||typeof m>"u")){let y=typeof e.blobs[0]=="string"?e.blobs:e.blobs.map(T=>B(T)),I=e.kzg,g=ye({blobs:y,kzg:I});if(typeof u>"u"&&(u=Wr({commitments:g})),typeof m>"u"){let T=be({blobs:y,commitments:g,kzg:I});m=Yr({blobs:y,commitments:g,proofs:T})}}let E=ne(f),p=[h(t),n?h(n):"0x",d?h(d):"0x",a?h(a):"0x",o?h(o):"0x",i??"0x",s?h(s):"0x",l??"0x",E,c?h(c):"0x",u??[],...K(e,r)],x=[],w=[],v=[];if(m)for(let y=0;y<m.length;y++){let{blob:I,commitment:g,proof:T}=m[y];x.push(I),w.push(g),v.push(T)}return Z(["0x03",m?M([p,x,w,v]):M(p)])}function Ut(e,r){let{chainId:t,gas:o,nonce:n,to:i,value:s,maxFeePerGas:c,maxPriorityFeePerGas:a,accessList:d,data:f}=e;Ie(e);let l=ne(d),u=[h(t),n?h(n):"0x",a?h(a):"0x",c?h(c):"0x",o?h(o):"0x",i??"0x",s?h(s):"0x",f??"0x",l,...K(e,r)];return Z(["0x02",M(u)])}function Ht(e,r){let{chainId:t,gas:o,data:n,nonce:i,to:s,value:c,accessList:a,gasPrice:d}=e;rt(e);let f=ne(a),l=[h(t),i?h(i):"0x",d?h(d):"0x",o?h(o):"0x",s??"0x",c?h(c):"0x",n??"0x",f,...K(e,r)];return Z(["0x01",M(l)])}function Lt(e,r){let{chainId:t=0,gas:o,data:n,nonce:i,to:s,value:c,gasPrice:a}=e;tt(e);let d=[i?h(i):"0x",a?h(a):"0x",o?h(o):"0x",s??"0x",c?h(c):"0x",n??"0x"];if(r){let f=(()=>{if(r.v>=35n)return(r.v-35n)/2n>0?r.v:27n+(r.v===35n?0n:1n);if(t>0)return BigInt(t*2)+BigInt(35n+r.v-27n);let m=27n+(r.v===27n?0n:1n);if(r.v!==m)throw new dr({v:r.v});return m})(),l=Y(r.r),u=Y(r.s);d=[...d,h(f),l==="0x00"?"0x":l,u==="0x00"?"0x":u]}else t>0&&(d=[...d,h(t),"0x","0x"]);return M(d)}function K(e,r){let t=r??e,{v:o,yParity:n}=t;if(typeof t.r>"u")return[];if(typeof t.s>"u")return[];if(typeof o>"u"&&typeof n>"u")return[];let i=Y(t.r),s=Y(t.s);return[typeof n=="number"?n?h(1):"0x":o===0n?"0x":o===1n?h(1):o===27n?"0x":h(1),i==="0x00"?"0x":i,s==="0x00"?"0x":s]}function ot(e){if(!e||e.length===0)return[];let r=[];for(let t of e){let{chainId:o,nonce:n,...i}=t,s=t.address;r.push([o?z(o):"0x",s,n?z(n):"0x",...K({},i)])}return r}function Zi(e){let r={formatters:void 0,fees:void 0,serializers:void 0,...e};function t(o){return n=>{let i=typeof n=="function"?n(o):n,s={...o,...i};return Object.assign(s,{extend:t(s)})}}return Object.assign(r,{extend:t(r)})}var Te=class extends b{constructor({domain:r}){super(`Invalid domain "${C(r)}".`,{metaMessages:["Must be a valid EIP-712 domain."]})}},ve=class extends b{constructor({primaryType:r,types:t}){super(`Invalid primary type \`${r}\` must be one of \`${JSON.stringify(Object.keys(t))}\`.`,{docsPath:"/api/glossary/Errors#typeddatainvalidprimarytypeerror",metaMessages:["Check that the primary type is a key in `types`."]})}},Pe=class extends b{constructor({type:r}){super(`Struct type "${r}" is invalid.`,{metaMessages:["Struct type must not be a Solidity type."],name:"InvalidStructTypeError"})}},Be=class extends b{constructor({type:r}){let t=r.replace(/^(u?int)/,"$&256");super(`Type "${r}" is not a valid EIP-712 type.`,{metaMessages:[`Use "${t}" instead.`],name:"InvalidTypedDataTypeError"})}};function fs(e){let{domain:r,message:t,primaryType:o,types:n}=e,i=(a,d)=>{let f={...d};for(let l of a){let{name:u,type:m}=l;m==="address"&&(f[u]=f[u].toLowerCase())}return f},s=n.EIP712Domain?r?i(n.EIP712Domain,r):{}:{},c=(()=>{if(o!=="EIP712Domain")return i(n[o],t)})();return C({domain:s,message:c,primaryType:o,types:n})}function us(e){let{domain:r,message:t,primaryType:o,types:n}=e,i=(s,c)=>{for(let a of s){let{name:d,type:f}=a,l=c[d],u=f.replace(/(\[[0-9]*\])+$/,"");if(u==="int"||u==="uint")throw new Be({type:f});let m=f.match(ar);if(m&&(typeof l=="number"||typeof l=="bigint")){let[x,w,v]=m;h(l,{signed:w==="int",size:Number.parseInt(v,10)/8})}if(f==="address"&&typeof l=="string"&&!L(l))throw new H({address:l});let E=f.match(sr);if(E){let[x,w]=E;if(w&&R(l)!==Number.parseInt(w,10))throw new rr({expectedSize:Number.parseInt(w,10),givenSize:R(l)})}let p=n[f];p&&(Gt(f),i(p,l))}};if(n.EIP712Domain&&r){if(typeof r!="object")throw new Te({domain:r});i(n.EIP712Domain,r)}if(o!=="EIP712Domain")if(n[o])i(n[o],t);else throw new ve({primaryType:o,types:n})}function ps({domain:e}){return[typeof e?.name=="string"&&{name:"name",type:"string"},e?.version&&{name:"version",type:"string"},(typeof e?.chainId=="number"||typeof e?.chainId=="bigint")&&{name:"chainId",type:"uint256"},e?.verifyingContract&&{name:"verifyingContract",type:"address"},e?.salt&&{name:"salt",type:"bytes32"}].filter(Boolean)}function Gt(e){if(e==="address"||e==="bool"||e==="string"||e.startsWith("bytes")||e.startsWith("uint")||e.startsWith("int"))throw new Pe({type:e})}function Dt(e,r){return mr(e,r)}function kt(e,r){return fr(e,r)}export{Do as a,Yo as b,M as c,Mr as d,_r as e,qr as f,Vr as g,Or as h,Xe as i,hn as j,Tt as k,En as l,ye as m,be as n,Wr as o,Yr as p,Zr as q,xe as r,ai as s,fi as t,Cr as u,Rt as v,hi as w,st as x,ji as y,Zi as z,fs as A,us as B,ps as C,Dt as D,kt as E,mt as F,ft as G,bt as H};
@@ -1,10 +0,0 @@
1
- import{a as pt}from"./chunk-F7HZCPX2.js";import{A as Y,B as Vt,C as J,D as jt,E as z,F as D,G as _t,H as mt,I as $,J as be,K as ct,L as ye,M as F,N as Kt,f as le,g as de,h as ue,i as zt,l as he,p as me,q as we,r as ge,t as It,u as Mt,v as ut,w as ht,x as Et,y as qt,z as Pt}from"./chunk-EZRXHJOM.js";import"./chunk-MYQCVH5Z.js";var Nt=class extends ge{constructor(n,t){super(),this.finished=!1,this.destroyed=!1,ue(n);let r=me(t);if(this.iHash=n.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let i=this.blockLen,s=new Uint8Array(i);s.set(r.length>i?n.create().update(r).digest():r);for(let c=0;c<s.length;c++)s[c]^=54;this.iHash.update(s),this.oHash=n.create();for(let c=0;c<s.length;c++)s[c]^=106;this.oHash.update(s),he(s)}update(n){return zt(this),this.iHash.update(n),this}digestInto(n){zt(this),de(n,this.outputLen),this.finished=!0,this.iHash.digestInto(n),this.oHash.update(n),this.oHash.digestInto(n),this.destroy()}digest(){let n=new Uint8Array(this.oHash.outputLen);return this.digestInto(n),n}_cloneInto(n){n||(n=Object.create(Object.getPrototypeOf(this),{}));let{oHash:t,iHash:r,finished:i,destroyed:s,blockLen:c,outputLen:a}=this;return n=n,n.finished=i,n.destroyed=s,n.blockLen=c,n.outputLen=a,n.oHash=t._cloneInto(n.oHash),n.iHash=r._cloneInto(n.iHash),n}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Yt=(e,n,t)=>new Nt(e,n).update(t).digest();Yt.create=(e,n)=>new Nt(e,n);var j=BigInt(0),P=BigInt(1),ft=BigInt(2),De=BigInt(3),Ee=BigInt(4),xe=BigInt(5),ve=BigInt(8);function U(e,n){let t=e%n;return t>=j?t:n+t}function W(e,n,t){let r=e;for(;n-- >j;)r*=r,r%=t;return r}function Rt(e,n){if(e===j)throw new Error("invert: expected non-zero number");if(n<=j)throw new Error("invert: expected positive modulus, got "+n);let t=U(e,n),r=n,i=j,s=P,c=P,a=j;for(;t!==j;){let l=r/t,u=r%t,p=i-c*l,x=s-a*l;r=t,t=u,i=c,s=a,c=p,a=x}if(r!==P)throw new Error("invert: does not exist");return U(i,n)}function Be(e,n){let t=(e.ORDER+P)/Ee,r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw new Error("Cannot find square root");return r}function We(e,n){let t=(e.ORDER-xe)/ve,r=e.mul(n,ft),i=e.pow(r,t),s=e.mul(n,i),c=e.mul(e.mul(s,ft),i),a=e.mul(s,e.sub(c,e.ONE));if(!e.eql(e.sqr(a),n))throw new Error("Cannot find square root");return a}function Ge(e){if(e<BigInt(3))throw new Error("sqrt is not defined for small field");let n=e-P,t=0;for(;n%ft===j;)n/=ft,t++;let r=ft,i=xt(e);for(;pe(i,r)===1;)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(t===1)return Be;let s=i.pow(r,n),c=(n+P)/ft;return function(o,l){if(o.is0(l))return l;if(pe(o,l)!==1)throw new Error("Cannot find square root");let u=t,p=o.mul(o.ONE,s),x=o.pow(l,n),v=o.pow(l,c);for(;!o.eql(x,o.ONE);){if(o.is0(x))return o.ZERO;let N=1,w=o.sqr(x);for(;!o.eql(w,o.ONE);)if(N++,w=o.sqr(w),N===u)throw new Error("Cannot find square root");let H=P<<BigInt(u-N-1),A=o.pow(p,H);u=N,p=o.sqr(A),x=o.mul(x,p),v=o.mul(v,A)}return v}}function Xe(e){return e%Ee===De?Be:e%ve===xe?We:Ge(e)}var Qe=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Tt(e){let n={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=Qe.reduce((r,i)=>(r[i]="function",r),n);return F(e,t)}function Je(e,n,t){if(t<j)throw new Error("invalid exponent, negatives unsupported");if(t===j)return e.ONE;if(t===P)return n;let r=e.ONE,i=n;for(;t>j;)t&P&&(r=e.mul(r,i)),i=e.sqr(i),t>>=P;return r}function wt(e,n,t=!1){let r=new Array(n.length).fill(t?e.ZERO:void 0),i=n.reduce((c,a,o)=>e.is0(a)?c:(r[o]=c,e.mul(c,a)),e.ONE),s=e.inv(i);return n.reduceRight((c,a,o)=>e.is0(a)?c:(r[o]=e.mul(c,r[o]),e.mul(c,a)),s),r}function pe(e,n){let t=(e.ORDER-P)/ft,r=e.pow(n,t),i=e.eql(r,e.ONE),s=e.eql(r,e.ZERO),c=e.eql(r,e.neg(e.ONE));if(!i&&!s&&!c)throw new Error("invalid Legendre symbol result");return i?1:s?0:-1}function Dt(e,n){n!==void 0&&le(n);let t=n!==void 0?n:e.toString(2).length,r=Math.ceil(t/8);return{nBitLength:t,nByteLength:r}}function xt(e,n,t=!1,r={}){if(e<=j)throw new Error("invalid field: expected ORDER > 0, got "+e);let{nBitLength:i,nByteLength:s}=Dt(e,n);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let c,a=Object.freeze({ORDER:e,isLE:t,BITS:i,BYTES:s,MASK:ct(i),ZERO:j,ONE:P,create:o=>U(o,e),isValid:o=>{if(typeof o!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof o);return j<=o&&o<e},is0:o=>o===j,isOdd:o=>(o&P)===P,neg:o=>U(-o,e),eql:(o,l)=>o===l,sqr:o=>U(o*o,e),add:(o,l)=>U(o+l,e),sub:(o,l)=>U(o-l,e),mul:(o,l)=>U(o*l,e),pow:(o,l)=>Je(a,o,l),div:(o,l)=>U(o*Rt(l,e),e),sqrN:o=>o*o,addN:(o,l)=>o+l,subN:(o,l)=>o-l,mulN:(o,l)=>o*l,inv:o=>Rt(o,e),sqrt:r.sqrt||(o=>(c||(c=Xe(e)),c(a,o))),toBytes:o=>t?jt(o,s):J(o,s),fromBytes:o=>{if(o.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+o.length);return t?Vt(o):Y(o)},invertBatch:o=>wt(a,o),cmov:(o,l,u)=>u?l:o});return Object.freeze(a)}function Se(e){if(typeof e!="bigint")throw new Error("field order must be bigint");let n=e.toString(2).length;return Math.ceil(n/8)}function Wt(e){let n=Se(e);return n+Math.ceil(n/2)}function Oe(e,n,t=!1){let r=e.length,i=Se(n),s=Wt(n);if(r<16||r<s||r>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+r);let c=t?Vt(e):Y(e),a=U(c,n-P)+P;return t?jt(a,i):J(a,i)}var Ae=BigInt(0),$t=BigInt(1);function Gt(e,n){let t=n.negate();return e?t:n}function qe(e,n){if(!Number.isSafeInteger(e)||e<=0||e>n)throw new Error("invalid window size, expected [1.."+n+"], got W="+e)}function Xt(e,n){qe(e,n);let t=Math.ceil(n/e)+1,r=2**(e-1),i=2**e,s=ct(e),c=BigInt(e);return{windows:t,windowSize:r,mask:s,maxNumber:i,shiftBy:c}}function Ie(e,n,t){let{windowSize:r,mask:i,maxNumber:s,shiftBy:c}=t,a=Number(e&i),o=e>>c;a>r&&(a-=s,o+=$t);let l=n*r,u=l+Math.abs(a)-1,p=a===0,x=a<0,v=n%2!==0;return{nextN:o,offset:u,isZero:p,isNeg:x,isNegF:v,offsetF:l}}function $e(e,n){if(!Array.isArray(e))throw new Error("array expected");e.forEach((t,r)=>{if(!(t instanceof n))throw new Error("invalid point at index "+r)})}function Fe(e,n){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((t,r)=>{if(!n.isValid(t))throw new Error("invalid scalar at index "+r)})}var Qt=new WeakMap,_e=new WeakMap;function Jt(e){return _e.get(e)||1}function Ne(e,n){return{constTimeNegate:Gt,hasPrecomputes(t){return Jt(t)!==1},unsafeLadder(t,r,i=e.ZERO){let s=t;for(;r>Ae;)r&$t&&(i=i.add(s)),s=s.double(),r>>=$t;return i},precomputeWindow(t,r){let{windows:i,windowSize:s}=Xt(r,n),c=[],a=t,o=a;for(let l=0;l<i;l++){o=a,c.push(o);for(let u=1;u<s;u++)o=o.add(a),c.push(o);a=o.double()}return c},wNAF(t,r,i){let s=e.ZERO,c=e.BASE,a=Xt(t,n);for(let o=0;o<a.windows;o++){let{nextN:l,offset:u,isZero:p,isNeg:x,isNegF:v,offsetF:N}=Ie(i,o,a);i=l,p?c=c.add(Gt(v,r[N])):s=s.add(Gt(x,r[u]))}return{p:s,f:c}},wNAFUnsafe(t,r,i,s=e.ZERO){let c=Xt(t,n);for(let a=0;a<c.windows&&i!==Ae;a++){let{nextN:o,offset:l,isZero:u,isNeg:p}=Ie(i,a,c);if(i=o,!u){let x=r[l];s=s.add(p?x.negate():x)}}return s},getPrecomputes(t,r,i){let s=Qt.get(r);return s||(s=this.precomputeWindow(r,t),t!==1&&Qt.set(r,i(s))),s},wNAFCached(t,r,i){let s=Jt(t);return this.wNAF(s,this.getPrecomputes(s,t,i),r)},wNAFCachedUnsafe(t,r,i,s){let c=Jt(t);return c===1?this.unsafeLadder(t,r,s):this.wNAFUnsafe(c,this.getPrecomputes(c,t,i),r,s)},setWindowSize(t,r){qe(r,n),_e.set(t,r),Qt.delete(t)}}}function Re(e,n,t,r){$e(t,e),Fe(r,n);let i=t.length,s=r.length;if(i!==s)throw new Error("arrays of points and scalars must have equal length");let c=e.ZERO,a=be(BigInt(i)),o=1;a>12?o=a-3:a>4?o=a-2:a>0&&(o=2);let l=ct(o),u=new Array(Number(l)+1).fill(c),p=Math.floor((n.BITS-1)/o)*o,x=c;for(let v=p;v>=0;v-=o){u.fill(c);for(let w=0;w<s;w++){let H=r[w],A=Number(H>>BigInt(v)&l);u[A]=u[A].add(t[w])}let N=c;for(let w=u.length-1,H=c;w>0;w--)H=H.add(u[w]),N=N.add(H);if(x=x.add(N),v!==0)for(let w=0;w<o;w++)x=x.double()}return x}function Ft(e){return Tt(e.Fp),F(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Dt(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}function Te(e){e.lowS!==void 0&&ht("lowS",e.lowS),e.prehash!==void 0&&ht("prehash",e.prehash)}function tn(e){let n=Ft(e);F(n,{a:"field",b:"field"},{allowInfinityPoint:"boolean",allowedPrivateKeyLengths:"array",clearCofactor:"function",fromBytes:"function",isTorsionFree:"function",toBytes:"function",wrapPrivateKey:"boolean"});let{endo:t,Fp:r,a:i}=n;if(t){if(!r.eql(i,r.ZERO))throw new Error("invalid endo: CURVE.a must be 0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function')}return Object.freeze({...n})}var ee=class extends Error{constructor(n=""){super(n)}},tt={Err:ee,_tlv:{encode:(e,n)=>{let{Err:t}=tt;if(e<0||e>256)throw new t("tlv.encode: wrong tag");if(n.length&1)throw new t("tlv.encode: unpadded data");let r=n.length/2,i=Et(r);if(i.length/2&128)throw new t("tlv.encode: long form length too big");let s=r>127?Et(i.length/2|128):"";return Et(e)+s+i+n},decode(e,n){let{Err:t}=tt,r=0;if(e<0||e>256)throw new t("tlv.encode: wrong tag");if(n.length<2||n[r++]!==e)throw new t("tlv.decode: wrong tlv");let i=n[r++],s=!!(i&128),c=0;if(!s)c=i;else{let o=i&127;if(!o)throw new t("tlv.decode(long): indefinite length not supported");if(o>4)throw new t("tlv.decode(long): byte length is too big");let l=n.subarray(r,r+o);if(l.length!==o)throw new t("tlv.decode: length bytes not complete");if(l[0]===0)throw new t("tlv.decode(long): zero leftmost byte");for(let u of l)c=c<<8|u;if(r+=o,c<128)throw new t("tlv.decode(long): not minimal encoding")}let a=n.subarray(r,r+c);if(a.length!==c)throw new t("tlv.decode: wrong value length");return{v:a,l:n.subarray(r+c)}}},_int:{encode(e){let{Err:n}=tt;if(e<X)throw new n("integer: negative integers are not allowed");let t=Et(e);if(Number.parseInt(t[0],16)&8&&(t="00"+t),t.length&1)throw new n("unexpected DER parsing assertion: unpadded hex");return t},decode(e){let{Err:n}=tt;if(e[0]&128)throw new n("invalid signature integer: negative");if(e[0]===0&&!(e[1]&128))throw new n("invalid signature integer: unnecessary leading zero");return Y(e)}},toSig(e){let{Err:n,_int:t,_tlv:r}=tt,i=z("signature",e),{v:s,l:c}=r.decode(48,i);if(c.length)throw new n("invalid signature: left bytes after parsing");let{v:a,l:o}=r.decode(2,s),{v:l,l:u}=r.decode(2,o);if(u.length)throw new n("invalid signature: left bytes after parsing");return{r:t.decode(a),s:t.decode(l)}},hexFromSig(e){let{_tlv:n,_int:t}=tt,r=n.encode(2,t.encode(e.r)),i=n.encode(2,t.encode(e.s)),s=r+i;return n.encode(48,s)}};function te(e,n){return qt(J(e,n))}var X=BigInt(0),k=BigInt(1),nt=BigInt(2),vt=BigInt(3),ne=BigInt(4);function en(e){let n=tn(e),{Fp:t}=n,r=xt(n.n,n.nBitLength),i=n.toBytes||((g,f,m)=>{let b=f.toAffine();return D(Uint8Array.from([4]),t.toBytes(b.x),t.toBytes(b.y))}),s=n.fromBytes||(g=>{let f=g.subarray(1),m=t.fromBytes(f.subarray(0,t.BYTES)),b=t.fromBytes(f.subarray(t.BYTES,2*t.BYTES));return{x:m,y:b}});function c(g){let{a:f,b:m}=n,b=t.sqr(g),E=t.mul(b,g);return t.add(t.add(E,t.mul(g,f)),m)}function a(g,f){let m=t.sqr(f),b=c(g);return t.eql(m,b)}if(!a(n.Gx,n.Gy))throw new Error("bad curve params: generator point");let o=t.mul(t.pow(n.a,vt),ne),l=t.mul(t.sqr(n.b),BigInt(27));if(t.is0(t.add(o,l)))throw new Error("bad curve params: a or b");function u(g){return mt(g,k,n.n)}function p(g){let{allowedPrivateKeyLengths:f,nByteLength:m,wrapPrivateKey:b,n:E}=n;if(f&&typeof g!="bigint"){if(Mt(g)&&(g=qt(g)),typeof g!="string"||!f.includes(g.length))throw new Error("invalid private key");g=g.padStart(m*2,"0")}let I;try{I=typeof g=="bigint"?g:Y(z("private key",g,m))}catch{throw new Error("invalid private key, expected hex or "+m+" bytes, got "+typeof g)}return b&&(I=U(I,E)),$("private key",I,k,E),I}function x(g){if(!(g instanceof w))throw new Error("ProjectivePoint expected")}let v=Kt((g,f)=>{let{px:m,py:b,pz:E}=g;if(t.eql(E,t.ONE))return{x:m,y:b};let I=g.is0();f==null&&(f=I?t.ONE:t.inv(E));let L=t.mul(m,f),Z=t.mul(b,f),B=t.mul(E,f);if(I)return{x:t.ZERO,y:t.ZERO};if(!t.eql(B,t.ONE))throw new Error("invZ was invalid");return{x:L,y:Z}}),N=Kt(g=>{if(g.is0()){if(n.allowInfinityPoint&&!t.is0(g.py))return;throw new Error("bad point: ZERO")}let{x:f,y:m}=g.toAffine();if(!t.isValid(f)||!t.isValid(m))throw new Error("bad point: x or y not FE");if(!a(f,m))throw new Error("bad point: equation left != right");if(!g.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class w{constructor(f,m,b){if(f==null||!t.isValid(f))throw new Error("x required");if(m==null||!t.isValid(m)||t.is0(m))throw new Error("y required");if(b==null||!t.isValid(b))throw new Error("z required");this.px=f,this.py=m,this.pz=b,Object.freeze(this)}static fromAffine(f){let{x:m,y:b}=f||{};if(!f||!t.isValid(m)||!t.isValid(b))throw new Error("invalid affine point");if(f instanceof w)throw new Error("projective point not allowed");let E=I=>t.eql(I,t.ZERO);return E(m)&&E(b)?w.ZERO:new w(m,b,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(f){let m=wt(t,f.map(b=>b.pz));return f.map((b,E)=>b.toAffine(m[E])).map(w.fromAffine)}static fromHex(f){let m=w.fromAffine(s(z("pointHex",f)));return m.assertValidity(),m}static fromPrivateKey(f){return w.BASE.multiply(p(f))}static msm(f,m){return Re(w,r,f,m)}_setWindowSize(f){T.setWindowSize(this,f)}assertValidity(){N(this)}hasEvenY(){let{y:f}=this.toAffine();if(t.isOdd)return!t.isOdd(f);throw new Error("Field doesn't support isOdd")}equals(f){x(f);let{px:m,py:b,pz:E}=this,{px:I,py:L,pz:Z}=f,B=t.eql(t.mul(m,Z),t.mul(I,E)),R=t.eql(t.mul(b,Z),t.mul(L,E));return B&&R}negate(){return new w(this.px,t.neg(this.py),this.pz)}double(){let{a:f,b:m}=n,b=t.mul(m,vt),{px:E,py:I,pz:L}=this,Z=t.ZERO,B=t.ZERO,R=t.ZERO,S=t.mul(E,E),M=t.mul(I,I),h=t.mul(L,L),d=t.mul(E,I);return d=t.add(d,d),R=t.mul(E,L),R=t.add(R,R),Z=t.mul(f,R),B=t.mul(b,h),B=t.add(Z,B),Z=t.sub(M,B),B=t.add(M,B),B=t.mul(Z,B),Z=t.mul(d,Z),R=t.mul(b,R),h=t.mul(f,h),d=t.sub(S,h),d=t.mul(f,d),d=t.add(d,R),R=t.add(S,S),S=t.add(R,S),S=t.add(S,h),S=t.mul(S,d),B=t.add(B,S),h=t.mul(I,L),h=t.add(h,h),S=t.mul(h,d),Z=t.sub(Z,S),R=t.mul(h,M),R=t.add(R,R),R=t.add(R,R),new w(Z,B,R)}add(f){x(f);let{px:m,py:b,pz:E}=this,{px:I,py:L,pz:Z}=f,B=t.ZERO,R=t.ZERO,S=t.ZERO,M=n.a,h=t.mul(n.b,vt),d=t.mul(m,I),y=t.mul(b,L),_=t.mul(E,Z),O=t.add(m,b),q=t.add(I,L);O=t.mul(O,q),q=t.add(d,y),O=t.sub(O,q),q=t.add(m,E);let C=t.add(I,Z);return q=t.mul(q,C),C=t.add(d,_),q=t.sub(q,C),C=t.add(b,E),B=t.add(L,Z),C=t.mul(C,B),B=t.add(y,_),C=t.sub(C,B),S=t.mul(M,q),B=t.mul(h,_),S=t.add(B,S),B=t.sub(y,S),S=t.add(y,S),R=t.mul(B,S),y=t.add(d,d),y=t.add(y,d),_=t.mul(M,_),q=t.mul(h,q),y=t.add(y,_),_=t.sub(d,_),_=t.mul(M,_),q=t.add(q,_),d=t.mul(y,q),R=t.add(R,d),d=t.mul(C,q),B=t.mul(O,B),B=t.sub(B,d),d=t.mul(O,y),S=t.mul(C,S),S=t.add(S,d),new w(B,R,S)}subtract(f){return this.add(f.negate())}is0(){return this.equals(w.ZERO)}wNAF(f){return T.wNAFCached(this,f,w.normalizeZ)}multiplyUnsafe(f){let{endo:m,n:b}=n;$("scalar",f,X,b);let E=w.ZERO;if(f===X)return E;if(this.is0()||f===k)return this;if(!m||T.hasPrecomputes(this))return T.wNAFCachedUnsafe(this,f,w.normalizeZ);let{k1neg:I,k1:L,k2neg:Z,k2:B}=m.splitScalar(f),R=E,S=E,M=this;for(;L>X||B>X;)L&k&&(R=R.add(M)),B&k&&(S=S.add(M)),M=M.double(),L>>=k,B>>=k;return I&&(R=R.negate()),Z&&(S=S.negate()),S=new w(t.mul(S.px,m.beta),S.py,S.pz),R.add(S)}multiply(f){let{endo:m,n:b}=n;$("scalar",f,k,b);let E,I;if(m){let{k1neg:L,k1:Z,k2neg:B,k2:R}=m.splitScalar(f),{p:S,f:M}=this.wNAF(Z),{p:h,f:d}=this.wNAF(R);S=T.constTimeNegate(L,S),h=T.constTimeNegate(B,h),h=new w(t.mul(h.px,m.beta),h.py,h.pz),E=S.add(h),I=M.add(d)}else{let{p:L,f:Z}=this.wNAF(f);E=L,I=Z}return w.normalizeZ([E,I])[0]}multiplyAndAddUnsafe(f,m,b){let E=w.BASE,I=(Z,B)=>B===X||B===k||!Z.equals(E)?Z.multiplyUnsafe(B):Z.multiply(B),L=I(this,m).add(I(f,b));return L.is0()?void 0:L}toAffine(f){return v(this,f)}isTorsionFree(){let{h:f,isTorsionFree:m}=n;if(f===k)return!0;if(m)return m(w,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:f,clearCofactor:m}=n;return f===k?this:m?m(w,this):this.multiplyUnsafe(n.h)}toRawBytes(f=!0){return ht("isCompressed",f),this.assertValidity(),i(w,this,f)}toHex(f=!0){return ht("isCompressed",f),qt(this.toRawBytes(f))}}w.BASE=new w(n.Gx,n.Gy,t.ONE),w.ZERO=new w(t.ZERO,t.ONE,t.ZERO);let{endo:H,nBitLength:A}=n,T=Ne(w,H?Math.ceil(A/2):A);return{CURVE:n,ProjectivePoint:w,normPrivateKeyToScalar:p,weierstrassEquation:c,isWithinCurveOrder:u}}function nn(e){let n=Ft(e);return F(n,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...n})}function Le(e){let n=nn(e),{Fp:t,n:r,nByteLength:i,nBitLength:s}=n,c=t.BYTES+1,a=2*t.BYTES+1;function o(h){return U(h,r)}function l(h){return Rt(h,r)}let{ProjectivePoint:u,normPrivateKeyToScalar:p,weierstrassEquation:x,isWithinCurveOrder:v}=en({...n,toBytes(h,d,y){let _=d.toAffine(),O=t.toBytes(_.x),q=D;return ht("isCompressed",y),y?q(Uint8Array.from([d.hasEvenY()?2:3]),O):q(Uint8Array.from([4]),O,t.toBytes(_.y))},fromBytes(h){let d=h.length,y=h[0],_=h.subarray(1);if(d===c&&(y===2||y===3)){let O=Y(_);if(!mt(O,k,t.ORDER))throw new Error("Point is not on curve");let q=x(O),C;try{C=t.sqrt(q)}catch(G){let K=G instanceof Error?": "+G.message:"";throw new Error("Point is not on curve"+K)}let V=(C&k)===k;return(y&1)===1!==V&&(C=t.neg(C)),{x:O,y:C}}else if(d===a&&y===4){let O=t.fromBytes(_.subarray(0,t.BYTES)),q=t.fromBytes(_.subarray(t.BYTES,2*t.BYTES));return{x:O,y:q}}else{let O=c,q=a;throw new Error("invalid Point, expected length of "+O+", or uncompressed "+q+", got "+d)}}});function N(h){let d=r>>k;return h>d}function w(h){return N(h)?o(-h):h}let H=(h,d,y)=>Y(h.slice(d,y));class A{constructor(d,y,_){$("r",d,k,r),$("s",y,k,r),this.r=d,this.s=y,_!=null&&(this.recovery=_),Object.freeze(this)}static fromCompact(d){let y=i;return d=z("compactSignature",d,y*2),new A(H(d,0,y),H(d,y,2*y))}static fromDER(d){let{r:y,s:_}=tt.toSig(z("DER",d));return new A(y,_)}assertValidity(){}addRecoveryBit(d){return new A(this.r,this.s,d)}recoverPublicKey(d){let{r:y,s:_,recovery:O}=this,q=E(z("msgHash",d));if(O==null||![0,1,2,3].includes(O))throw new Error("recovery id invalid");let C=O===2||O===3?y+n.n:y;if(C>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");let V=(O&1)===0?"02":"03",Q=u.fromHex(V+te(C,t.BYTES)),G=l(C),K=o(-q*G),at=o(_*G),et=u.BASE.multiplyAndAddUnsafe(Q,K,at);if(!et)throw new Error("point at infinify");return et.assertValidity(),et}hasHighS(){return N(this.s)}normalizeS(){return this.hasHighS()?new A(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return Pt(this.toDERHex())}toDERHex(){return tt.hexFromSig(this)}toCompactRawBytes(){return Pt(this.toCompactHex())}toCompactHex(){let d=i;return te(this.r,d)+te(this.s,d)}}let T={isValidPrivateKey(h){try{return p(h),!0}catch{return!1}},normPrivateKeyToScalar:p,randomPrivateKey:()=>{let h=Wt(n.n);return Oe(n.randomBytes(h),n.n)},precompute(h=8,d=u.BASE){return d._setWindowSize(h),d.multiply(BigInt(3)),d}};function g(h,d=!0){return u.fromPrivateKey(h).toRawBytes(d)}function f(h){if(typeof h=="bigint")return!1;if(h instanceof u)return!0;let y=z("key",h).length,_=t.BYTES,O=_+1,q=2*_+1;if(!(n.allowedPrivateKeyLengths||i===O))return y===O||y===q}function m(h,d,y=!0){if(f(h)===!0)throw new Error("first arg must be private key");if(f(d)===!1)throw new Error("second arg must be public key");return u.fromHex(d).multiply(p(h)).toRawBytes(y)}let b=n.bits2int||function(h){if(h.length>8192)throw new Error("input is too large");let d=Y(h),y=h.length*8-s;return y>0?d>>BigInt(y):d},E=n.bits2int_modN||function(h){return o(b(h))},I=ct(s);function L(h){return $("num < 2^"+s,h,X,I),J(h,i)}function Z(h,d,y=B){if(["recovered","canonical"].some(st=>st in y))throw new Error("sign() legacy options not supported");let{hash:_,randomBytes:O}=n,{lowS:q,prehash:C,extraEntropy:V}=y;q==null&&(q=!0),h=z("msgHash",h),Te(y),C&&(h=z("prehashed msgHash",_(h)));let Q=E(h),G=p(d),K=[L(G),L(Q)];if(V!=null&&V!==!1){let st=V===!0?O(t.BYTES):V;K.push(z("extraEntropy",st))}let at=D(...K),et=Q;function Ct(st){let lt=b(st);if(!v(lt))return;let Ut=l(lt),bt=u.BASE.multiply(lt).toAffine(),it=o(bt.x);if(it===X)return;let yt=o(Ut*o(et+it*G));if(yt===X)return;let dt=(bt.x===it?0:2)|Number(bt.y&k),ae=yt;return q&&N(yt)&&(ae=w(yt),dt^=1),new A(it,ae,dt)}return{seed:at,k2sig:Ct}}let B={lowS:n.lowS,prehash:!1},R={lowS:n.lowS,prehash:!1};function S(h,d,y=B){let{seed:_,k2sig:O}=Z(h,d,y),q=n;return ye(q.hash.outputLen,q.nByteLength,q.hmac)(_,O)}u.BASE._setWindowSize(8);function M(h,d,y,_=R){let O=h;d=z("msgHash",d),y=z("publicKey",y);let{lowS:q,prehash:C,format:V}=_;if(Te(_),"strict"in _)throw new Error("options.strict was renamed to lowS");if(V!==void 0&&V!=="compact"&&V!=="der")throw new Error("format must be compact or der");let Q=typeof O=="string"||Mt(O),G=!Q&&!V&&typeof O=="object"&&O!==null&&typeof O.r=="bigint"&&typeof O.s=="bigint";if(!Q&&!G)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let K,at;try{if(G&&(K=new A(O.r,O.s)),Q){try{V!=="compact"&&(K=A.fromDER(O))}catch(dt){if(!(dt instanceof tt.Err))throw dt}!K&&V!=="der"&&(K=A.fromCompact(O))}at=u.fromHex(y)}catch{return!1}if(!K||q&&K.hasHighS())return!1;C&&(d=n.hash(d));let{r:et,s:Ct}=K,st=E(d),lt=l(Ct),Ut=o(st*lt),bt=o(et*lt),it=u.BASE.multiplyAndAddUnsafe(at,Ut,bt)?.toAffine();return it?o(it.x)===et:!1}return{CURVE:n,getPublicKey:g,getSharedSecret:m,sign:S,verify:M,ProjectivePoint:u,Signature:A,utils:T}}function rn(e,n){let t=e.ORDER,r=X;for(let N=t-k;N%nt===X;N/=nt)r+=k;let i=r,s=nt<<i-k-k,c=s*nt,a=(t-k)/c,o=(a-k)/nt,l=c-k,u=s,p=e.pow(n,a),x=e.pow(n,(a+k)/nt),v=(N,w)=>{let H=p,A=e.pow(w,l),T=e.sqr(A);T=e.mul(T,w);let g=e.mul(N,T);g=e.pow(g,o),g=e.mul(g,A),A=e.mul(g,w),T=e.mul(g,N);let f=e.mul(T,A);g=e.pow(f,u);let m=e.eql(g,e.ONE);A=e.mul(T,x),g=e.mul(f,H),T=e.cmov(A,T,m),f=e.cmov(g,f,m);for(let b=i;b>k;b--){let E=b-nt;E=nt<<E-k;let I=e.pow(f,E),L=e.eql(I,e.ONE);A=e.mul(T,H),H=e.mul(H,H),I=e.mul(f,H),T=e.cmov(A,T,L),f=e.cmov(I,f,L)}return{isValid:m,value:T}};if(e.ORDER%ne===vt){let N=(e.ORDER-vt)/ne,w=e.sqrt(e.neg(n));v=(H,A)=>{let T=e.sqr(A),g=e.mul(H,A);T=e.mul(T,g);let f=e.pow(T,N);f=e.mul(f,g);let m=e.mul(f,w),b=e.mul(e.sqr(f),A),E=e.eql(b,H),I=e.cmov(m,f,E);return{isValid:E,value:I}}}return v}function Ze(e,n){if(Tt(e),!e.isValid(n.A)||!e.isValid(n.B)||!e.isValid(n.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");let t=rn(e,n.Z);if(!e.isOdd)throw new Error("Fp.isOdd is not implemented!");return r=>{let i,s,c,a,o,l,u,p;i=e.sqr(r),i=e.mul(i,n.Z),s=e.sqr(i),s=e.add(s,i),c=e.add(s,e.ONE),c=e.mul(c,n.B),a=e.cmov(n.Z,e.neg(s),!e.eql(s,e.ZERO)),a=e.mul(a,n.A),s=e.sqr(c),l=e.sqr(a),o=e.mul(l,n.A),s=e.add(s,o),s=e.mul(s,c),l=e.mul(l,a),o=e.mul(l,n.B),s=e.add(s,o),u=e.mul(i,c);let{isValid:x,value:v}=t(s,l);p=e.mul(i,r),p=e.mul(p,v),u=e.cmov(u,c,x),p=e.cmov(p,v,x);let N=e.isOdd(r)===e.isOdd(p);p=e.cmov(e.neg(p),p,N);let w=wt(e,[a],!0)[0];return u=e.mul(u,w),{x:u,y:p}}}function on(e){return{hash:e,hmac:(n,...t)=>Yt(e,n,we(...t)),randomBytes:It}}function He(e,n){let t=r=>Le({...e,...on(r)});return{...t(n),create:t}}var sn=Y;function rt(e,n){if(Bt(e),Bt(n),e<0||e>=1<<8*n)throw new Error("invalid I2OSP input: "+e);let t=Array.from({length:n}).fill(0);for(let r=n-1;r>=0;r--)t[r]=e&255,e>>>=8;return new Uint8Array(t)}function cn(e,n){let t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e[r]^n[r];return t}function Bt(e){if(!Number.isSafeInteger(e))throw new Error("number expected")}function fn(e,n,t,r){ut(e),ut(n),Bt(t),n.length>255&&(n=r(D(_t("H2C-OVERSIZE-DST-"),n)));let{outputLen:i,blockLen:s}=r,c=Math.ceil(t/i);if(t>65535||c>255)throw new Error("expand_message_xmd: invalid lenInBytes");let a=D(n,rt(n.length,1)),o=rt(0,s),l=rt(t,2),u=new Array(c),p=r(D(o,e,l,rt(0,1),a));u[0]=r(D(p,rt(1,1),a));for(let v=1;v<=c;v++){let N=[cn(p,u[v-1]),rt(v+1,1),a];u[v]=r(D(...N))}return D(...u).slice(0,t)}function an(e,n,t,r,i){if(ut(e),ut(n),Bt(t),n.length>255){let s=Math.ceil(2*r/8);n=i.create({dkLen:s}).update(_t("H2C-OVERSIZE-DST-")).update(n).digest()}if(t>65535||n.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return i.create({dkLen:t}).update(e).update(rt(t,2)).update(n).update(rt(n.length,1)).digest()}function ke(e,n,t){F(t,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});let{p:r,k:i,m:s,hash:c,expand:a,DST:o}=t;ut(e),Bt(n);let l=typeof o=="string"?_t(o):o,u=r.toString(2).length,p=Math.ceil((u+i)/8),x=n*s*p,v;if(a==="xmd")v=fn(e,l,x,c);else if(a==="xof")v=an(e,l,x,i,c);else if(a==="_internal_pass")v=e;else throw new Error('expand must be "xmd" or "xof"');let N=new Array(n);for(let w=0;w<n;w++){let H=new Array(s);for(let A=0;A<s;A++){let T=p*(A+w*s),g=v.subarray(T,T+p);H[A]=U(sn(g),r)}N[w]=H}return N}function Ce(e,n){let t=n.map(r=>Array.from(r).reverse());return(r,i)=>{let[s,c,a,o]=t.map(p=>p.reduce((x,v)=>e.add(e.mul(x,r),v))),[l,u]=wt(e,[c,o],!0);return r=e.mul(s,l),i=e.mul(i,e.mul(a,u)),{x:r,y:i}}}function Ue(e,n,t){if(typeof n!="function")throw new Error("mapToCurve() must be defined");function r(s){return e.fromAffine(n(s))}function i(s){let c=s.clearCofactor();return c.equals(e.ZERO)?e.ZERO:(c.assertValidity(),c)}return{defaults:t,hashToCurve(s,c){let a=ke(s,2,{...t,DST:t.DST,...c}),o=r(a[0]),l=r(a[1]);return i(o.add(l))},encodeToCurve(s,c){let a=ke(s,1,{...t,DST:t.encodeDST,...c});return i(r(a[0]))},mapToCurve(s){if(!Array.isArray(s))throw new Error("expected array of bigints");for(let c of s)if(typeof c!="bigint")throw new Error("expected array of bigints");return i(r(s))}}}var At=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Lt=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),ie=BigInt(0),St=BigInt(1),Zt=BigInt(2),ze=(e,n)=>(e+n/Zt)/n;function Pe(e){let n=At,t=BigInt(3),r=BigInt(6),i=BigInt(11),s=BigInt(22),c=BigInt(23),a=BigInt(44),o=BigInt(88),l=e*e*e%n,u=l*l*e%n,p=W(u,t,n)*u%n,x=W(p,t,n)*u%n,v=W(x,Zt,n)*l%n,N=W(v,i,n)*v%n,w=W(N,s,n)*N%n,H=W(w,a,n)*w%n,A=W(H,o,n)*H%n,T=W(A,a,n)*w%n,g=W(T,t,n)*u%n,f=W(g,c,n)*N%n,m=W(f,r,n)*l%n,b=W(m,Zt,n);if(!ot.eql(ot.sqr(b),e))throw new Error("Cannot find square root");return b}var ot=xt(At,void 0,void 0,{sqrt:Pe}),kt=He({a:ie,b:BigInt(7),Fp:ot,n:Lt,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{let n=Lt,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-St*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=t,c=BigInt("0x100000000000000000000000000000000"),a=ze(s*e,n),o=ze(-r*e,n),l=U(e-a*t-o*i,n),u=U(-a*r-o*s,n),p=l>c,x=u>c;if(p&&(l=n-l),x&&(u=n-u),l>c||u>c)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:p,k1:l,k2neg:x,k2:u}}}},pt),Me={};function Ht(e,...n){let t=Me[e];if(t===void 0){let r=pt(Uint8Array.from(e,i=>i.charCodeAt(0)));t=D(r,r),Me[e]=t}return pt(D(t,...n))}var ce=e=>e.toRawBytes(!0).slice(1),oe=e=>J(e,32),re=e=>U(e,At),Ot=e=>U(e,Lt),fe=kt.ProjectivePoint,ln=(e,n,t)=>fe.BASE.multiplyAndAddUnsafe(e,n,t);function se(e){let n=kt.utils.normPrivateKeyToScalar(e),t=fe.fromPrivateKey(n);return{scalar:t.hasEvenY()?n:Ot(-n),bytes:ce(t)}}function Ve(e){$("x",e,St,At);let n=re(e*e),t=re(n*e+BigInt(7)),r=Pe(t);r%Zt!==ie&&(r=re(-r));let i=new fe(e,r,St);return i.assertValidity(),i}var gt=Y;function je(...e){return Ot(gt(Ht("BIP0340/challenge",...e)))}function dn(e){return se(e).bytes}function un(e,n,t=It(32)){let r=z("message",e),{bytes:i,scalar:s}=se(n),c=z("auxRand",t,32),a=oe(s^gt(Ht("BIP0340/aux",c))),o=Ht("BIP0340/nonce",a,i,r),l=Ot(gt(o));if(l===ie)throw new Error("sign failed: k is zero");let{bytes:u,scalar:p}=se(l),x=je(u,i,r),v=new Uint8Array(64);if(v.set(u,0),v.set(oe(Ot(p+x*s)),32),!Ke(v,r,i))throw new Error("sign: Invalid signature produced");return v}function Ke(e,n,t){let r=z("signature",e,64),i=z("message",n),s=z("publicKey",t,32);try{let c=Ve(gt(s)),a=gt(r.subarray(0,32));if(!mt(a,St,At))return!1;let o=gt(r.subarray(32,64));if(!mt(o,St,Lt))return!1;let l=je(oe(a),ce(c),i),u=ln(c,o,Ot(-l));return!(!u||!u.hasEvenY()||u.toAffine().x!==a)}catch{return!1}}var Pn={getPublicKey:dn,sign:un,verify:Ke,utils:{randomPrivateKey:kt.utils.randomPrivateKey,lift_x:Ve,pointToBytes:ce,numberToBytesBE:J,bytesToNumberBE:Y,taggedHash:Ht,mod:U}},hn=Ce(ot,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map(e=>e.map(n=>BigInt(n)))),mn=Ze(ot,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:ot.create(BigInt("-11"))}),Ye=Ue(kt.ProjectivePoint,e=>{let{x:n,y:t}=mn(ot.create(e[0]));return hn(n,t)},{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:ot.ORDER,m:1,k:128,expand:"xmd",hash:pt}),Vn=Ye.hashToCurve,jn=Ye.encodeToCurve;export{jn as encodeToCurve,Vn as hashToCurve,Pn as schnorr,kt as secp256k1,Ye as secp256k1_hasher};
2
- /*! Bundled license information:
3
-
4
- @noble/curves/esm/abstract/modular.js:
5
- @noble/curves/esm/abstract/curve.js:
6
- @noble/curves/esm/abstract/weierstrass.js:
7
- @noble/curves/esm/_shortw_utils.js:
8
- @noble/curves/esm/secp256k1.js:
9
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
10
- */