@avalabs/core-utils-sdk 3.1.0-alpha.79 → 3.1.0-alpha.80

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.
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var t=require("big.js"),e=require("bn.js"),n=require("@hpke/core"),r=require("is-ipfs");function o(e,n=0){const r=t(10).pow(n);return new t(e.toString()).div(r)}function i(t,e=9){const n=t.toFixed(e).split("."),r=parseInt(n[0]).toLocaleString("en-US");if(1===n.length)return r;{let t=n[1],o=t.charAt(t.length-1);for(;"0"===o;)t=t.substring(0,t.length-1),o=t.charAt(t.length-1);const i=t.substring(0,e);return i?`${r}.${i}`:r}}const s=new t(10),u=new t(0);function a(t){const n=new e(10).pow(new e(9));return t.mul(n)}function c(t,e=9){return i(o(t,e),e)}function l(t){return c(t,9)}function p(t){return o(t,9)}const h=new n.CipherSuite({kem:new n.DhkemP521HkdfSha512,kdf:new n.HkdfSha512,aead:new n.Aes256Gcm});const f=(t,e,n)=>{const r=(o=n,Object.fromEntries(Object.entries(o).filter((([t,e])=>void 0!==e))));var o;const i=new URLSearchParams(r).toString();return`${t}${e=i?`${e}?${i}`:e}`},d="unsupported ipfs URL pattern",x=t=>{if("string"!=typeof t)throw new Error("url is not string");const e=t.split(/\/|\?/);for(const t of e){if(r.cid(t))return{containsCid:!0,cid:t};const e=t.split(".")[0];if(r.cid(e))return{containsCid:!0,cid:e}}return{containsCid:!1,cid:null}},g=(t,e)=>new Array(e+1).join(t),w=(t,e,n=" ")=>g(n,e-t.toString().length)+t,m=t=>`${w(t.getHours(),2,"0")}:${w(t.getMinutes(),2,"0")}:${w(t.getSeconds(),2,"0")}.${w(t.getMilliseconds(),3,"0")}`,b=()=>m(new Date);function v(n,r){const o=t("string"==typeof n?n.replace(/,/gi,""):n),i=t(10).pow(r);return new e(o.times(i).toFixed(0))}function T(t){return v(t,9)}const B=new t("1e+18");const S=new t("1e+9");const $=t();$.PE=99,$.NE=-18,$.RM=t.roundDown;class y{value;symbol;maxDecimals;constructor(t,e,n){this.value=y.toBig(t).div($(10).pow(e)),this.maxDecimals=e,this.symbol=n}getSymbol(){return this.symbol}getMaxDecimals(){return this.maxDecimals}add(t){return this.cloneWithValue(this.value.add(y.toBig(t)))}sub(t){return this.cloneWithValue(this.value.sub(y.toBig(t)))}mul(t){return this.cloneWithValue(this.value.mul(y.toBig(t)))}div(t){return this.cloneWithValue(this.value.div(y.toBig(t)))}gt(t){return this.value.gt(y.toBig(t))}lt(t){return this.value.lt(y.toBig(t))}eq(t){return this.value.eq(y.toBig(t))}toString(){return this.value.toString()}toDisplay(e){let n;return n=this.value.gte(1e3)?this.value.round(2,t.roundHalfUp).toFixed(e?.fixedDp):this.value.gte(1e-4)?this.value.round(4,t.roundHalfUp).toFixed(e?.fixedDp):this.value.gte(1e-6)?this.value.round(6,t.roundHalfUp).toFixed(e?.fixedDp):this.value.gte(1e-8)?this.value.round(8,t.roundHalfUp).toFixed(e?.fixedDp):this.value.round(this.maxDecimals,t.roundHalfUp).toFixed(e?.fixedDp),e?.asNumber?Number(n):this.toLocaleString(n)}toLocaleString(t){const e=t.split("."),n=e[0];return 1===e.length?n:`${Number(n).toLocaleString("en-US")}.${e[1]}`}isZero(){return this.value.eq(0)}toSubUnit(e){const n=e?this.value.round(this.maxDecimals,t.roundHalfUp):this.value;return BigInt(n.mul(new $(10).pow(this.maxDecimals)).toFixed(0))}static toBig(n){switch(typeof n){case"bigint":return $(BigInt(n).toString());case"string":case"number":return $(n);case"object":if(e.isBN(n))return $(n.toString());if(n instanceof t)return n}return n.value}cloneWithValue(t){return new y(t.mul($(10).pow(this.maxDecimals)),this.maxDecimals,this.symbol)}}exports.BIG_TEN=s,exports.BIG_ZERO=u,exports.HttpClient=class{constructor(t,e={}){this.baseURL=t;const{headers:n,...r}=e;this.headerOptions=n,this.nonHeaderOptions=r}TIMEOUT=1e4;headerOptions;nonHeaderOptions;get(t,e={},n={}){const r=f(this.baseURL,t,e),{headers:o,...i}=n,s={method:"GET",headers:{"Content-Type":"application/json",...this.headerOptions,...o},...this.nonHeaderOptions,...i};return this.handleResponse(this.fetchWithTimeout(r,s))}post(t,e,n={},r={}){const o=f(this.baseURL,t,r),{headers:i,...s}=n,u={method:"POST",headers:{"Content-Type":"application/json",...this.headerOptions,...i},...this.nonHeaderOptions,...s,body:"string"==typeof e?e:JSON.stringify(e)};return this.handleResponse(this.fetchWithTimeout(o,u))}async handleResponse(t){const e=await t;if(e.ok)return await e.json();{const t=await e.text();return Promise.reject(new Error(t))}}async fetchWithTimeout(t,e={}){const{timeout:n=this.TIMEOUT}=e,r=new AbortController,o=setTimeout((()=>r.abort()),n),i=await fetch(t,{...e,signal:r.signal});return clearTimeout(o),i}},exports.TokenUnit=y,exports.UNSUPPORTED_URL_ERROR=d,exports.avaxCtoX=function(t){const n=new e(10).pow(new e(9));return t.div(n)},exports.avaxPtoC=function(t){return a(t)},exports.avaxXtoC=a,exports.balanceToDisplayValue=function(t,e){const n=o(t,e);return n.gte(1e3)?i(n,2):n.gte(1e-4)?i(n,4):i(n,e-t.toString().length+1)},exports.bigIntToString=function(t,e){e=Math.floor(e);const n=t.toString(),r=Math.max(n.length-e,0),o=n.slice(r).padStart(e,"0"),i=n.slice(0,r)||"0";return o.length?`${i}.${o}`:i},exports.bigToBN=function(n,r){const o=Math.floor(r);if(o<0)throw new Error("Denomination can not be less that 0.");const i=n.mul(t(10).pow(o)).toFixed(0,0);return new e(i)},exports.bigToBigInt=function(e,n){const r=Math.floor(n);if(r<0)throw new Error("Denomination can not be less that 0.");const o=e.mul(t(10).pow(r)).toFixed(0,0);return BigInt(o)},exports.bigToLocaleString=i,exports.bigintToBig=function(t,n){return o(new e.BN(t.toString()),n)},exports.bnToAvaxC=function(t){return c(t,18)},exports.bnToAvaxP=function(t){return l(t)},exports.bnToAvaxX=l,exports.bnToBig=o,exports.bnToBigAvaxC=function(t){return o(t,18)},exports.bnToBigAvaxP=function(t){return p(t)},exports.bnToBigAvaxX=p,exports.bnToLocaleString=c,exports.encryptAnalyticsData=async function(t,e,n){if(!t||!e)throw new Error("Encryption setting missing");const r=await h.kem.deserializePublicKey(Buffer.from(e,"base64")),o=await h.createSenderContext({recipientPublicKey:r}),i=(new TextEncoder).encode(t),s=(new TextEncoder).encode(n),u=await o.seal(s,i);return{data:Buffer.from(u).toString("base64"),enc:Buffer.from(o.enc).toString("base64"),keyID:t}},exports.formatAndLog=function(t,e,n){console.groupCollapsed("%c%s %s",((t,e=!0)=>`color:${t};font-weight:${e?"600":"300"};font-size:11px`)(n?.color??"#cccccc"),b(),t),console.log(e),console.groupEnd()},exports.formatTime=m,exports.hexToBN=function(t){return t.match("0x")?new e.BN(BigInt(t)):new e.BN(t,"hex")},exports.hexToBytes=function(t){return t?(t.length-2)/2:null},exports.ipfsResolver=(t,e)=>{const n=x(t);if(!n.cid||!0!==n.containsCid)throw new Error("url does not contain CID");const r=t.split(n.cid);if(t.includes(`ipfs://${n.cid}`))return`${e}/ipfs/${n.cid}${r[1]}`;if(t.includes(`/ipfs/${n.cid}`))return`${e}/ipfs/${n.cid}${r[1]}`;if(t.includes(`/ipns/${n.cid}`))return`${e}/ipns/${n.cid}${r[1]}`;if(t.includes(`${n.cid}.ipfs`)){const r=new URL(t).pathname;return`${e}/ipfs/${n.cid}${r}`}throw new Error(d)},exports.noop=()=>{},exports.now=b,exports.numberToBN=v,exports.numberToBNAvaxC=function(t){return v(t,18)},exports.numberToBNAvaxP=function(t){return T(t)},exports.numberToBNAvaxX=T,exports.padStart=w,exports.promiseResolveWithBackoff=async function t(e,n,r=0,o=10){try{const i=await function(t,e=0){return new Promise(((n,r)=>{setTimeout((()=>{t().then((t=>n(t))).catch((t=>r(t)))}),500*e)}))}(e,r);return o===r+1?i:n(i)?t(e,n,r+1,o):i}catch(i){if(o===r+1)throw"string"==typeof i?new Error(i):i;if(n(i))return t(e,n,r+1,o);throw"string"==typeof i?new Error(i):i}},exports.repeat=g,exports.resolve=async function(t){try{return[await t,null]}catch(t){return[null,t]}},exports.stringToBN=function(n,r){const o=t(n.replace(/,/gi,"")),i=t(10).pow(r),s=o.times(i).toFixed(0,0);return new e(s)},exports.strip0x=function(t){return"0x"===t.substring(0,2)?t.substring(2):t},exports.truncateAddress=(t,e=6)=>`${t.substring(0,e)}…${t.slice(-e/2)}`,exports.urlContainsCID=x,exports.wait=function(t){return new Promise((e=>setTimeout(e,t)))},exports.weiToAvax=function(t){return t.div(B)},exports.weiToNAvax=function(t){return t.div(S)};
1
+ "use strict";var t=require("big.js"),e=require("bn.js"),n=require("@hpke/core"),r=require("is-ipfs");function o(e,n=0){const r=t(10).pow(n);return new t(e.toString()).div(r)}function i(t,e=9){const n=t.toFixed(e).split("."),r=parseInt(n[0]).toLocaleString("en-US");if(1===n.length)return r;{let t=n[1],o=t.charAt(t.length-1);for(;"0"===o;)t=t.substring(0,t.length-1),o=t.charAt(t.length-1);const i=t.substring(0,e);return i?`${r}.${i}`:r}}const s=new t(10),u=new t(0);function a(t){const n=new e(10).pow(new e(9));return t.mul(n)}function c(t,e=9){return i(o(t,e),e)}function l(t){return c(t,9)}function p(t){return o(t,9)}const h=new n.CipherSuite({kem:new n.DhkemP521HkdfSha512,kdf:new n.HkdfSha512,aead:new n.Aes256Gcm});const f=(t,e,n)=>{const r=(o=n,Object.fromEntries(Object.entries(o).filter((([t,e])=>void 0!==e))));var o;const i=new URLSearchParams(r).toString();return`${t}${e=i?`${e}?${i}`:e}`},d="unsupported ipfs URL pattern",g=t=>{if("string"!=typeof t)throw new Error("url is not string");const e=t.split(/\/|\?/);for(const t of e){if(r.cid(t))return{containsCid:!0,cid:t};const e=t.split(".")[0];if(r.cid(e))return{containsCid:!0,cid:e}}return{containsCid:!1,cid:null}},x=(t,e)=>new Array(e+1).join(t),w=(t,e,n=" ")=>x(n,e-t.toString().length)+t,m=t=>`${w(t.getHours(),2,"0")}:${w(t.getMinutes(),2,"0")}:${w(t.getSeconds(),2,"0")}.${w(t.getMilliseconds(),3,"0")}`,b=()=>m(new Date);function v(n,r){const o=t("string"==typeof n?n.replace(/,/gi,""):n),i=t(10).pow(r);return new e(o.times(i).toFixed(0))}function T(t){return v(t,9)}const B=new t("1e+18");const S=new t("1e+9");const $=t();$.PE=99,$.NE=-18,$.RM=t.roundDown;class y{value;symbol;maxDecimals;constructor(t,e,n){this.value=y.toBig(t).div($(10).pow(e)),this.maxDecimals=e,this.symbol=n}getSymbol(){return this.symbol}getMaxDecimals(){return this.maxDecimals}add(t){return this.cloneWithValue(this.value.add(y.toBig(t)))}sub(t){return this.cloneWithValue(this.value.sub(y.toBig(t)))}mul(t){return this.cloneWithValue(this.value.mul(y.toBig(t)))}div(t){return this.cloneWithValue(this.value.div(y.toBig(t)))}gt(t){return this.value.gt(y.toBig(t))}lt(t){return this.value.lt(y.toBig(t))}eq(t){return this.value.eq(y.toBig(t))}toString(){return this.value.toString()}toDisplay(e){let n;return n=this.value.gte(1e3)?this.value.round(2,t.roundHalfUp).toFixed(e?.fixedDp):this.value.gte(1e-4)?this.value.round(4,t.roundHalfUp).toFixed(e?.fixedDp):this.value.gte(1e-6)?this.value.round(6,t.roundHalfUp).toFixed(e?.fixedDp):this.value.gte(1e-8)?this.value.round(8,t.roundHalfUp).toFixed(e?.fixedDp):this.value.round(this.maxDecimals,t.roundHalfUp).toFixed(e?.fixedDp),e?.asNumber?Number(n):this.toLocaleString(n)}toLocaleString(t){const e=t.split("."),n=e[0];return 1===e.length?n:`${Number(n).toLocaleString("en-US")}.${e[1]}`}isZero(){return this.value.eq(0)}toSubUnit(e){const n=e?this.value.round(this.maxDecimals,t.roundHalfUp):this.value;return BigInt(n.mul(new $(10).pow(this.maxDecimals)).toFixed(0))}static toBig(n){switch(typeof n){case"bigint":return $(BigInt(n).toString());case"string":case"number":return $(n);case"object":if(e.isBN(n))return $(n.toString());if(n instanceof t)return n}return n.value}cloneWithValue(t){return new y(t.mul($(10).pow(this.maxDecimals)),this.maxDecimals,this.symbol)}}exports.BIG_TEN=s,exports.BIG_ZERO=u,exports.HttpClient=class{constructor(t,e={},n){this.baseURL=t;const{headers:r,...o}=e;this.headerOptions=r,this.nonHeaderOptions=o,this.#t=n??globalThis.fetch}TIMEOUT=1e4;headerOptions;nonHeaderOptions;#t;get(t,e={},n={}){const r=f(this.baseURL,t,e),{headers:o,...i}=n,s={method:"GET",headers:{"Content-Type":"application/json",...this.headerOptions,...o},...this.nonHeaderOptions,...i};return this.handleResponse(this.fetchWithTimeout(r,s))}post(t,e,n={},r={}){const o=f(this.baseURL,t,r),{headers:i,...s}=n,u={method:"POST",headers:{"Content-Type":"application/json",...this.headerOptions,...i},...this.nonHeaderOptions,...s,body:"string"==typeof e?e:JSON.stringify(e)};return this.handleResponse(this.fetchWithTimeout(o,u))}async handleResponse(t){const e=await t;if(e.ok)return await e.json();{const t=await e.text();return Promise.reject(new Error(t))}}async fetchWithTimeout(t,e={}){const{timeout:n=this.TIMEOUT}=e,r=new AbortController,o=setTimeout((()=>r.abort()),n),i=await this.#t(t,{...e,signal:r.signal});return clearTimeout(o),i}},exports.TokenUnit=y,exports.UNSUPPORTED_URL_ERROR=d,exports.avaxCtoX=function(t){const n=new e(10).pow(new e(9));return t.div(n)},exports.avaxPtoC=function(t){return a(t)},exports.avaxXtoC=a,exports.balanceToDisplayValue=function(t,e){const n=o(t,e);return n.gte(1e3)?i(n,2):n.gte(1e-4)?i(n,4):i(n,e-t.toString().length+1)},exports.bigIntToString=function(t,e){e=Math.floor(e);const n=t.toString(),r=Math.max(n.length-e,0),o=n.slice(r).padStart(e,"0"),i=n.slice(0,r)||"0";return o.length?`${i}.${o}`:i},exports.bigToBN=function(n,r){const o=Math.floor(r);if(o<0)throw new Error("Denomination can not be less that 0.");const i=n.mul(t(10).pow(o)).toFixed(0,0);return new e(i)},exports.bigToBigInt=function(e,n){const r=Math.floor(n);if(r<0)throw new Error("Denomination can not be less that 0.");const o=e.mul(t(10).pow(r)).toFixed(0,0);return BigInt(o)},exports.bigToLocaleString=i,exports.bigintToBig=function(t,n){return o(new e.BN(t.toString()),n)},exports.bnToAvaxC=function(t){return c(t,18)},exports.bnToAvaxP=function(t){return l(t)},exports.bnToAvaxX=l,exports.bnToBig=o,exports.bnToBigAvaxC=function(t){return o(t,18)},exports.bnToBigAvaxP=function(t){return p(t)},exports.bnToBigAvaxX=p,exports.bnToLocaleString=c,exports.encryptAnalyticsData=async function(t,e,n){if(!t||!e)throw new Error("Encryption setting missing");const r=await h.kem.deserializePublicKey(Buffer.from(e,"base64")),o=await h.createSenderContext({recipientPublicKey:r}),i=(new TextEncoder).encode(t),s=(new TextEncoder).encode(n),u=await o.seal(s,i);return{data:Buffer.from(u).toString("base64"),enc:Buffer.from(o.enc).toString("base64"),keyID:t}},exports.formatAndLog=function(t,e,n){console.groupCollapsed("%c%s %s",((t,e=!0)=>`color:${t};font-weight:${e?"600":"300"};font-size:11px`)(n?.color??"#cccccc"),b(),t),console.log(e),console.groupEnd()},exports.formatTime=m,exports.hexToBN=function(t){return t.match("0x")?new e.BN(BigInt(t)):new e.BN(t,"hex")},exports.hexToBytes=function(t){return t?(t.length-2)/2:null},exports.ipfsResolver=(t,e)=>{const n=g(t);if(!n.cid||!0!==n.containsCid)throw new Error("url does not contain CID");const r=t.split(n.cid);if(t.includes(`ipfs://${n.cid}`))return`${e}/ipfs/${n.cid}${r[1]}`;if(t.includes(`/ipfs/${n.cid}`))return`${e}/ipfs/${n.cid}${r[1]}`;if(t.includes(`/ipns/${n.cid}`))return`${e}/ipns/${n.cid}${r[1]}`;if(t.includes(`${n.cid}.ipfs`)){const r=new URL(t).pathname;return`${e}/ipfs/${n.cid}${r}`}throw new Error(d)},exports.noop=()=>{},exports.now=b,exports.numberToBN=v,exports.numberToBNAvaxC=function(t){return v(t,18)},exports.numberToBNAvaxP=function(t){return T(t)},exports.numberToBNAvaxX=T,exports.padStart=w,exports.promiseResolveWithBackoff=async function t(e,n,r=0,o=10){try{const i=await function(t,e=0){return new Promise(((n,r)=>{setTimeout((()=>{t().then((t=>n(t))).catch((t=>r(t)))}),500*e)}))}(e,r);return o===r+1?i:n(i)?t(e,n,r+1,o):i}catch(i){if(o===r+1)throw"string"==typeof i?new Error(i):i;if(n(i))return t(e,n,r+1,o);throw"string"==typeof i?new Error(i):i}},exports.repeat=x,exports.resolve=async function(t){try{return[await t,null]}catch(t){return[null,t]}},exports.stringToBN=function(n,r){const o=t(n.replace(/,/gi,"")),i=t(10).pow(r),s=o.times(i).toFixed(0,0);return new e(s)},exports.strip0x=function(t){return"0x"===t.substring(0,2)?t.substring(2):t},exports.truncateAddress=(t,e=6)=>`${t.substring(0,e)}…${t.slice(-e/2)}`,exports.urlContainsCID=g,exports.wait=function(t){return new Promise((e=>setTimeout(e,t)))},exports.weiToAvax=function(t){return t.div(B)},exports.weiToNAvax=function(t){return t.div(S)};
package/dist/index.d.ts CHANGED
@@ -110,11 +110,12 @@ type HttpOptions = RequestInit & {
110
110
  timeout?: number;
111
111
  };
112
112
  declare class HttpClient {
113
+ #private;
113
114
  private readonly baseURL;
114
115
  private TIMEOUT;
115
116
  private headerOptions;
116
117
  private nonHeaderOptions;
117
- constructor(baseURL: string, options?: HttpOptions);
118
+ constructor(baseURL: string, options?: HttpOptions, fetchFn?: typeof fetch);
118
119
  get<T>(path: string, params?: Record<string, any>, customOptions?: HttpOptions): Promise<T>;
119
120
  post<T>(path: string, data: Record<string, any>, customOptions?: HttpOptions, params?: Record<string, any>): Promise<T>;
120
121
  private handleResponse;
@@ -2,11 +2,12 @@ type HttpOptions = RequestInit & {
2
2
  timeout?: number;
3
3
  };
4
4
  declare class HttpClient {
5
+ #private;
5
6
  private readonly baseURL;
6
7
  private TIMEOUT;
7
8
  private headerOptions;
8
9
  private nonHeaderOptions;
9
- constructor(baseURL: string, options?: HttpOptions);
10
+ constructor(baseURL: string, options?: HttpOptions, fetchFn?: typeof fetch);
10
11
  get<T>(path: string, params?: Record<string, any>, customOptions?: HttpOptions): Promise<T>;
11
12
  post<T>(path: string, data: Record<string, any>, customOptions?: HttpOptions, params?: Record<string, any>): Promise<T>;
12
13
  private handleResponse;
package/esm/httpClient.js CHANGED
@@ -1 +1 @@
1
- class t{constructor(t,e={}){this.baseURL=t;const{headers:s,...n}=e;this.headerOptions=s,this.nonHeaderOptions=n}TIMEOUT=1e4;headerOptions;nonHeaderOptions;get(t,s={},n={}){const o=e(this.baseURL,t,s),{headers:i,...r}=n,a={method:"GET",headers:{"Content-Type":"application/json",...this.headerOptions,...i},...this.nonHeaderOptions,...r};return this.handleResponse(this.fetchWithTimeout(o,a))}post(t,s,n={},o={}){const i=e(this.baseURL,t,o),{headers:r,...a}=n,h={method:"POST",headers:{"Content-Type":"application/json",...this.headerOptions,...r},...this.nonHeaderOptions,...a,body:"string"==typeof s?s:JSON.stringify(s)};return this.handleResponse(this.fetchWithTimeout(i,h))}async handleResponse(t){const e=await t;if(e.ok)return await e.json();{const t=await e.text();return Promise.reject(new Error(t))}}async fetchWithTimeout(t,e={}){const{timeout:s=this.TIMEOUT}=e,n=new AbortController,o=setTimeout((()=>n.abort()),s),i=await fetch(t,{...e,signal:n.signal});return clearTimeout(o),i}}const e=(t,e,s)=>{const n=(o=s,Object.fromEntries(Object.entries(o).filter((([t,e])=>void 0!==e))));var o;const i=new URLSearchParams(n).toString();return`${t}${e=i?`${e}?${i}`:e}`};export{t as HttpClient};
1
+ class t{constructor(t,e={},s){this.baseURL=t;const{headers:n,...o}=e;this.headerOptions=n,this.nonHeaderOptions=o,this.#t=s??globalThis.fetch}TIMEOUT=1e4;headerOptions;nonHeaderOptions;#t;get(t,s={},n={}){const o=e(this.baseURL,t,s),{headers:i,...r}=n,a={method:"GET",headers:{"Content-Type":"application/json",...this.headerOptions,...i},...this.nonHeaderOptions,...r};return this.handleResponse(this.fetchWithTimeout(o,a))}post(t,s,n={},o={}){const i=e(this.baseURL,t,o),{headers:r,...a}=n,h={method:"POST",headers:{"Content-Type":"application/json",...this.headerOptions,...r},...this.nonHeaderOptions,...a,body:"string"==typeof s?s:JSON.stringify(s)};return this.handleResponse(this.fetchWithTimeout(i,h))}async handleResponse(t){const e=await t;if(e.ok)return await e.json();{const t=await e.text();return Promise.reject(new Error(t))}}async fetchWithTimeout(t,e={}){const{timeout:s=this.TIMEOUT}=e,n=new AbortController,o=setTimeout((()=>n.abort()),s),i=await this.#t(t,{...e,signal:n.signal});return clearTimeout(o),i}}const e=(t,e,s)=>{const n=(o=s,Object.fromEntries(Object.entries(o).filter((([t,e])=>void 0!==e))));var o;const i=new URLSearchParams(n).toString();return`${t}${e=i?`${e}?${i}`:e}`};export{t as HttpClient};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@avalabs/core-utils-sdk",
3
- "version": "3.1.0-alpha.79",
3
+ "version": "3.1.0-alpha.80",
4
4
  "license": "Limited Ecosystem License",
5
5
  "private": false,
6
6
  "type": "module",
@@ -44,5 +44,5 @@
44
44
  "bn.js": "^5.2.1",
45
45
  "ethers": "^6.7.1"
46
46
  },
47
- "gitHead": "e0a5a9e7e40c9e4d096f4abdba319b8120f39518"
47
+ "gitHead": "fac1eece40ef40bb0c4d927f95152064afc0ace0"
48
48
  }