@argent/x-shared 1.53.2 → 1.55.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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("lodash-es"),a=require("./HttpError.cjs"),d=require("./IHttpService.cjs");class w{constructor(o,t="json"){this.requestInit=o,this.responseType=t}async get(o,t){const s=h.isFunction(this.requestInit)?await this.requestInit():this.requestInit,r={...s,...t,method:"GET",headers:{...s==null?void 0:s.headers,...t==null?void 0:t.headers}},e=await fetch(o,r).catch(()=>{throw new a.HttpError(d.HTTP_ERROR_MESSAGE.FAILED_TO_FETCH_URL,0)});if(this.responseType==="json"){if(!e.ok)throw new a.HttpError(e.statusText,e.status);return await e.json()}return e}async post(o,t,s){const r=h.isFunction(this.requestInit)?await this.requestInit():this.requestInit,e={...r,...t,method:"POST",headers:{...r==null?void 0:r.headers,...t==null?void 0:t.headers}},n=await fetch(o,e).catch(()=>{throw new a.HttpError(d.HTTP_ERROR_MESSAGE.FAILED_TO_POST_URL,0)});if(!n.ok)throw new a.HttpError(n.statusText,n.status,await n.json());if(n.status===204)return{};const c=await n.json();if(s)try{return s.parse(c)}catch(i){throw new a.HttpError(i.message,0)}return c}async put(o,t){const s=h.isFunction(this.requestInit)?await this.requestInit():this.requestInit,r={...s,...t,method:"PUT",headers:{...s==null?void 0:s.headers,...t==null?void 0:t.headers}},e=await fetch(o,r).catch(()=>{throw new a.HttpError("Failed to put url",0)});if(!e.ok)throw new a.HttpError(e.statusText,e.status);return await e.json()}async delete(o,t){const s=h.isFunction(this.requestInit)?await this.requestInit():this.requestInit,r={...s,...t,method:"DELETE",headers:{...s==null?void 0:s.headers,...t==null?void 0:t.headers}},e=await fetch(o,r).catch(()=>{throw new a.HttpError("Failed to delete url",0)});if(!e.ok)throw new a.HttpError(e.statusText,e.status)}}exports.HTTPService=w;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("lodash-es"),n=require("./HttpError.cjs"),d=require("./IHttpService.cjs");class w{constructor(a,t="json"){this.requestInit=a,this.responseType=t}async get(a,t){const s=i.isFunction(this.requestInit)?await this.requestInit():this.requestInit,r={...s,...t,method:"GET",headers:{...s==null?void 0:s.headers,...t==null?void 0:t.headers}},e=await fetch(a,r).catch(async o=>{let c;throw o instanceof Response&&(c=await o.json().catch(()=>{})),new n.HttpError(d.HTTP_ERROR_MESSAGE.FAILED_TO_FETCH_URL,0,c)});if(this.responseType==="json"){if(!e.ok)throw new n.HttpError(e.statusText,e.status,await e.json().catch(()=>{}));return await e.json()}return e}async post(a,t,s){const r=i.isFunction(this.requestInit)?await this.requestInit():this.requestInit,e={...r,...t,method:"POST",headers:{...r==null?void 0:r.headers,...t==null?void 0:t.headers}},o=await fetch(a,e).catch(()=>{throw new n.HttpError(d.HTTP_ERROR_MESSAGE.FAILED_TO_POST_URL,0)});if(!o.ok)throw new n.HttpError(o.statusText,o.status,await o.json());if(o.status===204)return{};const c=await o.json();if(s)try{return s.parse(c)}catch(h){throw new n.HttpError(h.message,0)}return c}async put(a,t){const s=i.isFunction(this.requestInit)?await this.requestInit():this.requestInit,r={...s,...t,method:"PUT",headers:{...s==null?void 0:s.headers,...t==null?void 0:t.headers}},e=await fetch(a,r).catch(()=>{throw new n.HttpError("Failed to put url",0)});if(!e.ok)throw new n.HttpError(e.statusText,e.status);return await e.json()}async delete(a,t){const s=i.isFunction(this.requestInit)?await this.requestInit():this.requestInit,r={...s,...t,method:"DELETE",headers:{...s==null?void 0:s.headers,...t==null?void 0:t.headers}},e=await fetch(a,r).catch(()=>{throw new n.HttpError("Failed to delete url",0)});if(!e.ok)throw new n.HttpError(e.statusText,e.status)}}exports.HTTPService=w;
@@ -1,12 +1,12 @@
1
- import { isFunction as n } from "lodash-es";
2
- import { HttpError as r } from "./HttpError.js";
1
+ import { isFunction as c } from "lodash-es";
2
+ import { HttpError as h } from "./HttpError.js";
3
3
  import { HTTP_ERROR_MESSAGE as w } from "./IHttpService.js";
