@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.
- package/dist/index.cjs +1 -1
- package/dist/index.js +224 -222
- package/dist/src/http/HttpService.cjs +1 -1
- package/dist/src/http/HttpService.js +33 -30
- package/dist/src/tokens/service/types/backend.model.d.ts +2 -0
- package/dist/src/tokens/service/types/defiPosition.model.cjs +1 -1
- package/dist/src/tokens/service/types/defiPosition.model.d.ts +4120 -1476
- package/dist/src/tokens/service/types/defiPosition.model.js +89 -72
- package/package.json +9 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
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
|
|
2
|
-
import { HttpError as
|
|
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(
|
|
6
|
-
this.requestInit =
|
|
5
|
+
constructor(r, t = "json") {
|
|
6
|
+
this.requestInit = r, this.responseType = t;
|
|
7
7
|
}
|
|
8
|
-
async get(
|
|
9
|
-
const s =
|
|
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(
|
|
19
|
-
|
|
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
|
|
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(
|
|
29
|
-
const a =
|
|
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
|
-
},
|
|
39
|
-
throw new
|
|
41
|
+
}, o = await fetch(r, e).catch(() => {
|
|
42
|
+
throw new h(w.FAILED_TO_POST_URL, 0);
|
|
40
43
|
});
|
|
41
|
-
if (!
|
|
42
|
-
throw new
|
|
43
|
-
if (
|
|
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
|
|
48
|
+
const n = await o.json();
|
|
46
49
|
if (s)
|
|
47
50
|
try {
|
|
48
|
-
return s.parse(
|
|
51
|
+
return s.parse(n);
|
|
49
52
|
} catch (i) {
|
|
50
|
-
throw new
|
|
53
|
+
throw new h(i.message, 0);
|
|
51
54
|
}
|
|
52
|
-
return
|
|
55
|
+
return n;
|
|
53
56
|
}
|
|
54
|
-
async put(
|
|
55
|
-
const s =
|
|
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(
|
|
65
|
-
throw new
|
|
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
|
|
71
|
+
throw new h(e.statusText, e.status);
|
|
69
72
|
return await e.json();
|
|
70
73
|
}
|
|
71
|
-
async delete(
|
|
72
|
-
const s =
|
|
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(
|
|
82
|
-
throw new
|
|
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
|
|
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"),
|
|
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;
|