@cowprotocol/cow-sdk 0.0.14 → 0.0.15-RC.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.
@@ -25,5 +25,5 @@ import e from"loglevel";import r from"cross-fetch";import{SigningScheme as t,Int
25
25
  volumeUsd
26
26
  }
27
27
  }
28
- `,z={[T.MAINNET]:"https://api.thegraph.com/subgraphs/name/cowprotocol/cow",[T.RINKEBY]:"https://api.thegraph.com/subgraphs/name/cowprotocol/cow-rinkeby",[T.GNOSIS_CHAIN]:"https://api.thegraph.com/subgraphs/name/cowprotocol/cow-gc"};class X{constructor(e){this.context=void 0,this.clients=void 0,this.API_NAME="CoW Protocol Subgraph",this.context=e,this.clients=this.createClients()}createClients(){return{[T.MAINNET]:new l(z[T.MAINNET],{fetch:r}),[T.RINKEBY]:new l(z[T.RINKEBY],{fetch:r}),[T.GNOSIS_CHAIN]:new l(z[T.GNOSIS_CHAIN],{fetch:r})}}getBaseUrl(){try{return Promise.resolve(this.context.chainId).then(function(e){return z[e]})}catch(e){return Promise.reject(e)}}getTotals(){try{const r=this;return Promise.resolve(r.context.chainId).then(function(t){return e.debug(`[subgraph:${r.API_NAME}] Get totals for:`,t),Promise.resolve(r.runQuery(W)).then(function(e){return e.totals[0]})})}catch(e){return Promise.reject(e)}}getLastDaysVolume(r){try{const t=this;return Promise.resolve(t.context.chainId).then(function(o){return e.debug(`[subgraph:${t.API_NAME}] Get last ${r} days volume for:`,o),t.runQuery(J,{days:r})})}catch(e){return Promise.reject(e)}}getLastHoursVolume(r){try{const t=this;return Promise.resolve(t.context.chainId).then(function(o){return e.debug(`[subgraph:${t.API_NAME}] Get last ${r} hours volume for:`,o),t.runQuery(Z,{hours:r})})}catch(e){return Promise.reject(e)}}runQuery(r,t){try{const o=this;return Promise.resolve(function(e,n){try{var i=Promise.resolve(o.context.chainId).then(function(e){return Promise.resolve(o.clients[e].request(r,t))})}catch(e){return n(e)}return i&&i.then?i.then(void 0,n):i}(0,function(n){return e.error(n),Promise.resolve(o.getBaseUrl()).then(function(e){throw new m(`Error running query: ${r}. Variables: ${JSON.stringify(t)}. API: ${e}. Inner Error: ${n}`)})}))}catch(e){return Promise.reject(e)}}}const ee=function(e){return Promise.resolve(te()).then(function({ajv:r,validate:t}){return{result:!!t(e),errors:r.errors?r.errorsText(r.errors):void 0}})},re=function(e){try{const r=1,t=112,o=18,n=32,i=function(e){const r=e.match(/.{1,2}/g);if(r)return new Uint8Array(r.map(e=>parseInt(e,16)))}(e.replace(/(^0x)/,""));if(!i)return Promise.resolve();const s=Uint8Array.from([r,t,o,n,...i]);return Promise.resolve(import("multiformats/cid")).then(function({CID:e}){return e.decode(s).toV0().toString()})}catch(e){return Promise.reject(e)}},te=function(){try{function e(){return{ajv:ne,validate:oe}}ne||(ne=new h);const r=function(){if(!oe)return Promise.resolve(import("./appData.schema-adfc1c6f.js")).then(function(e){oe=ne.compile(e)})}();return Promise.resolve(r&&r.then?r.then(e):e())}catch(t){return Promise.reject(t)}};let oe,ne;function ie(e,r){try{var t=e()}catch(e){return r(e)}return t&&t.then?t.then(void 0,r):t}const se="CowSwap";class ae{constructor(e){this.context=void 0,this.context=e}generateAppDataDoc(e={},r){const{appCode:t=se,environment:o}=r||{};return{version:"0.3.0",appCode:t,environment:o,metadata:{...e}}}decodeAppData(r){try{return Promise.resolve(ie(function(){return Promise.resolve(re(r)).then(function(e){if(!e)throw new m("Error getting serialized CID");return function(e,r="https://gnosis.mypinata.cloud/ipfs"){try{return Promise.resolve(import("cross-fetch")).then(function({default:t}){return Promise.resolve(t(`${r}/${e}`)).then(function(e){return Promise.resolve(e.json())})})}catch(e){return Promise.reject(e)}}(e)})},function(r){const t=r;throw e.error("Error decoding AppData:",t),new m("Error decoding AppData: "+t.message)}))}catch(e){return Promise.reject(e)}}cidToAppDataHex(e){try{return Promise.resolve(import("multiformats/cid")).then(function({CID:r}){const{digest:t}=r.parse(e).multihash;return`0x${Buffer.from(t).toString("hex")}`})}catch(e){return Promise.reject(e)}}appDataHexToCid(e){try{return Promise.resolve(re(e)).then(function(e){if(!e)throw new m("Error getting serialized CID");return e})}catch(e){return Promise.reject(e)}}calculateAppDataHash(e){try{const r=this;return Promise.resolve(ee(e)).then(function(t){if(null==t||!t.result)throw new m("Invalid appData provided",null==t?void 0:t.errors);return ie(function(){return Promise.resolve(function(e){try{const r=JSON.stringify(e);return Promise.resolve(import("ipfs-only-hash")).then(function({of:e}){return e(r,{cidVersion:0})})}catch(e){return Promise.reject(e)}}(e)).then(function(e){return Promise.resolve(r.cidToAppDataHex(e)).then(function(r){if(!r)throw new m(`Could not extract appDataHash from calculated cidV0 ${e}`);return{cidV0:e,appDataHash:r}})})},function(e){throw new m("Failed to calculate appDataHash",e.message)})})}catch(e){return Promise.reject(e)}}uploadMetadataDocToIpfs(e){try{const r=this;return Promise.resolve(function(e,{writeUri:r="https://api.pinata.cloud",pinataApiKey:t="",pinataApiSecret:o=""}){try{return Promise.resolve(import("cross-fetch")).then(function({default:n}){if(!t||!o)throw new m("You need to pass IPFS api credentials.");const i=JSON.stringify({pinataContent:e,pinataMetadata:{name:"appData"}});return Promise.resolve(n(`${r}/pinning/pinJSONToIPFS`,{method:"POST",body:i,headers:{"Content-Type":"application/json",pinata_api_key:t,pinata_secret_api_key:o}})).then(function(e){return Promise.resolve(e.json()).then(function(r){if(200!==e.status)throw new Error(r.error.details||r.error);return r})})})}catch(e){return Promise.reject(e)}}(e,r.context.ipfs)).then(function({IpfsHash:e}){return r.cidToAppDataHex(e)})}catch(e){return Promise.reject(e)}}}var ce=0;function ue(e){return"__private_"+ce+++"_"+e}function de(e,r){if(!Object.prototype.hasOwnProperty.call(e,r))throw new TypeError("attempted to use private field on non-instance");return e}const le={appDataHash:"0x0000000000000000000000000000000000000000000000000000000000000000",isDevEnvironment:!1,ipfs:{readUri:"https://gnosis.mypinata.cloud/ipfs",writeUri:"https://api.pinata.cloud",apiKey:void 0,apiSecret:void 0}};var he,me,pe,fe,Te,ge,ve,Ee,Pe,ye,Ae,Ie,we,Ne,ke,De,Oe,_e,Se,Ue=/*#__PURE__*/ue("context"),be=/*#__PURE__*/ue("chainId");class Re{constructor(e,r){Object.defineProperty(this,Ue,{writable:!0,value:void 0}),Object.defineProperty(this,be,{writable:!0,value:void 0}),de(this,be)[be]=this.updateChainId(e),de(this,Ue)[Ue]={...le,...r,ipfs:{...le.ipfs,...r.ipfs}}}updateChainId(r){if(!T[r])throw new m(`Invalid chainId: ${r}`);return e.debug(f,`Updating chainId to: ${r}`),de(this,be)[be]=r,r}get chainId(){const r=this;var t;const o=null==(t=de(this,Ue)[Ue].signer)?void 0:t.provider;return o?(e.debug(f,"Getting chainId from provider"),function(){try{return Promise.resolve(o.getNetwork()).then(function(t){const o=t.chainId;return o!==de(r,be)[be]&&(e.debug(f,`ChainId mismatch: Provider's chainId: ${o} vs Context's chainId: ${de(r,be)[be]}. Updating Context's chainId`),r.updateChainId(o)),o})}catch(e){return Promise.reject(e)}}()):Promise.resolve(de(this,be)[be])}get appDataHash(){var e;return null!==(e=de(this,Ue)[Ue].appDataHash)&&void 0!==e?e:le.appDataHash}get isDevEnvironment(){var e;return null!==(e=de(this,Ue)[Ue].isDevEnvironment)&&void 0!==e?e:le.isDevEnvironment}get signer(){return de(this,Ue)[Ue].signer}get ipfs(){var e;return null!==(e=de(this,Ue)[Ue].ipfs)&&void 0!==e?e:le.ipfs}}class xe{constructor(r,t={},o={}){this.context=void 0,this.cowApi=void 0,this.metadataApi=void 0,this.cowSubgraphApi=void 0,this.updateChainId=e=>{this.context.updateChainId(e)},this.validateAppDataDocument=ee,this.context=new Re(r,{...t}),this.cowApi=new Q(this.context),this.cowSubgraphApi=new X(this.context),this.metadataApi=new ae(this.context),e.setLevel(o.loglevel||"error")}signOrder(e){try{const r=this,t=r._checkSigner();return Promise.resolve(r.context.chainId).then(function(o){return function(e,r,t){return P({order:e,chainId:r},A,t)}({...e,appData:r.context.appDataHash},o,t)})}catch(e){return Promise.reject(e)}}signOrderCancellation(e){try{const r=this,t=r._checkSigner();return Promise.resolve(r.context.chainId).then(function(r){return function(e,r,t){return P({orderId:e,chainId:r},y,t)}(e,r,t)})}catch(e){return Promise.reject(e)}}_checkSigner(e=this.context.signer){if(!e)throw new m("No signer available");return e}}!function(e){e.EthPriceUsd="ethPriceUSD",e.Id="id"}(he||(he={})),function(e){e.FeesEth="feesEth",e.FeesUsd="feesUsd",e.Id="id",e.NumberOfTrades="numberOfTrades",e.Orders="orders",e.Settlements="settlements",e.Timestamp="timestamp",e.Tokens="tokens",e.TotalTokens="totalTokens",e.VolumeEth="volumeEth",e.VolumeUsd="volumeUsd"}(me||(me={})),function(e){e.FeesEth="feesEth",e.FeesUsd="feesUsd",e.Id="id",e.NumberOfTrades="numberOfTrades",e.Orders="orders",e.Settlements="settlements",e.Timestamp="timestamp",e.Tokens="tokens",e.TotalTokens="totalTokens",e.VolumeEth="volumeEth",e.VolumeUsd="volumeUsd"}(pe||(pe={})),function(e){e.Asc="asc",e.Desc="desc"}(fe||(fe={})),function(e){e.Id="id",e.InvalidateTimestamp="invalidateTimestamp",e.IsSigned="isSigned",e.IsValid="isValid",e.Owner="owner",e.PresignTimestamp="presignTimestamp",e.Trades="trades",e.TradesTimestamp="tradesTimestamp"}(Te||(Te={})),function(e){e.Id="id",e.Timestamp="timestamp",e.Token0="token0",e.Token0Price="token0Price",e.Token0relativePrice="token0relativePrice",e.Token1="token1",e.Token1Price="token1Price",e.Token1relativePrice="token1relativePrice",e.VolumeToken0="volumeToken0",e.VolumeToken1="volumeToken1",e.VolumeTradedEth="volumeTradedEth",e.VolumeTradedUsd="volumeTradedUsd"}(ge||(ge={})),function(e){e.Id="id",e.Timestamp="timestamp",e.Token0="token0",e.Token0Price="token0Price",e.Token0relativePrice="token0relativePrice",e.Token1="token1",e.Token1Price="token1Price",e.Token1relativePrice="token1relativePrice",e.VolumeToken0="volumeToken0",e.VolumeToken1="volumeToken1",e.VolumeTradedEth="volumeTradedEth",e.VolumeTradedUsd="volumeTradedUsd"}(ve||(ve={})),function(e){e.Id="id",e.Token0="token0",e.Token0Price="token0Price",e.Token0relativePrice="token0relativePrice",e.Token1="token1",e.Token1Price="token1Price",e.Token1relativePrice="token1relativePrice",e.VolumeToken0="volumeToken0",e.VolumeToken1="volumeToken1",e.VolumeTradedEth="volumeTradedEth",e.VolumeTradedUsd="volumeTradedUsd"}(Ee||(Ee={})),function(e){e.FirstTradeTimestamp="firstTradeTimestamp",e.Id="id",e.Solver="solver",e.Trades="trades",e.TxHash="txHash"}(Pe||(Pe={})),function(e){e.AveragePrice="averagePrice",e.ClosePrice="closePrice",e.HigherPrice="higherPrice",e.Id="id",e.LowerPrice="lowerPrice",e.OpenPrice="openPrice",e.Timestamp="timestamp",e.Token="token",e.TotalTrades="totalTrades",e.TotalVolume="totalVolume",e.TotalVolumeEth="totalVolumeEth",e.TotalVolumeUsd="totalVolumeUsd"}(ye||(ye={})),function(e){e.AveragePrice="averagePrice",e.ClosePrice="closePrice",e.HigherPrice="higherPrice",e.Id="id",e.LowerPrice="lowerPrice",e.OpenPrice="openPrice",e.Timestamp="timestamp",e.Token="token",e.TotalTrades="totalTrades",e.TotalVolume="totalVolume",e.TotalVolumeEth="totalVolumeEth",e.TotalVolumeUsd="totalVolumeUsd"}(Ae||(Ae={})),function(e){e.AmountEth="amountEth",e.AmountUsd="amountUsd",e.Id="id",e.Timestamp="timestamp",e.Token="token",e.Trade="trade"}(Ie||(Ie={})),function(e){e.Address="address",e.Decimals="decimals",e.FirstTradeTimestamp="firstTradeTimestamp",e.History="history",e.Id="id",e.Name="name",e.NumberOfTrades="numberOfTrades",e.PriceEth="priceEth",e.PriceUsd="priceUsd",e.Symbol="symbol",e.TotalVolume="totalVolume",e.TotalVolumeEth="totalVolumeEth",e.TotalVolumeUsd="totalVolumeUsd"}(we||(we={})),function(e){e.FeesEth="feesEth",e.FeesUsd="feesUsd",e.Id="id",e.NumberOfTrades="numberOfTrades",e.Orders="orders",e.Settlements="settlements",e.Tokens="tokens",e.Traders="traders",e.VolumeEth="volumeEth",e.VolumeUsd="volumeUsd"}(Ne||(Ne={})),function(e){e.BuyAmount="buyAmount",e.BuyAmountEth="buyAmountEth",e.BuyAmountUsd="buyAmountUsd",e.BuyToken="buyToken",e.FeeAmount="feeAmount",e.GasPrice="gasPrice",e.Id="id",e.Order="order",e.SellAmount="sellAmount",e.SellAmountEth="sellAmountEth",e.SellAmountUsd="sellAmountUsd",e.SellToken="sellToken",e.Settlement="settlement",e.Timestamp="timestamp",e.TxHash="txHash"}(ke||(ke={})),function(e){e.Id="id",e.Liquidity="liquidity",e.Tick="tick",e.Token0="token0",e.Token0Price="token0Price",e.Token1="token1",e.Token1Price="token1Price",e.TotalValueLockedToken0="totalValueLockedToken0",e.TotalValueLockedToken1="totalValueLockedToken1"}(De||(De={})),function(e){e.Address="address",e.AllowedPools="allowedPools",e.Decimals="decimals",e.Id="id",e.Name="name",e.PriceEth="priceEth",e.PriceUsd="priceUsd",e.Symbol="symbol"}(Oe||(Oe={})),function(e){e.Address="address",e.FirstTradeTimestamp="firstTradeTimestamp",e.Id="id",e.IsSolver="isSolver",e.NumberOfTrades="numberOfTrades",e.OrdersPlaced="ordersPlaced",e.SolvedAmountEth="solvedAmountEth",e.SolvedAmountUsd="solvedAmountUsd",e.TradedAmountEth="tradedAmountEth",e.TradedAmountUsd="tradedAmountUsd"}(_e||(_e={})),function(e){e.Allow="allow",e.Deny="deny"}(Se||(Se={}));var Ce={__proto__:null,get Bundle_OrderBy(){return he},get DailyTotal_OrderBy(){return me},get HourlyTotal_OrderBy(){return pe},get OrderDirection(){return fe},get Order_OrderBy(){return Te},get PairDaily_OrderBy(){return ge},get PairHourly_OrderBy(){return ve},get Pair_OrderBy(){return Ee},get Settlement_OrderBy(){return Pe},get TokenDailyTotal_OrderBy(){return ye},get TokenHourlyTotal_OrderBy(){return Ae},get TokenTradingEvent_OrderBy(){return Ie},get Token_OrderBy(){return we},get Total_OrderBy(){return Ne},get Trade_OrderBy(){return ke},get UniswapPool_OrderBy(){return De},get UniswapToken_OrderBy(){return Oe},get User_OrderBy(){return _e},get _SubgraphErrorPolicy_(){return Se}};export{g as ALL_SUPPORTED_CHAIN_IDS,m as CowError,xe as CowSdk,Ce as GraphQL,T as SupportedChainId,F as Token};
28
+ `,z={[T.MAINNET]:"https://api.thegraph.com/subgraphs/name/cowprotocol/cow",[T.RINKEBY]:"https://api.thegraph.com/subgraphs/name/cowprotocol/cow-rinkeby",[T.GNOSIS_CHAIN]:"https://api.thegraph.com/subgraphs/name/cowprotocol/cow-gc"};class X{constructor(e){this.context=void 0,this.clients=void 0,this.API_NAME="CoW Protocol Subgraph",this.context=e,this.clients=this.createClients()}createClients(){return{[T.MAINNET]:new l(z[T.MAINNET],{fetch:r}),[T.RINKEBY]:new l(z[T.RINKEBY],{fetch:r}),[T.GNOSIS_CHAIN]:new l(z[T.GNOSIS_CHAIN],{fetch:r})}}getBaseUrl(){try{return Promise.resolve(this.context.chainId).then(function(e){return z[e]})}catch(e){return Promise.reject(e)}}getTotals(){try{const r=this;return Promise.resolve(r.context.chainId).then(function(t){return e.debug(`[subgraph:${r.API_NAME}] Get totals for:`,t),Promise.resolve(r.runQuery(W)).then(function(e){return e.totals[0]})})}catch(e){return Promise.reject(e)}}getLastDaysVolume(r){try{const t=this;return Promise.resolve(t.context.chainId).then(function(o){return e.debug(`[subgraph:${t.API_NAME}] Get last ${r} days volume for:`,o),t.runQuery(J,{days:r})})}catch(e){return Promise.reject(e)}}getLastHoursVolume(r){try{const t=this;return Promise.resolve(t.context.chainId).then(function(o){return e.debug(`[subgraph:${t.API_NAME}] Get last ${r} hours volume for:`,o),t.runQuery(Z,{hours:r})})}catch(e){return Promise.reject(e)}}runQuery(r,t){try{const o=this;return Promise.resolve(function(e,n){try{var i=Promise.resolve(o.context.chainId).then(function(e){return Promise.resolve(o.clients[e].request(r,t))})}catch(e){return n(e)}return i&&i.then?i.then(void 0,n):i}(0,function(n){return e.error(n),Promise.resolve(o.getBaseUrl()).then(function(e){throw new m(`Error running query: ${r}. Variables: ${JSON.stringify(t)}. API: ${e}. Inner Error: ${n}`)})}))}catch(e){return Promise.reject(e)}}}const ee=function(e){return Promise.resolve(te()).then(function({ajv:r,validate:t}){return{result:!!t(e),errors:r.errors?r.errorsText(r.errors):void 0}})},re=function(e){try{const r=1,t=112,o=18,n=32,i=function(e){const r=e.match(/.{1,2}/g);if(r)return new Uint8Array(r.map(e=>parseInt(e,16)))}(e.replace(/(^0x)/,""));if(!i)return Promise.resolve();const s=Uint8Array.from([r,t,o,n,...i]);return Promise.resolve(import("multiformats/cid")).then(function({CID:e}){return e.decode(s).toV0().toString()})}catch(e){return Promise.reject(e)}},te=function(){try{function e(){return{ajv:ne,validate:oe}}ne||(ne=new h);const r=function(){if(!oe)return Promise.resolve(import("./appData.schema-ba6f714f.js")).then(function(e){oe=ne.compile(e)})}();return Promise.resolve(r&&r.then?r.then(e):e())}catch(t){return Promise.reject(t)}};let oe,ne;function ie(e,r){try{var t=e()}catch(e){return r(e)}return t&&t.then?t.then(void 0,r):t}const se="CowSwap";class ae{constructor(e){this.context=void 0,this.context=e}generateAppDataDoc(e={},r){const{appCode:t=se,environment:o}=r||{};return{version:"0.4.0",appCode:t,environment:o,metadata:{...e}}}decodeAppData(r){try{return Promise.resolve(ie(function(){return Promise.resolve(re(r)).then(function(e){if(!e)throw new m("Error getting serialized CID");return function(e,r="https://gnosis.mypinata.cloud/ipfs"){try{return Promise.resolve(import("cross-fetch")).then(function({default:t}){return Promise.resolve(t(`${r}/${e}`)).then(function(e){return Promise.resolve(e.json())})})}catch(e){return Promise.reject(e)}}(e)})},function(r){const t=r;throw e.error("Error decoding AppData:",t),new m("Error decoding AppData: "+t.message)}))}catch(e){return Promise.reject(e)}}cidToAppDataHex(e){try{return Promise.resolve(import("multiformats/cid")).then(function({CID:r}){const{digest:t}=r.parse(e).multihash;return`0x${Buffer.from(t).toString("hex")}`})}catch(e){return Promise.reject(e)}}appDataHexToCid(e){try{return Promise.resolve(re(e)).then(function(e){if(!e)throw new m("Error getting serialized CID");return e})}catch(e){return Promise.reject(e)}}calculateAppDataHash(e){try{const r=this;return Promise.resolve(ee(e)).then(function(t){if(null==t||!t.result)throw new m("Invalid appData provided",null==t?void 0:t.errors);return ie(function(){return Promise.resolve(function(e){try{const r=JSON.stringify(e);return Promise.resolve(import("ipfs-only-hash")).then(function({of:e}){return e(r,{cidVersion:0})})}catch(e){return Promise.reject(e)}}(e)).then(function(e){return Promise.resolve(r.cidToAppDataHex(e)).then(function(r){if(!r)throw new m(`Could not extract appDataHash from calculated cidV0 ${e}`);return{cidV0:e,appDataHash:r}})})},function(e){throw new m("Failed to calculate appDataHash",e.message)})})}catch(e){return Promise.reject(e)}}uploadMetadataDocToIpfs(e){try{const r=this;return Promise.resolve(function(e,{writeUri:r="https://api.pinata.cloud",pinataApiKey:t="",pinataApiSecret:o=""}){try{return Promise.resolve(import("cross-fetch")).then(function({default:n}){if(!t||!o)throw new m("You need to pass IPFS api credentials.");const i=JSON.stringify({pinataContent:e,pinataMetadata:{name:"appData"}});return Promise.resolve(n(`${r}/pinning/pinJSONToIPFS`,{method:"POST",body:i,headers:{"Content-Type":"application/json",pinata_api_key:t,pinata_secret_api_key:o}})).then(function(e){return Promise.resolve(e.json()).then(function(r){if(200!==e.status)throw new Error(r.error.details||r.error);return r})})})}catch(e){return Promise.reject(e)}}(e,r.context.ipfs)).then(function({IpfsHash:e}){return r.cidToAppDataHex(e)})}catch(e){return Promise.reject(e)}}}var ce=0;function ue(e){return"__private_"+ce+++"_"+e}function de(e,r){if(!Object.prototype.hasOwnProperty.call(e,r))throw new TypeError("attempted to use private field on non-instance");return e}const le={appDataHash:"0x0000000000000000000000000000000000000000000000000000000000000000",isDevEnvironment:!1,ipfs:{readUri:"https://gnosis.mypinata.cloud/ipfs",writeUri:"https://api.pinata.cloud",apiKey:void 0,apiSecret:void 0}};var he,me,pe,fe,Te,ge,ve,Ee,Pe,ye,Ae,Ie,we,Ne,ke,De,Oe,_e,Se,Ue=/*#__PURE__*/ue("context"),be=/*#__PURE__*/ue("chainId");class Re{constructor(e,r){Object.defineProperty(this,Ue,{writable:!0,value:void 0}),Object.defineProperty(this,be,{writable:!0,value:void 0}),de(this,be)[be]=this.updateChainId(e),de(this,Ue)[Ue]={...le,...r,ipfs:{...le.ipfs,...r.ipfs}}}updateChainId(r){if(!T[r])throw new m(`Invalid chainId: ${r}`);return e.debug(f,`Updating chainId to: ${r}`),de(this,be)[be]=r,r}get chainId(){const r=this;var t;const o=null==(t=de(this,Ue)[Ue].signer)?void 0:t.provider;return o?(e.debug(f,"Getting chainId from provider"),function(){try{return Promise.resolve(o.getNetwork()).then(function(t){const o=t.chainId;return o!==de(r,be)[be]&&(e.debug(f,`ChainId mismatch: Provider's chainId: ${o} vs Context's chainId: ${de(r,be)[be]}. Updating Context's chainId`),r.updateChainId(o)),o})}catch(e){return Promise.reject(e)}}()):Promise.resolve(de(this,be)[be])}get appDataHash(){var e;return null!==(e=de(this,Ue)[Ue].appDataHash)&&void 0!==e?e:le.appDataHash}get isDevEnvironment(){var e;return null!==(e=de(this,Ue)[Ue].isDevEnvironment)&&void 0!==e?e:le.isDevEnvironment}get signer(){return de(this,Ue)[Ue].signer}get ipfs(){var e;return null!==(e=de(this,Ue)[Ue].ipfs)&&void 0!==e?e:le.ipfs}}class xe{constructor(r,t={},o={}){this.context=void 0,this.cowApi=void 0,this.metadataApi=void 0,this.cowSubgraphApi=void 0,this.updateChainId=e=>{this.context.updateChainId(e)},this.validateAppDataDocument=ee,this.context=new Re(r,{...t}),this.cowApi=new Q(this.context),this.cowSubgraphApi=new X(this.context),this.metadataApi=new ae(this.context),e.setLevel(o.loglevel||"error")}signOrder(e){try{const r=this,t=r._checkSigner();return Promise.resolve(r.context.chainId).then(function(o){return function(e,r,t){return P({order:e,chainId:r},A,t)}({...e,appData:r.context.appDataHash},o,t)})}catch(e){return Promise.reject(e)}}signOrderCancellation(e){try{const r=this,t=r._checkSigner();return Promise.resolve(r.context.chainId).then(function(r){return function(e,r,t){return P({orderId:e,chainId:r},y,t)}(e,r,t)})}catch(e){return Promise.reject(e)}}_checkSigner(e=this.context.signer){if(!e)throw new m("No signer available");return e}}!function(e){e.EthPriceUsd="ethPriceUSD",e.Id="id"}(he||(he={})),function(e){e.FeesEth="feesEth",e.FeesUsd="feesUsd",e.Id="id",e.NumberOfTrades="numberOfTrades",e.Orders="orders",e.Settlements="settlements",e.Timestamp="timestamp",e.Tokens="tokens",e.TotalTokens="totalTokens",e.VolumeEth="volumeEth",e.VolumeUsd="volumeUsd"}(me||(me={})),function(e){e.FeesEth="feesEth",e.FeesUsd="feesUsd",e.Id="id",e.NumberOfTrades="numberOfTrades",e.Orders="orders",e.Settlements="settlements",e.Timestamp="timestamp",e.Tokens="tokens",e.TotalTokens="totalTokens",e.VolumeEth="volumeEth",e.VolumeUsd="volumeUsd"}(pe||(pe={})),function(e){e.Asc="asc",e.Desc="desc"}(fe||(fe={})),function(e){e.Id="id",e.InvalidateTimestamp="invalidateTimestamp",e.IsSigned="isSigned",e.IsValid="isValid",e.Owner="owner",e.PresignTimestamp="presignTimestamp",e.Trades="trades",e.TradesTimestamp="tradesTimestamp"}(Te||(Te={})),function(e){e.Id="id",e.Timestamp="timestamp",e.Token0="token0",e.Token0Price="token0Price",e.Token0relativePrice="token0relativePrice",e.Token1="token1",e.Token1Price="token1Price",e.Token1relativePrice="token1relativePrice",e.VolumeToken0="volumeToken0",e.VolumeToken1="volumeToken1",e.VolumeTradedEth="volumeTradedEth",e.VolumeTradedUsd="volumeTradedUsd"}(ge||(ge={})),function(e){e.Id="id",e.Timestamp="timestamp",e.Token0="token0",e.Token0Price="token0Price",e.Token0relativePrice="token0relativePrice",e.Token1="token1",e.Token1Price="token1Price",e.Token1relativePrice="token1relativePrice",e.VolumeToken0="volumeToken0",e.VolumeToken1="volumeToken1",e.VolumeTradedEth="volumeTradedEth",e.VolumeTradedUsd="volumeTradedUsd"}(ve||(ve={})),function(e){e.Id="id",e.Token0="token0",e.Token0Price="token0Price",e.Token0relativePrice="token0relativePrice",e.Token1="token1",e.Token1Price="token1Price",e.Token1relativePrice="token1relativePrice",e.VolumeToken0="volumeToken0",e.VolumeToken1="volumeToken1",e.VolumeTradedEth="volumeTradedEth",e.VolumeTradedUsd="volumeTradedUsd"}(Ee||(Ee={})),function(e){e.FirstTradeTimestamp="firstTradeTimestamp",e.Id="id",e.Solver="solver",e.Trades="trades",e.TxHash="txHash"}(Pe||(Pe={})),function(e){e.AveragePrice="averagePrice",e.ClosePrice="closePrice",e.HigherPrice="higherPrice",e.Id="id",e.LowerPrice="lowerPrice",e.OpenPrice="openPrice",e.Timestamp="timestamp",e.Token="token",e.TotalTrades="totalTrades",e.TotalVolume="totalVolume",e.TotalVolumeEth="totalVolumeEth",e.TotalVolumeUsd="totalVolumeUsd"}(ye||(ye={})),function(e){e.AveragePrice="averagePrice",e.ClosePrice="closePrice",e.HigherPrice="higherPrice",e.Id="id",e.LowerPrice="lowerPrice",e.OpenPrice="openPrice",e.Timestamp="timestamp",e.Token="token",e.TotalTrades="totalTrades",e.TotalVolume="totalVolume",e.TotalVolumeEth="totalVolumeEth",e.TotalVolumeUsd="totalVolumeUsd"}(Ae||(Ae={})),function(e){e.AmountEth="amountEth",e.AmountUsd="amountUsd",e.Id="id",e.Timestamp="timestamp",e.Token="token",e.Trade="trade"}(Ie||(Ie={})),function(e){e.Address="address",e.Decimals="decimals",e.FirstTradeTimestamp="firstTradeTimestamp",e.History="history",e.Id="id",e.Name="name",e.NumberOfTrades="numberOfTrades",e.PriceEth="priceEth",e.PriceUsd="priceUsd",e.Symbol="symbol",e.TotalVolume="totalVolume",e.TotalVolumeEth="totalVolumeEth",e.TotalVolumeUsd="totalVolumeUsd"}(we||(we={})),function(e){e.FeesEth="feesEth",e.FeesUsd="feesUsd",e.Id="id",e.NumberOfTrades="numberOfTrades",e.Orders="orders",e.Settlements="settlements",e.Tokens="tokens",e.Traders="traders",e.VolumeEth="volumeEth",e.VolumeUsd="volumeUsd"}(Ne||(Ne={})),function(e){e.BuyAmount="buyAmount",e.BuyAmountEth="buyAmountEth",e.BuyAmountUsd="buyAmountUsd",e.BuyToken="buyToken",e.FeeAmount="feeAmount",e.GasPrice="gasPrice",e.Id="id",e.Order="order",e.SellAmount="sellAmount",e.SellAmountEth="sellAmountEth",e.SellAmountUsd="sellAmountUsd",e.SellToken="sellToken",e.Settlement="settlement",e.Timestamp="timestamp",e.TxHash="txHash"}(ke||(ke={})),function(e){e.Id="id",e.Liquidity="liquidity",e.Tick="tick",e.Token0="token0",e.Token0Price="token0Price",e.Token1="token1",e.Token1Price="token1Price",e.TotalValueLockedToken0="totalValueLockedToken0",e.TotalValueLockedToken1="totalValueLockedToken1"}(De||(De={})),function(e){e.Address="address",e.AllowedPools="allowedPools",e.Decimals="decimals",e.Id="id",e.Name="name",e.PriceEth="priceEth",e.PriceUsd="priceUsd",e.Symbol="symbol"}(Oe||(Oe={})),function(e){e.Address="address",e.FirstTradeTimestamp="firstTradeTimestamp",e.Id="id",e.IsSolver="isSolver",e.NumberOfTrades="numberOfTrades",e.OrdersPlaced="ordersPlaced",e.SolvedAmountEth="solvedAmountEth",e.SolvedAmountUsd="solvedAmountUsd",e.TradedAmountEth="tradedAmountEth",e.TradedAmountUsd="tradedAmountUsd"}(_e||(_e={})),function(e){e.Allow="allow",e.Deny="deny"}(Se||(Se={}));var Ce={__proto__:null,get Bundle_OrderBy(){return he},get DailyTotal_OrderBy(){return me},get HourlyTotal_OrderBy(){return pe},get OrderDirection(){return fe},get Order_OrderBy(){return Te},get PairDaily_OrderBy(){return ge},get PairHourly_OrderBy(){return ve},get Pair_OrderBy(){return Ee},get Settlement_OrderBy(){return Pe},get TokenDailyTotal_OrderBy(){return ye},get TokenHourlyTotal_OrderBy(){return Ae},get TokenTradingEvent_OrderBy(){return Ie},get Token_OrderBy(){return we},get Total_OrderBy(){return Ne},get Trade_OrderBy(){return ke},get UniswapPool_OrderBy(){return De},get UniswapToken_OrderBy(){return Oe},get User_OrderBy(){return _e},get _SubgraphErrorPolicy_(){return Se}};export{g as ALL_SUPPORTED_CHAIN_IDS,m as CowError,xe as CowSdk,Ce as GraphQL,T as SupportedChainId,F as Token};
29
29
  //# sourceMappingURL=index.module.js.map