4
4
  class m {
5
- constructor(o, t = "json") {
6
- this.requestInit = o, this.responseType = t;
5
+ constructor(r, t = "json") {
6
+ this.requestInit = r, this.responseType = t;
7
7
  }
8
- async get(o, t) {
9
- const s = n(this.requestInit) ? await this.requestInit() : this.requestInit, a = {
8
+ async get(r, t) {
9
+ const s = c(this.requestInit) ? await this.requestInit() : this.requestInit, a = {
10
10
  ...s,
11
11
  ...t,
12
12
  method: "GET",
@@ -15,18 +15,21 @@ class m {
15
15
  ...s == null ? void 0 : s.headers,
16
16
  ...t == null ? void 0 : t.headers
17
17
  }
18
- }, e = await fetch(o, a).catch(() => {
19
- throw new r(w.FAILED_TO_FETCH_URL, 0);
18
+ }, e = await fetch(r, a).catch(async (o) => {
19
+ let n;
20
+ throw o instanceof Response && (n = await o.json().catch(() => {
21
+ })), new h(w.FAILED_TO_FETCH_URL, 0, n);
20
22
  });
21
23
  if (this.responseType === "json") {
22
24
  if (!e.ok)
23
- throw new r(e.statusText, e.status);
25
+ throw new h(e.statusText, e.status, await e.json().catch(() => {
26
+ }));
24
27
  return await e.json();
25
28
  }
26
29
  return e;
27
30
  }
28
- async post(o, t, s) {
29
- const a = n(this.requestInit) ? await this.requestInit() : this.requestInit, e = {
31
+ async post(r, t, s) {
32
+ const a = c(this.requestInit) ? await this.requestInit() : this.requestInit, e = {
30
33
  ...a,
31
34
  ...t,
32
35
  method: "POST",
@@ -35,24 +38,24 @@ class m {
35
38
  ...a == null ? void 0 : a.headers,
36
39
  ...t == null ? void 0 : t.headers
37
40
  }
38
- }, h = await fetch(o, e).catch(() => {
39
- throw new r(w.FAILED_TO_POST_URL, 0);
41
+ }, o = await fetch(r, e).catch(() => {
42
+ throw new h(w.FAILED_TO_POST_URL, 0);
40
43
  });
41
- if (!h.ok)
42
- throw new r(h.statusText, h.status, await h.json());
43
- if (h.status === 204)
44
+ if (!o.ok)
45
+ throw new h(o.statusText, o.status, await o.json());
46
+ if (o.status === 204)
44
47
  return {};
45
- const c = await h.json();
48
+ const n = await o.json();
46
49
  if (s)
47
50
  try {
48
- return s.parse(c);
51
+ return s.parse(n);
49
52
  } catch (i) {
50
- throw new r(i.message, 0);
53
+ throw new h(i.message, 0);
51
54
  }
52
- return c;
55
+ return n;
53
56
  }
54
- async put(o, t) {
55
- const s = n(this.requestInit) ? await this.requestInit() : this.requestInit, a = {
57
+ async put(r, t) {
58
+ const s = c(this.requestInit) ? await this.requestInit() : this.requestInit, a = {
56
59
  ...s,
57
60
  ...t,
58
61
  method: "PUT",
@@ -61,15 +64,15 @@ class m {
61
64
  ...s == null ? void 0 : s.headers,
62
65
  ...t == null ? void 0 : t.headers
63
66
  }
64
- }, e = await fetch(o, a).catch(() => {
65
- throw new r("Failed to put url", 0);
67
+ }, e = await fetch(r, a).catch(() => {
68
+ throw new h("Failed to put url", 0);
66
69
  });
67
70
  if (!e.ok)
68
- throw new r(e.statusText, e.status);
71
+ throw new h(e.statusText, e.status);
69
72
  return await e.json();
70
73
  }
71
- async delete(o, t) {
72
- const s = n(this.requestInit) ? await this.requestInit() : this.requestInit, a = {
74
+ async delete(r, t) {
75
+ const s = c(this.requestInit) ? await this.requestInit() : this.requestInit, a = {
73
76
  ...s,
74
77
  ...t,
75
78
  method: "DELETE",
@@ -78,11 +81,11 @@ class m {
78
81
  ...s == null ? void 0 : s.headers,
79
82
  ...t == null ? void 0 : t.headers
80
83
  }
81
- }, e = await fetch(o, a).catch(() => {
82
- throw new r("Failed to delete url", 0);
84
+ }, e = await fetch(r, a).catch(() => {
85
+ throw new h("Failed to delete url", 0);
83
86
  });
84
87
  if (!e.ok)
85
- throw new r(e.statusText, e.status);
88
+ throw new h(e.statusText, e.status);
86
89
  }
87
90
  }
88
91
  export {
@@ -15917,3 +15917,5 @@ export type ApiStrkDelegatedStaking = z.infer<typeof apiStrkDelegatedStakingSche
15917
15917
  export type ApiStaking = z.infer<typeof apiStakingPositionSchema>;
15918
15918
  export type ApiDelegatedTokens = z.infer<typeof apiDelegatedTokensSchema>;
15919
15919
  export type ApiDelegatedTokensArray = z.infer<typeof apiDelegatedTokensArraySchema>;
15920
+ export type ApiStrkDelegatedStakingPosition = z.infer<typeof apiStrkDelegatedStakingPositionsSchema>;
15921
+ export type ApiStrkLiquidStakingPosition = z.infer<typeof apiStakingPositionsSchema>;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("zod"),o=require("../../../chains/starknet/address.cjs"),z=require("./backend.model.cjs"),m=require("./defiPositionType.model.cjs"),n=require("./webToken.model.cjs"),s=n.webTokenWithBalanceAndPriceSchema.extend({accruedFees:e.z.string(),currentPrice:e.z.string(),maxPrice:e.z.string(),minPrice:e.z.string(),principal:e.z.string()}),t=e.z.object({address:o.addressSchema.optional(),currencyValue:e.z.string().default("0")}),a=t.extend({poolFeePercentage:e.z.string(),tickSpacingPercentage:e.z.string().optional(),tokenId:e.z.string().optional(),unitCurrencyValueToken0:e.z.string().optional(),unitCurrencyValueToken1:e.z.string().optional(),token0:s,token1:s}),g=e.z.array(a),h=e.z.object({name:e.z.string().optional(),healthRatio:e.z.string().optional(),accountAddress:o.addressSchema.optional()}),i=t.extend({totalBalances:e.z.record(e.z.string()),collateral:e.z.boolean(),debt:e.z.boolean(),lending:e.z.boolean(),apy:e.z.string().optional(),totalApy:e.z.string().optional(),group:e.z.string().optional(),unitCurrencyValue:e.z.string().optional(),positionToken:z.apiTokenInfoSchema.or(e.z.undefined()),token:n.webTokenWithBalanceAndPriceSchema.optional(),accountAddress:o.addressSchema.optional(),accountAddressGroup:e.z.string().optional()}),S=e.z.array(i),r=t.extend({delegatingTo:o.addressSchema,token:n.webTokenWithBalanceAndPriceSchema.optional(),balance:e.z.string(),unitCurrencyValue:e.z.string().optional().default("0")}),P=e.z.array(r),c=t.extend({apy:e.z.string().optional(),totalApy:e.z.string().optional(),unitCurrencyValue:e.z.string().optional()}),y=e.z.array(c),d=a.or(i).or(r).or(c),l=e.z.record(e.z.object({name:e.z.string().optional(),healthRatio:e.z.string().optional(),accountAddress:o.addressSchema.optional()})),p=e.z.object({type:m.defiPositionTypeSchema,manageUrl:e.z.string().url().optional(),name:e.z.string(),positions:e.z.array(d),positionsTotalValue:e.z.string(),brandColor:e.z.string().optional(),groups:l.optional(),accountAddress:o.addressSchema}),u=e.z.array(p),b=e.z.object({dappId:e.z.string(),products:u});exports.collateralizedDebtGroupSchema=h;exports.collateralizedDebtPositionSchema=i;exports.collateralizedDebtPositionsSchema=S;exports.concentratedLiquidityPositionSchema=a;exports.concentratedLiquidityPositionsSchema=g;exports.defiDappsProductsSchema=b;exports.defiPositionSchema=d;exports.defiProductSchema=p;exports.defiProductsSchema=u;exports.delegatedTokensArraySchema=P;exports.delegatedTokensSchema=r;exports.productGroupsSchema=l;exports.stakingPositionSchema=c;exports.stakingPositionsSchema=y;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("zod"),t=require("../../../chains/starknet/address.cjs"),m=require("./backend.model.cjs"),p=require("./defiPositionType.model.cjs"),o=require("./webToken.model.cjs"),l=o.webTokenWithBalanceAndPriceSchema.extend({accruedFees:e.z.string(),currentPrice:e.z.string(),maxPrice:e.z.string(),minPrice:e.z.string(),principal:e.z.string()}),a=e.z.object({address:t.addressSchema.optional(),currencyValue:e.z.string().default("0")}),i=a.extend({poolFeePercentage:e.z.string(),tickSpacingPercentage:e.z.string().optional(),tokenId:e.z.string().optional(),unitCurrencyValueToken0:e.z.string().optional(),unitCurrencyValueToken1:e.z.string().optional(),token0:l,token1:l}),S=e.z.array(i),k=e.z.object({name:e.z.string().optional(),healthRatio:e.z.string().optional(),accountAddress:t.addressSchema.optional()}),r=a.extend({totalBalances:e.z.record(e.z.string()),collateral:e.z.boolean(),debt:e.z.boolean(),lending:e.z.boolean(),apy:e.z.string().optional(),totalApy:e.z.string().optional(),group:e.z.string().optional(),unitCurrencyValue:e.z.string().optional(),positionToken:m.apiTokenInfoSchema.or(e.z.undefined()),token:o.webTokenWithBalanceAndPriceSchema.optional(),accountAddress:t.addressSchema.optional(),accountAddressGroup:e.z.string().optional()}),P=e.z.array(r),c=a.extend({delegatingTo:t.addressSchema,token:o.webTokenWithBalanceAndPriceSchema.optional(),balance:e.z.string(),unitCurrencyValue:e.z.string().optional().default("0")}),y=e.z.array(c),n=e.z.object({wei:e.z.string(),eth:e.z.string(),currency:e.z.string()}),s=a.extend({id:e.z.string(),total:n,apy:e.z.number(),totalApy:e.z.number(),token:o.webTokenWithBalanceAndPriceSchema}),b=e.z.array(s),d=a.extend({id:e.z.string(),accruedRewards:n,stakedAmount:n,total:n,apy:e.z.number(),totalApy:e.z.number(),stakerInfo:m.apiStrkDelegatedStakingSchema.shape.data.shape.stakerInfo,token:o.webTokenWithBalanceAndPriceSchema}),T=e.z.array(d),z=i.or(r).or(c).or(d).or(s),g=e.z.record(e.z.object({name:e.z.string().optional(),healthRatio:e.z.string().optional(),accountAddress:t.addressSchema.optional()})),u=e.z.object({type:p.defiPositionTypeSchema,manageUrl:e.z.string().url().optional(),name:e.z.string(),positions:e.z.array(z),positionsTotalValue:e.z.string(),brandColor:e.z.string().optional(),groups:g.optional(),accountAddress:t.addressSchema}),h=e.z.array(u),A=e.z.object({dappId:e.z.string(),products:h});exports.collateralizedDebtGroupSchema=k;exports.collateralizedDebtPositionSchema=r;exports.collateralizedDebtPositionsSchema=P;exports.concentratedLiquidityPositionSchema=i;exports.concentratedLiquidityPositionsSchema=S;exports.defiDappsProductsSchema=A;exports.defiPositionSchema=z;exports.defiProductSchema=u;exports.defiProductsSchema=h;exports.delegatedTokensArraySchema=y;exports.delegatedTokensSchema=c;exports.productGroupsSchema=g;exports.stakingPositionSchema=s;exports.stakingPositionsSchema=b;exports.strkDelegatedStakingPositionArraySchema=T;exports.strkDelegatedStakingPositionSchema=d;