@argent/x-shared 1.45.1 → 1.46.1

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 i=require("starknet"),n=require("../../errors/address.cjs"),l=require("../../errors/call.cjs"),u=require("../../errors/network.cjs"),w=require("../../utils/starknet/starknet.cjs"),d=require("./address.cjs"),S=require("./network.cjs");function m(r){return r.replace(".stark","").split(".").map(s=>i.starknetId.useEncoded(s).toString(10))}function A(r){const t=S.getChainIdFromNetworkId(r);return i.starknetId.getStarknetIdContract(t)}function k(r,t){const o=A(t),s=m(r);try{const e={domain:s,hint:[]};return w.callSchema.parse({contractAddress:o,entrypoint:"domain_to_address",calldata:e})}catch(a){throw new l.CallError({code:"NOT_VALID",options:{error:a}})}}async function I(r,t,o){if(!t||!o)throw new u.NetworkError({code:"NO_NETWORK_OR_MULTICALL"});let s=null;try{s=k(r,t)}catch(c){throw new l.CallError({code:"NOT_VALID",options:{error:c}})}let a,e;try{a=await o.callContract(s),e=a[0]}catch{throw new n.AddressError({code:"STARKNAME_ERROR"})}if(d.isZeroAddress(e))throw new n.AddressError({code:"STARKNAME_NOT_FOUND",message:`${r} not found`});if(!d.isValidAddress(e))throw new n.AddressError({code:"STARKNAME_INVALID_ADDRESS",message:`${r} resolved to an invalid address (${e})`});return d.normalizeAddress(e)}exports.getAddressFromStarkName=I;exports.getCallFromStarkName=k;exports.getStarknetIdContractAddressFromNetworkId=A;exports.starkNameToCallDataDomain=m;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("starknet"),n=require("../../errors/address.cjs"),i=require("../../errors/call.cjs"),u=require("../../errors/network.cjs"),w=require("../../utils/starknet/starknet.cjs"),d=require("./address.cjs"),S=require("./network.cjs");function l(r){return r.replace(".stark","").split(".").map(s=>c.starknetId.useEncoded(s).toString(10))}function m(r){const t=S.getChainIdFromNetworkId(r);return c.starknetId.getStarknetIdContract(t)}function A(r,t){const o=m(t),s=l(r);try{const e={domain:s,hint:[]};return w.callSchema.parse({contractAddress:o,entrypoint:"domain_to_address",calldata:e})}catch(a){throw new i.CallError({code:"NOT_VALID",options:{error:a}})}}async function I(r,t,o){if(!t||!o)throw new u.NetworkError({code:"NO_NETWORK_OR_MULTICALL"});let s=null;try{s=A(r,t)}catch(N){throw new i.CallError({code:"NOT_VALID",options:{error:N}})}let a,e;try{a=await o.callContract(s),e=a[0]}catch{throw new n.AddressError({code:"STARKNAME_ERROR"})}if(d.isZeroAddress(e))throw new n.AddressError({code:"STARKNAME_NOT_FOUND",message:`${r} not found`});if(!d.isValidAddress(e))throw new n.AddressError({code:"STARKNAME_INVALID_ADDRESS",message:`${r} resolved to an invalid address (${e})`});return d.normalizeAddress(e)}exports.getAddressFromStarkName=I;exports.getCallFromStarkName=A;exports.getStarknetIdContractAddressFromNetworkId=m;exports.starkNameToCallDataDomain=l;
@@ -1,19 +1,19 @@
1
- import { starknetId as c } from "starknet";
1
+ import { starknetId as d } from "starknet";
2
2
  import { AddressError as s } from "../../errors/address.js";
3
- import { CallError as i } from "../../errors/call.js";
3
+ import { CallError as c } from "../../errors/call.js";
4
4
  import { NetworkError as l } from "../../errors/network.js";
5
5
  import { callSchema as A } from "../../utils/starknet/starknet.js";
6
6
  import { isZeroAddress as N, isValidAddress as p, normalizeAddress as f } from "./address.js";
7
7
  import { getChainIdFromNetworkId as w } from "./network.js";
