UNPKG

@multiversx/sdk-dapp-swap

Version:

A library to hold the main logic for swapping between tokens on the MultiversX blockchain

3 lines (2 loc) 1.33 kB
import{a as l}from"./chunk-H2CUEYMD.js";import{a,d as s,f as c}from"./chunk-DKQLHRWP.js";c();import v from"react";import{ApolloClient as A,from as z,HttpLink as L,InMemoryCache as R}from"@apollo/client";import{setContext as C}from"@apollo/client/link/context";import{onError as $}from"@apollo/client/link/error";import{print as b}from"graphql";var k=({children:m,accessToken:t,graphQLAddress:n,getAuthorizationHeaders:e})=>{let u=C((f,y)=>s(void 0,[f,y],function*(o,{headers:r}){let i={url:n,params:o==null?void 0:o.variables,body:{operationName:o==null?void 0:o.operationName,variables:o==null?void 0:o.variables,query:b(o==null?void 0:o.query)},method:"POST"},P=yield e==null?void 0:e(i),w=t?{Authorization:`Bearer ${t}`}:{};return{headers:a(a(a({},r),w),P)}})),p=$(({graphQLErrors:o,networkError:r})=>{o&&o.forEach(({message:f,locations:y,path:i})=>{console.log(`[GraphQL error]: Message: ${f}, Location: ${y}, Path: ${i}`)}),r&&console.log(`[Network error]: ${r}`)}),h=z([p,new L({uri:n})]),d=new A({cache:new R,link:u.concat(h),queryDeduplication:!1,defaultOptions:{watchQuery:{fetchPolicy:"no-cache",errorPolicy:"all"},query:{fetchPolicy:"no-cache",errorPolicy:"all"}}});return v.createElement(l.Provider,{value:{client:d,accessToken:t,isAuthenticated:Boolean(t)}},m)};export{k as a}; //# sourceMappingURL=chunk-Y25RM36Y.js.map