var p=(t,r,e)=>new Promise((o,c)=>{var i=a=>{try{l(e.next(a))}catch(s){c(s)}},n=a=>{try{l(e.throw(a))}catch(s){c(s)}},l=a=>a.done?o(a.value):Promise.resolve(a.value).then(i,n);l((e=e.apply(t,r)).next())});import{useConnection as E,useWallet as b}from"@solana/wallet-adapter-react";import{Transaction as $}from"@solana/web3.js";import{useCallback as A}from"react";import u from"axios";import{createContext as P,useMemo as K}from"react";import{jsx as B}from"react/jsx-runtime";var Y=P(void 0),w="production";var m=w==="development"?"https://qa-api-v2.bandit.network/sdk":"https://api-v2.bandit.network/sdk";var y=(t,r,e,o,c,i)=>p(void 0,null,function*(){try{return(yield u.post(`${m}/collection/sns/registerDomain`,{name:r,claimWallet:e,price:o,payUsing:c,space:i},{headers:{"X-API-KEY":t}})).data}catch(n){throw new Error(n)}}),x=(t,r,e)=>p(void 0,null,function*(){try{return(yield u.post(`${m}/collection/sns/claimDomain`,{name:r,transactionHash:e},{headers:{"X-API-KEY":t}})).data}catch(o){throw new Error(o)}});var v=()=>{let t=b(),{connection:r}=E();return{registerSns:A((o,c,i,n,l,a)=>p(void 0,null,function*(){if(!(!t.connected||!t.publicKey||!r))try{let s=c,g=yield y(o,n.name,l,s.toString(),i.value,a*1e3),D=yield r.getLatestBlockhash(),d=$.from(Buffer.from(g));d.recentBlockhash=D.blockhash;let h=yield t.sendTransaction(d,r);console.log(h),yield x(o,n.name,h)}catch(s){throw s}}),[t,r])}},F=v;export{F as default};
