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