8
- function h(r) {
9
- return r.replace(".stark", "").split(".").map((n) => c.useEncoded(n).toString(10));
8
+ function h(t) {
9
+ return t.replace(".stark", "").split(".").map((n) => d.useEncoded(n).toString(10));
10
10
  }
11
- function I(r) {
12
- const t = w(r);
13
- return c.getStarknetIdContract(t);
11
+ function I(t) {
12
+ const r = w(t);
13
+ return d.getStarknetIdContract(r);
14
14
  }
15
- function S(r, t) {
16
- const e = I(t), n = h(r);
15
+ function S(t, r) {
16
+ const e = I(r), n = h(t);
17
17
  try {
18
18
  const o = { domain: n, hint: [] };
19
19
  return A.parse({
@@ -22,24 +22,24 @@ function S(r, t) {
22
22
  calldata: o
23
23
  });
24
24
  } catch (a) {
25
- throw new i({
25
+ throw new c({
26
26
  code: "NOT_VALID",
27
27
  options: { error: a }
28
28
  });
29
29
  }
30
30
  }
31
- async function g(r, t, e) {
32
- if (!t || !e)
31
+ async function g(t, r, e) {
32
+ if (!r || !e)
33
33
  throw new l({
34
34
  code: "NO_NETWORK_OR_MULTICALL"
35
35
  });
36
36
  let n = null;
37
37
  try {
38
- n = S(r, t);
39
- } catch (d) {
40
- throw new i({
38
+ n = S(t, r);
39
+ } catch (m) {
40
+ throw new c({
41
41
  code: "NOT_VALID",
42
- options: { error: d }
42
+ options: { error: m }
43
43
  });
44
44
  }
45
45
  let a, o;
@@ -53,12 +53,12 @@ async function g(r, t, e) {
53
53
  if (N(o))
54
54
  throw new s({
55
55
  code: "STARKNAME_NOT_FOUND",
56
- message: `${r} not found`
56
+ message: `${t} not found`
57
57
  });
58
58
  if (!p(o))
59
59
  throw new s({
60
60
  code: "STARKNAME_INVALID_ADDRESS",
61
- message: `${r} resolved to an invalid address (${o})`
61
+ message: `${t} resolved to an invalid address (${o})`
62
62
  });
63
63
  return f(o);
64
64
  }
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../../../../errors/address.cjs"),d=require("../../address.cjs"),o=require("../../starknetId.cjs"),n=require("../../getAddressFromStarkName.cjs"),i=require("../../argentName.cjs"),A=require("../../getAddressFromArgentName.cjs");class c{constructor(e,r,t){this.httpService=e,this.baseUrl=r,this.allowedArgentNameNetworkId=t}async parseAddressOrDomain(e,r,t){if(d.isAddress(e))return d.normalizeAddress(e);try{return await this.getAddressFromDomainName(e,r,t)}catch{throw new s.AddressError({code:"NOT_VALID"})}}async getAddressFromDomainName(e,r,t){if(o.isStarknetId(e))return n.getAddressFromStarkName(e,r,t);if(i.isArgentName(e)){if(r!==this.allowedArgentNameNetworkId)throw new s.AddressError({code:"ARGENT_NAME_INVALID_NETWORK",message:`Argent name is only enabled on "${this.allowedArgentNameNetworkId}"`});return A.getAddressFromArgentName(e,this.httpService,this.baseUrl)}throw new s.AddressError({code:"NO_ADDRESS_FROM_DOMAIN"})}}exports.StarknetAddressService=c;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../../../../errors/address.cjs"),d=require("../../address.cjs"),a=require("../../starknetId.cjs"),o=require("../../getAddressFromStarkName.cjs"),n=require("../../argentName.cjs"),i=require("../../getAddressFromArgentName.cjs");class A{constructor(e,r,t){this.httpService=e,this.baseUrl=r,this.allowedArgentNameNetworkId=t}async parseAddressOrDomain(e,r,t){if(d.isAddress(e))return d.normalizeAddress(e);try{return await this.getAddressFromDomainName(e,r,t)}catch{throw new s.AddressError({code:"NOT_VALID"})}}async getAddressFromDomainName(e,r,t){if(a.isStarknetId(e))return o.getAddressFromStarkName(e,r,t);if(n.isArgentName(e)){if(r!==this.allowedArgentNameNetworkId)throw new s.AddressError({code:"ARGENT_NAME_INVALID_NETWORK",message:`Argent name is only enabled on "${this.allowedArgentNameNetworkId}"`});return i.getAddressFromArgentName(e,this.httpService,this.baseUrl)}throw new s.AddressError({code:"NO_ADDRESS_FROM_DOMAIN"})}}exports.StarknetAddressService=A;
@@ -1,16 +1,16 @@
1
1
  import { AddressError as s } from "../../../../errors/address.js";
2
- import { isAddress as i, normalizeAddress as m } from "../../address.js";
3
- import { isStarknetId as a } from "../../starknetId.js";
4
- import { getAddressFromStarkName as d } from "../../getAddressFromStarkName.js";
5
- import { isArgentName as n } from "../../argentName.js";
6
- import { getAddressFromArgentName as A } from "../../getAddressFromArgentName.js";
2
+ import { isAddress as o, normalizeAddress as i } from "../../address.js";
3
+ import { isStarknetId as m } from "../../starknetId.js";
4
+ import { getAddressFromStarkName as a } from "../../getAddressFromStarkName.js";
5
+ import { isArgentName as d } from "../../argentName.js";
6
+ import { getAddressFromArgentName as n } from "../../getAddressFromArgentName.js";
7
7
  class p {
8
8
  constructor(e, r, t) {
9
9
  this.httpService = e, this.baseUrl = r, this.allowedArgentNameNetworkId = t;
10
10
  }
11
11
  async parseAddressOrDomain(e, r, t) {
12
- if (i(e))
13
- return m(e);
12
+ if (o(e))
13
+ return i(e);
14
14
  try {
15
15
  return await this.getAddressFromDomainName(e, r, t);
16
16
  } catch {
@@ -18,15 +18,15 @@ class p {
18
18
  }
19
19
  }
20
20
  async getAddressFromDomainName(e, r, t) {
21
- if (a(e))
22
- return d(e, r, t);
23
- if (n(e)) {
21
+ if (m(e))
22
+ return a(e, r, t);
23
+ if (d(e)) {
24
24
  if (r !== this.allowedArgentNameNetworkId)
25
25
  throw new s({
26
26
  code: "ARGENT_NAME_INVALID_NETWORK",
27
27
  message: `Argent name is only enabled on "${this.allowedArgentNameNetworkId}"`
28
28
  });
29
- return A(e, this.httpService, this.baseUrl);
29
+ return n(e, this.httpService, this.baseUrl);
30
30
  }
31
31
  throw new s({
32
32
  code: "NO_ADDRESS_FROM_DOMAIN"
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=(o,e,t)=>{const r=new Error(o);r.name="FetcherError",r.url=e.url,r.status=e.status,r.statusText=e.statusText,r.responseText=t;try{const s=JSON.parse(t);r.responseJson=s}catch{}return r},n=async(o,e)=>{const t=await fetch(o,e),r=await t.text();if(!t.ok)throw c("An error occurred while fetching",t,r);try{return JSON.parse(r)}catch{throw c("An error occurred while parsing",t,r)}},a=async(o,e)=>{const t=await fetch(o,{method:"POST",...e}),r=await t.text();if(!t.ok)throw c("An error occurred while fetching",t,r);try{return JSON.parse(r)}catch{throw c("An error occurred while parsing",t,r)}};exports.fetchData=n;exports.fetcherError=c;exports.postData=a;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=(o,e,t)=>{const r=new Error(o);r.name="FetcherError",r.url=e.url,r.status=e.status,r.statusText=e.statusText,r.responseText=t;try{const c=JSON.parse(t);r.responseJson=c}catch{}return r},n=async(o,e)=>{const t=await fetch(o,e),r=await t.text();if(!t.ok)throw s("An error occurred while fetching",t,r);try{return JSON.parse(r)}catch{throw s("An error occurred while parsing",t,r)}},a=async(o,e)=>{const t=await fetch(o,{method:"POST",...e}),r=await t.text();if(!t.ok)throw s("An error occurred while fetching",t,r);try{return JSON.parse(r)}catch{throw s("An error occurred while parsing",t,r)}};exports.fetchData=n;exports.fetcherError=s;exports.postData=a;
@@ -1,20 +1,20 @@
1
- const n = (o, e, t) => {
1
+ const s = (o, e, t) => {
2
2
  const r = new Error(o);
3
3
  r.name = "FetcherError", r.url = e.url, r.status = e.status, r.statusText = e.statusText, r.responseText = t;
4
4
  try {
5
- const s = JSON.parse(t);
6
- r.responseJson = s;
5
+ const n = JSON.parse(t);
6
+ r.responseJson = n;
7
7
  } catch {
8
8
  }
9
9
  return r;
10
10
  }, c = async (o, e) => {
11
11
  const t = await fetch(o, e), r = await t.text();
12
12
  if (!t.ok)
13
- throw n("An error occurred while fetching", t, r);
13
+ throw s("An error occurred while fetching", t, r);
14
14
  try {
15
15
  return JSON.parse(r);
16
16
  } catch {
17
- throw n("An error occurred while parsing", t, r);
17
+ throw s("An error occurred while parsing", t, r);
18
18
  }
19
19
  }, a = async (o, e) => {
20
20
  const t = await fetch(o, {
@@ -22,15 +22,15 @@ const n = (o, e, t) => {
22
22
  ...e
23
23
  }), r = await t.text();
24
24
  if (!t.ok)
25
- throw n("An error occurred while fetching", t, r);
25
+ throw s("An error occurred while fetching", t, r);
26
26
  try {
27
27
  return JSON.parse(r);
28
28
  } catch {
29
- throw n("An error occurred while parsing", t, r);
29
+ throw s("An error occurred while parsing", t, r);
30
30
  }
31
31
  };
32
32
  export {
33
33
  c as fetchData,
34
- n as fetcherError,
34
+ s as fetcherError,
35
35
  a as postData
36
36
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("url-join"),o=require("./fetcher.cjs"),c=async(t,r)=>{try{const{time:e}=await o.fetchData(n(t,"time"),{headers:r});return e}catch{throw new Error("failed to request time")}},a=async(t,r)=>{const e=await c(t,r);return Math.floor(e)};exports.getBackendTimeNowSeconds=a;exports.getBackendTimeSeconds=c;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("url-join"),r=require("./fetcher.cjs"),n=async(e,t)=>{try{const{time:c}=await r.fetchData(o(e,"time"),{headers:t});return c}catch{throw new Error("failed to request time")}},a=async(e,t)=>{const c=await n(e,t);return Math.floor(c)};exports.getBackendTimeNowSeconds=a;exports.getBackendTimeSeconds=n;
@@ -1,17 +1,17 @@
1
- import o from "url-join";
1
+ import r from "url-join";
2
2
  import { fetchData as n } from "./fetcher.js";
3
- const a = async (t, r) => {
3
+ const a = async (e, t) => {
4
4
  try {
5
- const { time: e } = await n(o(t, "time"), {
6
- headers: r
5
+ const { time: o } = await n(r(e, "time"), {
6
+ headers: t
7
7
  });
8
- return e;
8
+ return o;
9
9
  } catch {
10
10
  throw new Error("failed to request time");
11
11
  }
12
- }, s = async (t, r) => {
13
- const e = await a(t, r);
14
- return Math.floor(e);
12
+ }, s = async (e, t) => {
13
+ const o = await a(e, t);
14
+ return Math.floor(o);
15
15
  };
16
16
  export {
17
17
  s as getBackendTimeNowSeconds,
@@ -12,6 +12,7 @@ export * from './onchainRecovery';
12
12
  export * from './platform';
13
13
  export * from './signer';
14
14
  export * from './staking';
15
+ export * from './storage';
15
16
  export * from './tokens';
16
17
  export * from './transactions';
17
18
  export * from './utils';
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("zod"),c=require("../utils/starknet/starknet.cjs"),t=require("../chains/starknet/address.cjs"),a=e.z.object({id:e.z.string(),dappId:e.z.string(),productId:e.z.string(),productName:e.z.string(),chain:e.z.string(),name:e.z.string(),description:e.z.string(),iconUrl:e.z.string().url(),learnMoreUrl:e.z.string().url().optional(),riskFactor:e.z.enum(["low"]),metrics:e.z.object({baseApy:e.z.string(),totalApy:e.z.string(),tvl:e.z.string().optional()}),incentives:e.z.array(e.z.object({name:e.z.string(),description:e.z.string(),iconUrl:e.z.string().url(),learnMoreUrl:e.z.string().url(),metric:e.z.object({apy:e.z.string()})})),buyEnabled:e.z.boolean(),sellEnabled:e.z.boolean()}),s=a.extend({category:e.z.literal("staking"),investableAssets:e.z.object({tokenAddresses:e.z.array(t.addressSchemaArgentBackend),tokensRequirement:e.z.enum(["any"])}),withdrawableAssets:e.z.object({tokenAddresses:e.z.array(t.addressSchemaArgentBackend),tokensRequirement:e.z.enum(["any"])}),fees:e.z.object({depositFees:e.z.object({protocolFee:e.z.string().nullable().optional(),totalFee:e.z.string()}),withdrawalFees:e.z.object({protocolFee:e.z.string().nullable().optional(),totalFee:e.z.string()})})}),o=a.extend({category:e.z.literal("lending"),investableAssets:e.z.object({tokenAddresses:e.z.array(t.addressSchemaArgentBackend),tokensRequirement:e.z.enum(["any"])}),withdrawableAssets:e.z.object({tokenAddresses:e.z.array(t.addressSchemaArgentBackend),tokensRequirement:e.z.enum(["any"])}),fees:e.z.object({depositFees:e.z.object({totalFee:e.z.string()}),withdrawalFees:e.z.object({totalFee:e.z.string()})})}),n=e.z.object({name:e.z.string().optional(),iconUrl:e.z.string().url().optional(),address:e.z.string()}),r=a.extend({category:e.z.literal("strkDelegatedStaking"),stakerInfo:n,investableAssets:e.z.object({tokenAddresses:e.z.array(t.addressSchemaArgentBackend),tokensRequirement:e.z.enum(["any"]),useDecomposedBalances:e.z.boolean().optional()}),withdrawableAssets:e.z.object({tokenAddresses:e.z.array(t.addressSchemaArgentBackend),tokensRequirement:e.z.enum(["any"]),useDecomposedBalances:e.z.boolean().optional(),amountsRequirement:e.z.enum(["fullBalance"]).optional(),timelockDuration:e.z.number().optional()}),fees:e.z.object({depositFees:e.z.object({argentFee:e.z.string().nullable().optional(),protocolFee:e.z.string().nullable().optional(),providerFee:e.z.string().nullable().optional(),totalFee:e.z.string()}),withdrawalFees:e.z.object({argentFee:e.z.string().nullable().optional(),protocolFee:e.z.string().nullable().optional(),providerFee:e.z.string().nullable().optional(),totalFee:e.z.string()}),performanceFees:e.z.object({argentFee:e.z.string().nullable().optional(),protocolFee:e.z.string().nullable().optional(),providerFee:e.z.string().nullable().optional(),totalFee:e.z.string()}).optional()}),claimEnabled:e.z.boolean().optional()}),i=e.z.discriminatedUnion("category",[s,o,r]),z=e.z.object({investments:e.z.array(i)}),d=e.z.object({calls:e.z.array(c.callSchema)}),m=e.z.object({investmentId:e.z.string(),stakerInfo:n,accountAddress:t.addressSchemaArgentBackend,tokenAddress:t.addressSchemaArgentBackend,amount:e.z.string()}),l=e.z.enum(["stake","initiateWithdraw","withdraw","claim"]),g=e.z.object({stakingAction:l,stakerInfo:n,tokenAddress:t.addressSchema,amount:e.z.string()});exports.investmentMetaSchema=g;exports.investmentSchema=i;exports.investmentsResponseSchema=z;exports.lendingInvestmentSchema=o;exports.stakerInfoSchema=n;exports.stakingActionSchema=l;exports.stakingInvestmentSchema=s;exports.strkDelegatedStakingInvestmentSchema=r;exports.strkStakingCalldataResponseSchema=d;exports.strkStakingCalldataSchema=m;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("zod"),c=require("../utils/starknet/starknet.cjs"),t=require("../chains/starknet/address.cjs"),a=e.z.object({id:e.z.string(),dappId:e.z.string(),productId:e.z.string(),productName:e.z.string(),chain:e.z.string(),name:e.z.string(),description:e.z.string(),iconUrl:e.z.string().url(),learnMoreUrl:e.z.string().url().optional(),riskFactor:e.z.enum(["low"]),metrics:e.z.object({baseApy:e.z.string(),totalApy:e.z.string(),tvl:e.z.string().optional()}),incentives:e.z.array(e.z.object({name:e.z.string(),description:e.z.string(),iconUrl:e.z.string().url(),learnMoreUrl:e.z.string().url(),metric:e.z.object({apy:e.z.string()})})),buyEnabled:e.z.boolean(),sellEnabled:e.z.boolean()}),s=a.extend({category:e.z.literal("staking"),investableAssets:e.z.object({tokenAddresses:e.z.array(t.addressSchemaArgentBackend),tokensRequirement:e.z.enum(["any"])}),withdrawableAssets:e.z.object({tokenAddresses:e.z.array(t.addressSchemaArgentBackend),tokensRequirement:e.z.enum(["any"])}),fees:e.z.object({depositFees:e.z.object({protocolFee:e.z.string().nullable().optional(),totalFee:e.z.string()}),withdrawalFees:e.z.object({protocolFee:e.z.string().nullable().optional(),totalFee:e.z.string()})})}),o=a.extend({category:e.z.literal("lending"),investableAssets:e.z.object({tokenAddresses:e.z.array(t.addressSchemaArgentBackend),tokensRequirement:e.z.enum(["any"])}),withdrawableAssets:e.z.object({tokenAddresses:e.z.array(t.addressSchemaArgentBackend),tokensRequirement:e.z.enum(["any"])}),fees:e.z.object({depositFees:e.z.object({totalFee:e.z.string()}),withdrawalFees:e.z.object({totalFee:e.z.string()})})}),n=e.z.object({name:e.z.string().optional(),iconUrl:e.z.string().url().optional(),address:e.z.string()}),r=a.extend({category:e.z.literal("strkDelegatedStaking"),stakerInfo:n,investableAssets:e.z.object({tokenAddresses:e.z.array(t.addressSchemaArgentBackend),tokensRequirement:e.z.enum(["any"]),useDecomposedBalances:e.z.boolean().optional()}),withdrawableAssets:e.z.object({tokenAddresses:e.z.array(t.addressSchemaArgentBackend),tokensRequirement:e.z.enum(["any"]),useDecomposedBalances:e.z.boolean().optional(),amountsRequirement:e.z.enum(["fullBalance"]).optional(),timelockDuration:e.z.number().optional()}),fees:e.z.object({depositFees:e.z.object({argentFee:e.z.string().nullable().optional(),protocolFee:e.z.string().nullable().optional(),providerFee:e.z.string().nullable().optional(),totalFee:e.z.string()}),withdrawalFees:e.z.object({argentFee:e.z.string().nullable().optional(),protocolFee:e.z.string().nullable().optional(),providerFee:e.z.string().nullable().optional(),totalFee:e.z.string()}),performanceFees:e.z.object({argentFee:e.z.string().nullable().optional(),protocolFee:e.z.string().nullable().optional(),providerFee:e.z.string().nullable().optional(),totalFee:e.z.string()}).optional()}),buyEnabled:e.z.boolean().optional(),sellEnabled:e.z.boolean().optional(),claimEnabled:e.z.boolean().optional()}),i=e.z.discriminatedUnion("category",[s,o,r]),z=e.z.object({investments:e.z.array(i)}),d=e.z.object({calls:e.z.array(c.callSchema)}),m=e.z.object({investmentId:e.z.string(),stakerInfo:n,accountAddress:t.addressSchemaArgentBackend,tokenAddress:t.addressSchemaArgentBackend,amount:e.z.string()}),l=e.z.enum(["stake","initiateWithdraw","withdraw","claim"]),g=e.z.object({stakingAction:l,stakerInfo:n,tokenAddress:t.addressSchema,amount:e.z.string()});exports.investmentMetaSchema=g;exports.investmentSchema=i;exports.investmentsResponseSchema=z;exports.lendingInvestmentSchema=o;exports.stakerInfoSchema=n;exports.stakingActionSchema=l;exports.stakingInvestmentSchema=s;exports.strkDelegatedStakingInvestmentSchema=r;exports.strkStakingCalldataResponseSchema=d;exports.strkStakingCalldataSchema=m;
@@ -609,6 +609,8 @@ export declare const strkDelegatedStakingInvestmentSchema: z.ZodObject<z.objectU
609
609
  providerFee?: string | null | undefined;
610
610
  } | undefined;
611
611
  }>;
612
+ buyEnabled: z.ZodOptional<z.ZodBoolean>;
613
+ sellEnabled: z.ZodOptional<z.ZodBoolean>;
612
614
  claimEnabled: z.ZodOptional<z.ZodBoolean>;
613
615
  }>, "strip", z.ZodTypeAny, {
614
616
  name: string;
@@ -634,8 +636,6 @@ export declare const strkDelegatedStakingInvestmentSchema: z.ZodObject<z.objectU
634
636
  apy: string;
635
637
  };
636
638
  }[];
637
- buyEnabled: boolean;
638
- sellEnabled: boolean;
639
639
  category: "strkDelegatedStaking";
640
640
  investableAssets: {
641
641
  tokenAddresses: `0x${string}`[];
@@ -675,6 +675,8 @@ export declare const strkDelegatedStakingInvestmentSchema: z.ZodObject<z.objectU
675
675
  iconUrl?: string | undefined;
676
676
  };
677
677
  learnMoreUrl?: string | undefined;
678
+ buyEnabled?: boolean | undefined;
679
+ sellEnabled?: boolean | undefined;
678
680
  claimEnabled?: boolean | undefined;
679
681
  }, {
680
682
  name: string;
@@ -700,8 +702,6 @@ export declare const strkDelegatedStakingInvestmentSchema: z.ZodObject<z.objectU
700
702
  apy: string;
701
703
  };
702
704
  }[];
703
- buyEnabled: boolean;
704
- sellEnabled: boolean;
705
705
  category: "strkDelegatedStaking";
706
706
  investableAssets: {
707
707
  tokenAddresses: string[];
@@ -741,6 +741,8 @@ export declare const strkDelegatedStakingInvestmentSchema: z.ZodObject<z.objectU
741
741
  iconUrl?: string | undefined;
742
742
  };
743
743
  learnMoreUrl?: string | undefined;
744
+ buyEnabled?: boolean | undefined;
745
+ sellEnabled?: boolean | undefined;
744
746
  claimEnabled?: boolean | undefined;
745
747
  }>;
746
748
  export declare const investmentSchema: z.ZodDiscriminatedUnion<"category", [z.ZodObject<z.objectUtil.extendShape<{
@@ -1337,6 +1339,8 @@ export declare const investmentSchema: z.ZodDiscriminatedUnion<"category", [z.Zo
1337
1339
  providerFee?: string | null | undefined;
1338
1340
  } | undefined;
1339
1341
  }>;
1342
+ buyEnabled: z.ZodOptional<z.ZodBoolean>;
1343
+ sellEnabled: z.ZodOptional<z.ZodBoolean>;
1340
1344
  claimEnabled: z.ZodOptional<z.ZodBoolean>;
1341
1345
  }>, "strip", z.ZodTypeAny, {
1342
1346
  name: string;
@@ -1362,8 +1366,6 @@ export declare const investmentSchema: z.ZodDiscriminatedUnion<"category", [z.Zo
1362
1366
  apy: string;
1363
1367
  };
1364
1368
  }[];
1365
- buyEnabled: boolean;
1366
- sellEnabled: boolean;
1367
1369
  category: "strkDelegatedStaking";
1368
1370
  investableAssets: {
1369
1371
  tokenAddresses: `0x${string}`[];
@@ -1403,6 +1405,8 @@ export declare const investmentSchema: z.ZodDiscriminatedUnion<"category", [z.Zo
1403
1405
  iconUrl?: string | undefined;
1404
1406
  };
1405
1407
  learnMoreUrl?: string | undefined;
1408
+ buyEnabled?: boolean | undefined;
1409
+ sellEnabled?: boolean | undefined;
1406
1410
  claimEnabled?: boolean | undefined;
1407
1411
  }, {
1408
1412
  name: string;
@@ -1428,8 +1432,6 @@ export declare const investmentSchema: z.ZodDiscriminatedUnion<"category", [z.Zo
1428
1432
  apy: string;
1429
1433
  };
1430
1434
  }[];
1431
- buyEnabled: boolean;
1432
- sellEnabled: boolean;
1433
1435
  category: "strkDelegatedStaking";
1434
1436
  investableAssets: {
1435
1437
  tokenAddresses: string[];
@@ -1469,6 +1471,8 @@ export declare const investmentSchema: z.ZodDiscriminatedUnion<"category", [z.Zo
1469
1471
  iconUrl?: string | undefined;
1470
1472
  };
1471
1473
  learnMoreUrl?: string | undefined;
1474
+ buyEnabled?: boolean | undefined;
1475
+ sellEnabled?: boolean | undefined;
1472
1476
  claimEnabled?: boolean | undefined;
1473
1477
  }>]>;
1474
1478
  export type Investment = z.infer<typeof investmentSchema>;
@@ -2070,6 +2074,8 @@ export declare const investmentsResponseSchema: z.ZodObject<{
2070
2074
  providerFee?: string | null | undefined;
2071
2075
  } | undefined;
2072
2076
  }>;
2077
+ buyEnabled: z.ZodOptional<z.ZodBoolean>;
2078
+ sellEnabled: z.ZodOptional<z.ZodBoolean>;
2073
2079
  claimEnabled: z.ZodOptional<z.ZodBoolean>;
2074
2080
  }>, "strip", z.ZodTypeAny, {
2075
2081
  name: string;
@@ -2095,8 +2101,6 @@ export declare const investmentsResponseSchema: z.ZodObject<{
2095
2101
  apy: string;
2096
2102
  };
2097
2103
  }[];
2098
- buyEnabled: boolean;
2099
- sellEnabled: boolean;
2100
2104
  category: "strkDelegatedStaking";
2101
2105
  investableAssets: {
2102
2106
  tokenAddresses: `0x${string}`[];
@@ -2136,6 +2140,8 @@ export declare const investmentsResponseSchema: z.ZodObject<{
2136
2140
  iconUrl?: string | undefined;
2137
2141
  };
2138
2142
  learnMoreUrl?: string | undefined;
2143
+ buyEnabled?: boolean | undefined;
2144
+ sellEnabled?: boolean | undefined;
2139
2145
  claimEnabled?: boolean | undefined;
2140
2146
  }, {
2141
2147
  name: string;
@@ -2161,8 +2167,6 @@ export declare const investmentsResponseSchema: z.ZodObject<{
2161
2167
  apy: string;
2162
2168
  };
2163
2169
  }[];
2164
- buyEnabled: boolean;
2165
- sellEnabled: boolean;
2166
2170
  category: "strkDelegatedStaking";
2167
2171
  investableAssets: {
2168
2172
  tokenAddresses: string[];
@@ -2202,6 +2206,8 @@ export declare const investmentsResponseSchema: z.ZodObject<{
2202
2206
  iconUrl?: string | undefined;
2203
2207
  };
2204
2208
  learnMoreUrl?: string | undefined;
2209
+ buyEnabled?: boolean | undefined;
2210
+ sellEnabled?: boolean | undefined;
2205
2211
  claimEnabled?: boolean | undefined;
2206
2212
  }>]>, "many">;
2207
2213
  }, "strip", z.ZodTypeAny, {
@@ -2319,8 +2325,6 @@ export declare const investmentsResponseSchema: z.ZodObject<{
2319
2325
  apy: string;
2320
2326
  };
2321
2327
  }[];
2322
- buyEnabled: boolean;
2323
- sellEnabled: boolean;
2324
2328
  category: "strkDelegatedStaking";
2325
2329
  investableAssets: {
2326
2330
  tokenAddresses: `0x${string}`[];
@@ -2360,6 +2364,8 @@ export declare const investmentsResponseSchema: z.ZodObject<{
2360
2364
  iconUrl?: string | undefined;
2361
2365
  };
2362
2366
  learnMoreUrl?: string | undefined;
2367
+ buyEnabled?: boolean | undefined;
2368
+ sellEnabled?: boolean | undefined;
2363
2369
  claimEnabled?: boolean | undefined;
2364
2370
  })[];
2365
2371
  }, {
@@ -2477,8 +2483,6 @@ export declare const investmentsResponseSchema: z.ZodObject<{
2477
2483
  apy: string;
2478
2484
  };
2479
2485
  }[];
2480
- buyEnabled: boolean;
2481
- sellEnabled: boolean;
2482
2486
  category: "strkDelegatedStaking";
2483
2487
  investableAssets: {
2484
2488
  tokenAddresses: string[];
@@ -2518,6 +2522,8 @@ export declare const investmentsResponseSchema: z.ZodObject<{
2518
2522
  iconUrl?: string | undefined;
2519
2523
  };
2520
2524
  learnMoreUrl?: string | undefined;
2525
+ buyEnabled?: boolean | undefined;
2526
+ sellEnabled?: boolean | undefined;
2521
2527
  claimEnabled?: boolean | undefined;
2522
2528
  })[];
2523
2529
  }>;
@@ -105,6 +105,8 @@ const n = e.object({
105
105
  totalFee: e.string()
106
106
  }).optional()
107
107
  }),
108
+ buyEnabled: e.boolean().optional(),
109
+ sellEnabled: e.boolean().optional(),
108
110
  claimEnabled: e.boolean().optional()
109
111
  }), c = e.discriminatedUnion("category", [
110
112
  r,
@@ -0,0 +1,14 @@
1
+ import { IObjectStore, IRepository } from '../interface';
2
+ export declare class MockFnObjectStore<T> implements IObjectStore<T> {
3
+ namespace: string;
4
+ get: import('vitest').Mock<(...args: any[]) => any>;
5
+ set: import('vitest').Mock<(...args: any[]) => any>;
6
+ subscribe: import('vitest').Mock<(...args: any[]) => any>;
7
+ }
8
+ export declare class MockFnRepository<T> implements IRepository<T> {
9
+ namespace: string;
10
+ get: import('vitest').Mock<(...args: any[]) => any>;
11
+ upsert: import('vitest').Mock<(...args: any[]) => any>;
12
+ subscribe: import('vitest').Mock<(...args: any[]) => any>;
13
+ remove: import('vitest').Mock<(...args: any[]) => any>;
14
+ }
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("lodash-es");function f(t){return{compareFn:g.isEqual,mergeFn:(i,n)=>n,...t}}function h(t,i={}){const{compareFn:n,mergeFn:u}=f(i);return t.reduce((r,e)=>r.some(o=>n(o,e))?r.map(o=>n(o,e)?u(o,e):o):[...r,e],[])}function p(t,i,n={}){const{compareFn:u,mergeFn:r}=f(n),e=n.insertMode??"push",o=h(t,n);return i.reduce((s,a)=>{const c=s.findIndex(d=>u(d,a));return c===-1?e==="unshift"?[a,...s]:[...s,a]:[...s.slice(0,c),r(s[c],a),...s.slice(c+1)]},o)}function l(t){const i=r=>r;return{defaults:[],serialize:i,deserialize:i,compare:(r,e)=>r===e,merge:(r,e)=>e,...t}}exports.mergeArrayStableWith=p;exports.optionsWithDefaults=l;
@@ -0,0 +1,10 @@
1
+ import { IRepositoryOptions } from './interface';
2
+ interface OptionFunctions<T> {
3
+ compareFn?: (a: T, b: T) => boolean;
4
+ mergeFn?: (a: T, b: T) => T;
5
+ }
6
+ export declare function mergeArrayStableWith<T>(source: T[], other: T[], options?: OptionFunctions<T> & {
7
+ insertMode?: "unshift" | "push";
8
+ }): T[];
9
+ export declare function optionsWithDefaults<T, O extends IRepositoryOptions<T>>(options: O): Required<IRepositoryOptions<T>> & O;
10
+ export {};
@@ -0,0 +1,38 @@
1
+ import { isEqual as d } from "lodash-es";
2
+ function a(t) {
3
+ return {
4
+ compareFn: d,
5
+ mergeFn: (i, e) => e,
6
+ ...t
7
+ };
8
+ }
9
+ function g(t, i = {}) {
10
+ const { compareFn: e, mergeFn: u } = a(i);
11
+ return t.reduce((r, n) => r.some((o) => e(o, n)) ? r.map((o) => e(o, n) ? u(o, n) : o) : [...r, n], []);
12
+ }
13
+ function h(t, i, e = {}) {
14
+ const { compareFn: u, mergeFn: r } = a(e), n = e.insertMode ?? "push", o = g(t, e);
15
+ return i.reduce((s, c) => {
16
+ const f = s.findIndex((p) => u(p, c));
17
+ return f === -1 ? n === "unshift" ? [c, ...s] : [...s, c] : [
18
+ ...s.slice(0, f),
19
+ r(s[f], c),
20
+ ...s.slice(f + 1)
21
+ ];
22
+ }, o);
23
+ }
24
+ function F(t) {
25
+ const i = (r) => r;
26
+ return {
27
+ defaults: [],
28
+ serialize: i,
29
+ deserialize: i,
30
+ compare: (r, n) => r === n,
31
+ merge: (r, n) => n,
32
+ ...t
33
+ };
34
+ }
35
+ export {
36
+ h as mergeArrayStableWith,
37
+ F as optionsWithDefaults
38
+ };
@@ -0,0 +1,3 @@
1
+ export type * from './interface';
2
+ export * from './utils';
3
+ export * from './base';
@@ -0,0 +1,91 @@
1
+ import { SelectorFn } from '../tokens';
2
+ /**
3
+ * Represents a value of type T or a Promise of type T.
4
+ */
5
+ export type AllowPromise<T> = T | Promise<T>;
6
+ /**
7
+ * Represents a value of type T or an array of type T.
8
+ */
9
+ export type AllowArray<T> = T | T[];
10
+ /**
11
+ * A function that takes an array of values of type T and returns an array of values of type T.
12
+ */
13
+ export type SetterFn<T> = (value: T[]) => T[];
14
+ /**
15
+ * Represents a change in storage, including the old and new values.
16
+ */
17
+ export interface StorageChange<T = any> {
18
+ /** Optional. The new value of the item, if there is a new value. */
19
+ newValue?: T;
20
+ /** Optional. The old value of the item, if there was an old value. */
21
+ oldValue?: T;
22
+ }
23
+ /**
24
+ * Represents options for creating a new repository.
25
+ */
26
+ export interface IRepositoryOptions<T> {
27
+ /** The namespace for the repository. */
28
+ namespace: string;
29
+ /** Optional. The default values for the repository. */
30
+ defaults?: T[];
31
+ /** Optional. A function that serializes a value of type T. */
32
+ serialize?: (value: T[]) => any;
33
+ /** Optional. A function that deserializes a value to type T. */
34
+ deserialize?: (value: any) => AllowPromise<T[]>;
35
+ /** Optional. A function that compares two values of type T and returns a boolean. */
36
+ compare?: (a: T, b: T) => boolean;
37
+ /** Optional. A function that merges two values of type T. */
38
+ merge?: (oldValue: T, newValue: T) => T;
39
+ }
40
+ export type UpsertResult = {
41
+ created: number;
42
+ updated: number;
43
+ };
44
+ /**
45
+ * Represents a repository for managing data of type T.
46
+ */
47
+ export interface IRepository<T> {
48
+ /** The namespace for the repository. */
49
+ namespace: string;
50
+ /**
51
+ * Retrieves items from the repository based on the provided selector function.
52
+ * @param selector - Optional. A function that filters the items to be retrieved.
53
+ * @returns A Promise that resolves to an array of items of type T.
54
+ */
55
+ get(selector?: SelectorFn<T>): Promise<T[]>;
56
+ /**
57
+ * Inserts or updates items in the repository.
58
+ * @param value - An array of items, a single item, or a setter function that operates on an array of items.
59
+ * @returns A Promise that resolves to a boolean indicating whether the operation succeeded.
60
+ */
61
+ upsert(value: AllowArray<T> | SetterFn<T>, insertMode?: "push" | "unshift"): Promise<UpsertResult>;
62
+ /**
63
+ * Removes items from the repository based on the provided value or selector function.
64
+ * @param value - An array of items, a single item, or a selector function that filters the items to be removed.
65
+ * @returns A Promise that resolves to an array of removed items of type T.
66
+ */
67
+ remove(value: AllowArray<T> | SelectorFn<T>): Promise<T[]>;
68
+ /**
69
+ * Subscribes to changes in the repository.
70
+ * @param callback - A function that gets called when there are changes in the repository.
71
+ * @returns A function that can be called to unsubscribe from the changes.
72
+ */
73
+ subscribe(callback: (changeSet: StorageChange<T[]>) => AllowPromise<void>): () => void;
74
+ }
75
+ export interface IObjectStoreOptions<T> {
76
+ namespace: string;
77
+ /** Optional. The default values for the repository. */
78
+ defaults?: T;
79
+ /** Optional. A function that serializes a value of type T. */
80
+ serialize?: (value: T) => any;
81
+ /** Optional. A function that deserializes a value to type T. */
82
+ deserialize?: (value: any) => AllowPromise<T>;
83
+ /** Optional. A function that merges two values of type T. */
84
+ merge?: (oldValue: T, newValue: Partial<T>) => T;
85
+ }
86
+ export interface IObjectStore<T> {
87
+ namespace: string;
88
+ get(): Promise<T>;
89
+ set(value: Partial<T>): Promise<void>;
90
+ subscribe(callback: (value: StorageChange<Partial<T>>) => AllowPromise<void>): () => void;
91
+ }
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function n(e,f,r,i){if(typeof e=="object"&&e!==null)for(const t in e)typeof e[t]=="object"&&e[t]!==null?n(e[t],f,r,i):(!i||i.includes(t))&&e[t]===f&&(e[t]=r);else Array.isArray(e)&&e.forEach((t,l)=>{typeof t=="object"&&t!==null?n(t,f,r,i):t===f&&(e[l]=r)})}function c(e,f){if(typeof e=="object"&&e!==null){for(const r in e)if(typeof e[r]=="object"&&e[r]!==null){if(c(e[r],f))return!0}else if(e[r]===f)return!0}else if(Array.isArray(e)){for(const r of e)if(typeof r=="object"&&r!==null){if(c(r,f))return!0}else if(r===f)return!0}return!1}exports.containsValue=c;exports.replaceValueRecursively=n;
@@ -0,0 +1,5 @@
1
+ /** Function to recursively replace the value in an object or array
2
+ * Optionally, the replacement can be limited to specific keys
3
+ */
4
+ export declare function replaceValueRecursively(obj: any, oldValue: any, newValue: any, keys?: string[]): void;
5
+ export declare function containsValue(obj: any, value: any): boolean;
@@ -0,0 +1,30 @@
1
+ function n(r, t, f, i) {
2
+ if (typeof r == "object" && r !== null)
3
+ for (const e in r)
4
+ typeof r[e] == "object" && r[e] !== null ? n(r[e], t, f, i) : (!i || i.includes(e)) && r[e] === t && (r[e] = f);
5
+ else Array.isArray(r) && r.forEach((e, l) => {
6
+ typeof e == "object" && e !== null ? n(e, t, f, i) : e === t && (r[l] = f);
7
+ });
8
+ }
9
+ function c(r, t) {
10
+ if (typeof r == "object" && r !== null) {
11
+ for (const f in r)
12
+ if (typeof r[f] == "object" && r[f] !== null) {
13
+ if (c(r[f], t))
14
+ return !0;
15
+ } else if (r[f] === t)
16
+ return !0;
17
+ } else if (Array.isArray(r)) {
18
+ for (const f of r)
19
+ if (typeof f == "object" && f !== null) {
20
+ if (c(f, t))
21
+ return !0;
22
+ } else if (f === t)
23
+ return !0;
24
+ }
25
+ return !1;
26
+ }
27
+ export {
28
+ c as containsValue,
29
+ n as replaceValueRecursively
30
+ };
@@ -1,10 +1,10 @@
1
- const r = async (t, e) => {
1
+ const e = async (t, a) => {
2
2
  try {
3
- return await t.getClassHashAt(e), !0;
3
+ return await t.getClassHashAt(a), !0;
4
4
  } catch {
5
5
  return !1;
6
6
  }
7
7
  };
8
8
  export {
9
- r as isContractDeployed
9
+ e as isContractDeployed
10
10
  };