UNPKG

@starkware-industries/starkex-js

Version:

`starkex-js` is a JavaScript wrapper around the [StarkEx API](https://starkware.co/starkex/api/) that can be used in both NodeJS and Browser environments.

6 lines 33.2 kB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("StarkExAPI",[],t):"object"==typeof exports?exports.StarkExAPI=t():e.StarkExAPI=t()}(this,(function(){return(()=>{var e={206:(e,t,n)=>{e.exports=n(57)},387:(e,t,n)=>{"use strict";var r=n(485),o=n(570),i=n(940),a=n(581),s=n(574),u=n(845),c=n(338),f=n(524);e.exports=function(e){return new Promise((function(t,n){var l=e.data,p=e.headers;r.isFormData(l)&&delete p["Content-Type"];var _=new XMLHttpRequest;if(e.auth){var d=e.auth.username||"",E=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";p.Authorization="Basic "+btoa(d+":"+E)}var h=s(e.baseURL,e.url);if(_.open(e.method.toUpperCase(),a(h,e.params,e.paramsSerializer),!0),_.timeout=e.timeout,_.onreadystatechange=function(){if(_&&4===_.readyState&&(0!==_.status||_.responseURL&&0===_.responseURL.indexOf("file:"))){var r="getAllResponseHeaders"in _?u(_.getAllResponseHeaders()):null,i={data:e.responseType&&"text"!==e.responseType?_.response:_.responseText,status:_.status,statusText:_.statusText,headers:r,config:e,request:_};o(t,n,i),_=null}},_.onabort=function(){_&&(n(f("Request aborted",e,"ECONNABORTED",_)),_=null)},_.onerror=function(){n(f("Network Error",e,null,_)),_=null},_.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(f(t,e,"ECONNABORTED",_)),_=null},r.isStandardBrowserEnv()){var T=(e.withCredentials||c(h))&&e.xsrfCookieName?i.read(e.xsrfCookieName):void 0;T&&(p[e.xsrfHeaderName]=T)}if("setRequestHeader"in _&&r.forEach(p,(function(e,t){void 0===l&&"content-type"===t.toLowerCase()?delete p[t]:_.setRequestHeader(t,e)})),r.isUndefined(e.withCredentials)||(_.withCredentials=!!e.withCredentials),e.responseType)try{_.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&_.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&_.upload&&_.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then((function(e){_&&(_.abort(),n(e),_=null)})),l||(l=null),_.send(l)}))}},57:(e,t,n)=>{"use strict";var r=n(485),o=n(875),i=n(29),a=n(941);function s(e){var t=new i(e),n=o(i.prototype.request,t);return r.extend(n,i.prototype,t),r.extend(n,t),n}var u=s(n(141));u.Axios=i,u.create=function(e){return s(a(u.defaults,e))},u.Cancel=n(132),u.CancelToken=n(603),u.isCancel=n(475),u.all=function(e){return Promise.all(e)},u.spread=n(739),u.isAxiosError=n(835),e.exports=u,e.exports.default=u},132:e=>{"use strict";function t(e){this.message=e}t.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},t.prototype.__CANCEL__=!0,e.exports=t},603:(e,t,n)=>{"use strict";var r=n(132);function o(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var n=this;e((function(e){n.reason||(n.reason=new r(e),t(n.reason))}))}o.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},o.source=function(){var e;return{token:new o((function(t){e=t})),cancel:e}},e.exports=o},475:e=>{"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},29:(e,t,n)=>{"use strict";var r=n(485),o=n(581),i=n(96),a=n(9),s=n(941);function u(e){this.defaults=e,this.interceptors={request:new i,response:new i}}u.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=s(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=[a,void 0],n=Promise.resolve(e);for(this.interceptors.request.forEach((function(e){t.unshift(e.fulfilled,e.rejected)})),this.interceptors.response.forEach((function(e){t.push(e.fulfilled,e.rejected)}));t.length;)n=n.then(t.shift(),t.shift());return n},u.prototype.getUri=function(e){return e=s(this.defaults,e),o(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},r.forEach(["delete","get","head","options"],(function(e){u.prototype[e]=function(t,n){return this.request(s(n||{},{method:e,url:t,data:(n||{}).data}))}})),r.forEach(["post","put","patch"],(function(e){u.prototype[e]=function(t,n,r){return this.request(s(r||{},{method:e,url:t,data:n}))}})),e.exports=u},96:(e,t,n)=>{"use strict";var r=n(485);function o(){this.handlers=[]}o.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},o.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},o.prototype.forEach=function(e){r.forEach(this.handlers,(function(t){null!==t&&e(t)}))},e.exports=o},574:(e,t,n)=>{"use strict";var r=n(642),o=n(288);e.exports=function(e,t){return e&&!r(t)?o(e,t):t}},524:(e,t,n)=>{"use strict";var r=n(953);e.exports=function(e,t,n,o,i){var a=new Error(e);return r(a,t,n,o,i)}},9:(e,t,n)=>{"use strict";var r=n(485),o=n(212),i=n(475),a=n(141);function s(e){e.cancelToken&&e.cancelToken.throwIfRequested()}e.exports=function(e){return s(e),e.headers=e.headers||{},e.data=o(e.data,e.headers,e.transformRequest),e.headers=r.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),r.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||a.adapter)(e).then((function(t){return s(e),t.data=o(t.data,t.headers,e.transformResponse),t}),(function(t){return i(t)||(s(e),t&&t.response&&(t.response.data=o(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))}},953:e=>{"use strict";e.exports=function(e,t,n,r,o){return e.config=t,n&&(e.code=n),e.request=r,e.response=o,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e}},941:(e,t,n)=>{"use strict";var r=n(485);e.exports=function(e,t){t=t||{};var n={},o=["url","method","data"],i=["headers","auth","proxy","params"],a=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],s=["validateStatus"];function u(e,t){return r.isPlainObject(e)&&r.isPlainObject(t)?r.merge(e,t):r.isPlainObject(t)?r.merge({},t):r.isArray(t)?t.slice():t}function c(o){r.isUndefined(t[o])?r.isUndefined(e[o])||(n[o]=u(void 0,e[o])):n[o]=u(e[o],t[o])}r.forEach(o,(function(e){r.isUndefined(t[e])||(n[e]=u(void 0,t[e]))})),r.forEach(i,c),r.forEach(a,(function(o){r.isUndefined(t[o])?r.isUndefined(e[o])||(n[o]=u(void 0,e[o])):n[o]=u(void 0,t[o])})),r.forEach(s,(function(r){r in t?n[r]=u(e[r],t[r]):r in e&&(n[r]=u(void 0,e[r]))}));var f=o.concat(i).concat(a).concat(s),l=Object.keys(e).concat(Object.keys(t)).filter((function(e){return-1===f.indexOf(e)}));return r.forEach(l,c),n}},570:(e,t,n)=>{"use strict";var r=n(524);e.exports=function(e,t,n){var o=n.config.validateStatus;n.status&&o&&!o(n.status)?t(r("Request failed with status code "+n.status,n.config,null,n.request,n)):e(n)}},212:(e,t,n)=>{"use strict";var r=n(485);e.exports=function(e,t,n){return r.forEach(n,(function(n){e=n(e,t)})),e}},141:(e,t,n)=>{"use strict";var r=n(485),o=n(446),i={"Content-Type":"application/x-www-form-urlencoded"};function a(e,t){!r.isUndefined(e)&&r.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var s,u={adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(s=n(387)),s),transformRequest:[function(e,t){return o(t,"Accept"),o(t,"Content-Type"),r.isFormData(e)||r.isArrayBuffer(e)||r.isBuffer(e)||r.isStream(e)||r.isFile(e)||r.isBlob(e)?e:r.isArrayBufferView(e)?e.buffer:r.isURLSearchParams(e)?(a(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):r.isObject(e)?(a(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if("string"==typeof e)try{e=JSON.parse(e)}catch(e){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300}};u.headers={common:{Accept:"application/json, text/plain, */*"}},r.forEach(["delete","get","head"],(function(e){u.headers[e]={}})),r.forEach(["post","put","patch"],(function(e){u.headers[e]=r.merge(i)})),e.exports=u},875:e=>{"use strict";e.exports=function(e,t){return function(){for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];return e.apply(t,n)}}},581:(e,t,n)=>{"use strict";var r=n(485);function o(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}e.exports=function(e,t,n){if(!t)return e;var i;if(n)i=n(t);else if(r.isURLSearchParams(t))i=t.toString();else{var a=[];r.forEach(t,(function(e,t){null!=e&&(r.isArray(e)?t+="[]":e=[e],r.forEach(e,(function(e){r.isDate(e)?e=e.toISOString():r.isObject(e)&&(e=JSON.stringify(e)),a.push(o(t)+"="+o(e))})))})),i=a.join("&")}if(i){var s=e.indexOf("#");-1!==s&&(e=e.slice(0,s)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e}},288:e=>{"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},940:(e,t,n)=>{"use strict";var r=n(485);e.exports=r.isStandardBrowserEnv()?{write:function(e,t,n,o,i,a){var s=[];s.push(e+"="+encodeURIComponent(t)),r.isNumber(n)&&s.push("expires="+new Date(n).toGMTString()),r.isString(o)&&s.push("path="+o),r.isString(i)&&s.push("domain="+i),!0===a&&s.push("secure"),document.cookie=s.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},642:e=>{"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},835:e=>{"use strict";e.exports=function(e){return"object"==typeof e&&!0===e.isAxiosError}},338:(e,t,n)=>{"use strict";var r=n(485);e.exports=r.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function o(e){var r=e;return t&&(n.setAttribute("href",r),r=n.href),n.setAttribute("href",r),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return e=o(window.location.href),function(t){var n=r.isString(t)?o(t):t;return n.protocol===e.protocol&&n.host===e.host}}():function(){return!0}},446:(e,t,n)=>{"use strict";var r=n(485);e.exports=function(e,t){r.forEach(e,(function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])}))}},845:(e,t,n)=>{"use strict";var r=n(485),o=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,n,i,a={};return e?(r.forEach(e.split("\n"),(function(e){if(i=e.indexOf(":"),t=r.trim(e.substr(0,i)).toLowerCase(),n=r.trim(e.substr(i+1)),t){if(a[t]&&o.indexOf(t)>=0)return;a[t]="set-cookie"===t?(a[t]?a[t]:[]).concat([n]):a[t]?a[t]+", "+n:n}})),a):a}},739:e=>{"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}},485:(e,t,n)=>{"use strict";var r=n(875),o=Object.prototype.toString;function i(e){return"[object Array]"===o.call(e)}function a(e){return void 0===e}function s(e){return null!==e&&"object"==typeof e}function u(e){if("[object Object]"!==o.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function c(e){return"[object Function]"===o.call(e)}function f(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),i(e))for(var n=0,r=e.length;n<r;n++)t.call(null,e[n],n,e);else for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.call(null,e[o],o,e)}e.exports={isArray:i,isArrayBuffer:function(e){return"[object ArrayBuffer]"===o.call(e)},isBuffer:function(e){return null!==e&&!a(e)&&null!==e.constructor&&!a(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:s,isPlainObject:u,isUndefined:a,isDate:function(e){return"[object Date]"===o.call(e)},isFile:function(e){return"[object File]"===o.call(e)},isBlob:function(e){return"[object Blob]"===o.call(e)},isFunction:c,isStream:function(e){return s(e)&&c(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:f,merge:function e(){var t={};function n(n,r){u(t[r])&&u(n)?t[r]=e(t[r],n):u(n)?t[r]=e({},n):i(n)?t[r]=n.slice():t[r]=n}for(var r=0,o=arguments.length;r<o;r++)f(arguments[r],n);return t},extend:function(e,t,n){return f(t,(function(t,o){e[o]=n&&"function"==typeof t?r(t,n):t})),e},trim:function(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e}}},163:function(e,t,n){var r,o; /*! * js-logger - http://github.com/jonnyreeves/js-logger * Jonny Reeves, http://jonnyreeves.co.uk/ * js-logger may be freely distributed under the MIT license. */!function(i){"use strict";var a,s={};s.VERSION="1.6.1";var u={},c=function(e,t){return function(){return t.apply(e,arguments)}},f=function(){var e,t,n=arguments,r=n[0];for(t=1;t<n.length;t++)for(e in n[t])!(e in r)&&n[t].hasOwnProperty(e)&&(r[e]=n[t][e]);return r},l=function(e,t){return{value:e,name:t}};s.TRACE=l(1,"TRACE"),s.DEBUG=l(2,"DEBUG"),s.INFO=l(3,"INFO"),s.TIME=l(4,"TIME"),s.WARN=l(5,"WARN"),s.ERROR=l(8,"ERROR"),s.OFF=l(99,"OFF");var p=function(e){this.context=e,this.setLevel(e.filterLevel),this.log=this.info};p.prototype={setLevel:function(e){e&&"value"in e&&(this.context.filterLevel=e)},getLevel:function(){return this.context.filterLevel},enabledFor:function(e){var t=this.context.filterLevel;return e.value>=t.value},trace:function(){this.invoke(s.TRACE,arguments)},debug:function(){this.invoke(s.DEBUG,arguments)},info:function(){this.invoke(s.INFO,arguments)},warn:function(){this.invoke(s.WARN,arguments)},error:function(){this.invoke(s.ERROR,arguments)},time:function(e){"string"==typeof e&&e.length>0&&this.invoke(s.TIME,[e,"start"])},timeEnd:function(e){"string"==typeof e&&e.length>0&&this.invoke(s.TIME,[e,"end"])},invoke:function(e,t){a&&this.enabledFor(e)&&a(t,f({level:e},this.context))}};var _,d=new p({filterLevel:s.OFF});(_=s).enabledFor=c(d,d.enabledFor),_.trace=c(d,d.trace),_.debug=c(d,d.debug),_.time=c(d,d.time),_.timeEnd=c(d,d.timeEnd),_.info=c(d,d.info),_.warn=c(d,d.warn),_.error=c(d,d.error),_.log=_.info,s.setHandler=function(e){a=e},s.setLevel=function(e){for(var t in d.setLevel(e),u)u.hasOwnProperty(t)&&u[t].setLevel(e)},s.getLevel=function(){return d.getLevel()},s.get=function(e){return u[e]||(u[e]=new p(f({name:e},d.context)))},s.createDefaultHandler=function(e){(e=e||{}).formatter=e.formatter||function(e,t){t.name&&e.unshift("["+t.name+"]")};var t={},n=function(e,t){Function.prototype.apply.call(e,console,t)};return"undefined"==typeof console?function(){}:function(r,o){r=Array.prototype.slice.call(r);var i,a=console.log;o.level===s.TIME?(i=(o.name?"["+o.name+"] ":"")+r[0],"start"===r[1]?console.time?console.time(i):t[i]=(new Date).getTime():console.timeEnd?console.timeEnd(i):n(a,[i+": "+((new Date).getTime()-t[i])+"ms"])):(o.level===s.WARN&&console.warn?a=console.warn:o.level===s.ERROR&&console.error?a=console.error:o.level===s.INFO&&console.info?a=console.info:o.level===s.DEBUG&&console.debug?a=console.debug:o.level===s.TRACE&&console.trace&&(a=console.trace),e.formatter(r,o),n(a,r))}},s.useDefaults=function(e){s.setLevel(e&&e.defaultLevel||s.DEBUG),s.setHandler(s.createDefaultHandler(e))},s.setDefaults=s.useDefaults,void 0===(o="function"==typeof(r=s)?r.call(t,n,t,e):r)||(e.exports=o)}()},271:()=>{}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r].call(i.exports,i,i.exports,n),i.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var r={};return(()=>{"use strict";n.d(r,{default:()=>k});var e=n(163),t=n.n(e);t().useDefaults({defaultLevel:t().ERROR});var o=function(e){return e?t().get(e):t()},i=function(e,t){o(t).setLevel(e)},a=function(e){var t={};return Object.keys(e).forEach((function(n){var r,o=e[n];Array.isArray(o)?o=o.map((function(e){return a(e)})):"object"==typeof o&&(o=a(o)),t[(r=n,r.replace(/([A-Z])/g,"_$1").toLowerCase())]=o})),t},s=n(206),u=n.n(s),c=function(){return(c=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},f=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},l=function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},p={"Content-Type":"application/json"};u().interceptors.request.use((function(e){return Object.assign(e.headers,{}),e}),(function(e){return Promise.reject(e)})),u().interceptors.response.use((function(e){return e}),(function(e){return Promise.reject(e)}));var _,d,E=function(e){var t=e.path,r=e.method,o=void 0===r?"GET":r,i=e.data,a=e.headers,s=void 0===a?{}:a,_=e.certs;return f(void 0,void 0,void 0,(function(){var e,r;return l(this,(function(a){return _&&(r=n(271),e=new r.Agent(c({rejectUnauthorized:!1},_))),[2,u()({url:t,method:o,data:i||{},headers:Object.assign({},p,s),httpsAgent:e})]}))}))};!function(e){e.V1="v1",e.V2="v2"}(d||(d={}));var h,T,A=((_={})[d.V1]="",_[d.V2]="v2",_),R="This function is deprecated and will be deleted in the next version.",I=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},O=function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},N=function(){function e(e,t){this.path=t;var n=e.endpoint,r=e.certs;this.endpoint=n,this.certs=r,this.initLogger(this.getEndpoint())}return e.prototype.getEndpoint=function(e){return[this.endpoint,A[e||this.path.defaultVersion],this.path.gatewayRoute].filter((function(e){return!!e})).join("/")},e.prototype.initLogger=function(e){var t=e.split("/"),n=t[t.length-1].split("_").map((function(e){return function(e){return"string"!=typeof e?"":e.charAt(0).toUpperCase()+e.slice(1)}(e)})).join(" ");this.logger=o(n),this.logger.debug("Initialized")},e.prototype.makeRequest=function(e,t,n,r){var o,i,a;return I(this,void 0,void 0,(function(){var s,u;return O(this,(function(c){switch(c.label){case 0:return c.trys.push([0,2,,3]),this.logger.debug("Sending request to "+e,n),[4,E({path:this.getEndpoint(r)+"/"+e,method:t,data:n,certs:this.certs})];case 1:return s=c.sent(),this.logger.debug("Response success:",s.data),[2,s.data];case 2:return u=c.sent(),this.logger.error("Error in response:",null===(i=null===(o=u.response)||void 0===o?void 0:o.data)||void 0===i?void 0:i.message),[2,Promise.reject(null===(a=u.response)||void 0===a?void 0:a.data)];case 3:return[2]}}))}))},e}();!function(e){e.SETTLEMENT_REQUEST="SettlementRequest",e.TRANSFER_REQUEST="TransferRequest",e.CONDITIONAL_TRANSFER_REQUEST="ConditionalTransferRequest",e.DEPOSIT_REQUEST="DepositRequest",e.MINT_REQUEST="MintRequest",e.WITHDRAWAL_REQUEST="WithdrawalRequest",e.FULL_WITHDRAWAL_REQUEST="FullWithdrawalRequest",e.FALSE_FULL_WITHDRAWAL_REQUEST="FalseFullWithdrawalRequest",e.MULTI_TRANSACTION_REQUEST="MultiTransactionRequest"}(h||(h={})),function(e){e.ADD_TRANSACTION="add_transaction",e.GET_TRANSACTION="get_transaction",e.IS_ALIVE="is_alive",e.GET_FIRST_UNUSED_TX_ID="testing/get_first_unused_tx_id",e.GET_STARK_DEX_ADDRESS="testing/get_stark_dex_address",e.MARK_TRANSACTION_FOR_REPLACEMENT="mark_transaction_for_replacement"}(T||(T={}));var y,v,m,S=(y=function(e,t){return(y=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}y(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),g=function(){return(g=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},D=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},L=function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},b=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n},C=function(e){function t(t){return e.call(this,t,{gatewayRoute:"gateway",defaultVersion:d.V2})||this}return S(t,e),t.prototype.getTransaction=function(e){return this.makeRequest(T.GET_TRANSACTION+"?tx_id="+e)},t.prototype.getStarkDexAddress=function(){return this.makeRequest(T.GET_STARK_DEX_ADDRESS)},t.prototype.getFirstUnusedTxId=function(){return this.makeRequest(T.GET_FIRST_UNUSED_TX_ID)},t.prototype.markTransactionForReplacement=function(e){return this.makeRequest(T.MARK_TRANSACTION_FOR_REPLACEMENT+"?tx_id="+e,"POST")},t.prototype.isAlive=function(){return this.makeRequest(T.IS_ALIVE)},t.prototype.withdrawal=function(e){return this.addTransaction(h.WITHDRAWAL_REQUEST,e)},t.prototype.deposit=function(e){return this.addTransaction(h.DEPOSIT_REQUEST,e)},t.prototype.mint=function(e){return this.addTransaction(h.MINT_REQUEST,e)},t.prototype.settlement=function(e){return this.addTransaction(h.SETTLEMENT_REQUEST,e)},t.prototype.transfer=function(e){return this.addTransaction(h.TRANSFER_REQUEST,e)},t.prototype.conditionalTransfer=function(e){return this.addTransaction(h.CONDITIONAL_TRANSFER_REQUEST,e)},t.prototype.fullWithdrawal=function(e){return this.addTransaction(h.FULL_WITHDRAWAL_REQUEST,e)},t.prototype.falseFullWithdrawal=function(e){return this.addTransaction(h.FALSE_FULL_WITHDRAWAL_REQUEST,e)},t.prototype.multiTransaction=function(e){return this.addTransaction(h.MULTI_TRANSACTION_REQUEST,e)},t.prototype.addTransaction=function(e,t){return D(this,void 0,void 0,(function(){var n,r,o,i,s;return L(this,(function(u){switch(u.label){case 0:n=t.txId,r=b(t,["txId"]),o=a(r),u.label=1;case 1:return u.trys.push([1,3,,4]),[4,this.makeRequest(T.ADD_TRANSACTION,"POST",{tx:g({type:e},o),tx_id:n})];case 2:return i=u.sent(),[2,g({txId:n},i)];case 3:return s=u.sent(),[2,Promise.reject(g(g({},s),{txId:n}))];case 4:return[2]}}))}))},t}(N);!function(e){e[e.SETTLEMENT=0]="SETTLEMENT",e[e.TRANSFER=1]="TRANSFER"}(v||(v={})),function(e){e.IS_READY="is_ready",e.IS_ALIVE="is_alive",e.GET_BATCH_ENCLOSING_IDS="get_batch_enclosing_ids",e.GET_BATCH_IDS="get_batch_ids",e.GET_BATCH_INFO="get_batch_info",e.GET_LAST_BATCH_ID="get_last_batch_id",e.GET_PREV_BATCH_ID="get_prev_batch_id"}(m||(m={}));var w,U=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),x=function(e){function t(t){return e.call(this,t,{gatewayRoute:"feeder_gateway",defaultVersion:d.V2})||this}return U(t,e),t.prototype.isAlive=function(){return this.makeRequest(""+m.IS_ALIVE)},t.prototype.isReady=function(){return this.makeRequest(""+m.IS_READY)},t.prototype.getBatchEnclosingIds=function(e){return this.makeRequest(m.GET_BATCH_ENCLOSING_IDS+"?batch_id="+e)},t.prototype.DEPRECATED_getBatchIds=function(e){this.logger.error("DEPRECATED_getBatchIds: "+R);var t=e.vaultRoot,n=e.orderRoot,r=e.sequenceNumber;return this.makeRequest(m.GET_BATCH_IDS+"?vault_root="+t+"&order_root="+n+"&sequence_number="+r,"GET",void 0,d.V1)},t.prototype.DEPRECATED_getBatchInfo=function(e){return this.logger.error("DEPRECATED_getBatchInfo: "+R),this.makeRequest(m.GET_BATCH_INFO+"?batch_id="+e,"GET",void 0,d.V1)},t.prototype.getBatchInfo=function(e){return this.makeRequest(m.GET_BATCH_INFO+"?batch_id="+e)},t.prototype.getLastBatchId=function(){return this.makeRequest(""+m.GET_LAST_BATCH_ID)},t.prototype.getPrevBatchId=function(e){return this.makeRequest(m.GET_PREV_BATCH_ID+"?batch_id="+e)},t}(N);!function(e){e.APPROVE_NEW_ROOTS="approve_new_roots",e.GET_BATCH_DATA="get_batch_data"}(w||(w={}));var F,P=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();!function(e){function t(t){return e.call(this,t,{gatewayRoute:"availability_gateway",defaultVersion:d.V1})||this}P(t,e),t.prototype.approveNewRoots=function(e){var t=a(e);return this.makeRequest(w.APPROVE_NEW_ROOTS,"POST",t)},t.prototype.getBatchData=function(e){return this.makeRequest(w.GET_BATCH_DATA+"?batch_id="+e)}}(N);!function(e){e[e.API_FUNCTION_TEMPORARILY_DISABLED=0]="API_FUNCTION_TEMPORARILY_DISABLED",e[e.BATCH_CREATION_FAILURE=1]="BATCH_CREATION_FAILURE",e[e.BATCH_FULL=2]="BATCH_FULL",e[e.BATCH_NOT_READY=3]="BATCH_NOT_READY",e[e.CONFLICTING_ORDER_AMOUNTS=4]="CONFLICTING_ORDER_AMOUNTS",e[e.FACT_NOT_REGISTERED=5]="FACT_NOT_REGISTERED",e[e.INSUFFICIENT_ONCHAIN_BALANCE=6]="INSUFFICIENT_ONCHAIN_BALANCE",e[e.INVALID_BATCH_ID=7]="INVALID_BATCH_ID",e[e.INVALID_CLAIM_HASH=8]="INVALID_CLAIM_HASH",e[e.INVALID_COMMITTEE_MEMBER=9]="INVALID_COMMITTEE_MEMBER",e[e.INVALID_CONTRACT_ADDRESS=10]="INVALID_CONTRACT_ADDRESS",e[e.INVALID_CONTRACT_RESPONSE=11]="INVALID_CONTRACT_RESPONSE",e[e.INVALID_DEPLOYMENT_INFO=12]="INVALID_DEPLOYMENT_INFO",e[e.INVALID_ETH_ADDRESS=13]="INVALID_ETH_ADDRESS",e[e.INVALID_FACT=14]="INVALID_FACT",e[e.INVALID_FEE_TAKEN=15]="INVALID_FEE_TAKEN",e[e.INVALID_ORDER_ID=16]="INVALID_ORDER_ID",e[e.INVALID_ORDER_TYPE=17]="INVALID_ORDER_TYPE",e[e.INVALID_REQUEST=18]="INVALID_REQUEST",e[e.INVALID_REQUEST_PARAMETERS=19]="INVALID_REQUEST_PARAMETERS",e[e.INVALID_SETTLEMENT_INFO=20]="INVALID_SETTLEMENT_INFO",e[e.INVALID_SETTLEMENT_RATIO=21]="INVALID_SETTLEMENT_RATIO",e[e.INVALID_SETTLEMENT_TOKENS=22]="INVALID_SETTLEMENT_TOKENS",e[e.INVALID_SIGNATURE=23]="INVALID_SIGNATURE",e[e.INVALID_TRANSACTION=24]="INVALID_TRANSACTION",e[e.INVALID_TRANSACTION_ID=25]="INVALID_TRANSACTION_ID",e[e.INVALID_VAULT=26]="INVALID_VAULT",e[e.MALFORMED_REQUEST=27]="MALFORMED_REQUEST",e[e.MIGRATED_PIPELINE_OBJECT_MISSING=28]="MIGRATED_PIPELINE_OBJECT_MISSING",e[e.MISSING_FEE_OBJECT=29]="MISSING_FEE_OBJECT",e[e.ORDER_OVERDUE=30]="ORDER_OVERDUE",e[e.OUT_OF_RANGE_AMOUNT=32]="OUT_OF_RANGE_AMOUNT",e[e.OUT_OF_RANGE_BALANCE=33]="OUT_OF_RANGE_BALANCE",e[e.OUT_OF_RANGE_BATCH_ID=34]="OUT_OF_RANGE_BATCH_ID",e[e.OUT_OF_RANGE_ETH_ADDRESS=35]="OUT_OF_RANGE_ETH_ADDRESS",e[e.OUT_OF_RANGE_EXPIRATION_TIMESTAMP=36]="OUT_OF_RANGE_EXPIRATION_TIMESTAMP",e[e.OUT_OF_RANGE_NONCE=37]="OUT_OF_RANGE_NONCE",e[e.OUT_OF_RANGE_ORACLE_PRICE_QUORUM=38]="OUT_OF_RANGE_ORACLE_PRICE_QUORUM",e[e.OUT_OF_RANGE_ORDER_ID=39]="OUT_OF_RANGE_ORDER_ID",e[e.OUT_OF_RANGE_POSITIVE_AMOUNT=31]="OUT_OF_RANGE_POSITIVE_AMOUNT",e[e.OUT_OF_RANGE_PUBLIC_KEY=40]="OUT_OF_RANGE_PUBLIC_KEY",e[e.OUT_OF_RANGE_SIGNATURE_SUBFIELD=41]="OUT_OF_RANGE_SIGNATURE_SUBFIELD",e[e.OUT_OF_RANGE_TOKEN_ID=42]="OUT_OF_RANGE_TOKEN_ID",e[e.OUT_OF_RANGE_VAULT_ID=43]="OUT_OF_RANGE_VAULT_ID",e[e.REPLACED_BEFORE=44]="REPLACED_BEFORE",e[e.REQUEST_FAILED=45]="REQUEST_FAILED",e[e.SCHEMA_VALIDATION_ERROR=46]="SCHEMA_VALIDATION_ERROR",e[e.TRANSACTION_CANCELLED=47]="TRANSACTION_CANCELLED",e[e.TRANSACTION_PENDING=48]="TRANSACTION_PENDING"}(F||(F={}));var B,G,V,M,j=function(){function e(e){this.gateway=new C(e),this.feederGateway=new x(e)}return e.StarkErrorCode=F,e.GatewayRequestType=h,e}();B="@starkware-industries/starkex-js",G="0.1.0",V="#734d7e",M=function(e){return o(e).getLevel()}(),i(o().INFO),o().log("%c "+B+" v"+G,"color: "+(V||"#ff98f9")+"; font-size: large"),i(M);const k=j})(),r=r.default})()}));